File tree Expand file tree Collapse file tree 7 files changed +50
-15
lines changed Expand file tree Collapse file tree 7 files changed +50
-15
lines changed Original file line number Diff line number Diff line change 44 export let id: string | null | undefined ;
55 export let label: string | undefined ;
66 export let description: string | undefined ;
7+ export let truncate: boolean = false ;
78 </script >
89
910<Layout .Stack inline gap =" s" alignItems =" flex-start" direction =" row" >
1011 <slot />
1112 {#if label }
12- <Layout .Stack inline gap =" xxs" >
13- <label for ={id }>
14- <Typography .Text variant ="m-500" >{label }</Typography .Text >
15- </label >
16- {#if description }
17- <Typography .Text variant =" m-400" color =" --fgcolor-neutral-tertiary"
18- >{description }</Typography .Text
19- >
20- {:else if $$slots .description }
21- <slot name =" description" ></slot >
22- {/if }
23- </Layout .Stack >
13+ <div style ={truncate ? ' min-width: 0' : undefined }>
14+ <Layout .Stack inline gap =" xxs" >
15+ <label for ={id }>
16+ <Typography .Text variant ="m-500" {truncate }>{label }</Typography .Text >
17+ </label >
18+ {#if description }
19+ <Typography .Text variant ="m-400" color ="--fgcolor-neutral-tertiary" {truncate }
20+ >{description }</Typography .Text
21+ >
22+ {:else if $$slots .description }
23+ <slot name =" description" ></slot >
24+ {/if }
25+ </Layout .Stack >
26+ </div >
2427 {/if }
2528</Layout .Stack >
2629
Original file line number Diff line number Diff line change 1111 export let description: string | undefined = undefined ;
1212 export let checked: boolean | ' indeterminate' = false ;
1313 export let required: boolean = false ;
14+ export let truncate: boolean = false ;
1415
1516 /* disable checkbox but keep colors */
1617 export let showDisabledState: boolean = true ;
3233 }
3334 </script >
3435
35- <Base {label } {id } {description }>
36+ <Base {label } {id } {description } { truncate } >
3637 <button
3738 bind:this ={element }
3839 {disabled }
Original file line number Diff line number Diff line change 1818 export let label: $$Props [' label' ] = undefined ;
1919 export let description: string | undefined = undefined ;
2020 export let radioInput: $$Props [' radioInput' ] = undefined ;
21+ export let truncate: boolean = false ;
2122 </script >
2223
23- <Base {label } {id } {description }>
24+ <Base {label } {id } {description } { truncate } >
2425 <input
2526 type =" radio"
2627 bind:this ={radioInput }
Original file line number Diff line number Diff line change 1010 export let label: string | undefined = undefined ;
1111 export let description: string | undefined = undefined ;
1212 export let required: boolean = false ;
13+ export let truncate: boolean = false ;
1314
1415 const dispatch = createEventDispatcher ();
1516
3031 $ : localChecked .set (checked );
3132 </script >
3233
33- <Base {label } {id } {description }>
34+ <Base {label } {id } {description } { truncate } >
3435 <button {...$root } use:root {disabled }>
3536 <span class =" thumb" />
3637 <input {...$input } use:input on:invalid on:change {id } {required } />
Original file line number Diff line number Diff line change 5151<Story name ="Disabled" args ={{ disabled : true }} />
5252<Story name ="Disabled but checked" args ={{ disabled : true , checked : true }} />
5353<Story name ="Focus" {play } />
54+ <Story
55+ name =" Truncated"
56+ args ={{
57+ label : ' This is a very long label that should be truncated with an ellipsis when the truncate prop is enabled' ,
58+ description :
59+ ' This is a very long description that should also be truncated with an ellipsis when the truncate prop is enabled' ,
60+ truncate : true
61+ }}
62+ />
Original file line number Diff line number Diff line change 4949 <Selector .Radio id =" id3" label =" Option 3" group =" group" name =" group" value =" 3" />
5050 </Layout .Stack >
5151</Story >
52+ <Story
53+ name =" Truncated"
54+ args ={{
55+ value : ' 1' ,
56+ group : ' truncate-group' ,
57+ label : ' This is a very long label that should be truncated with an ellipsis when the truncate prop is enabled' ,
58+ description :
59+ ' This is a very long description that should also be truncated with an ellipsis when the truncate prop is enabled' ,
60+ truncate : true
61+ }}
62+ />
Original file line number Diff line number Diff line change 4242<Story name ="Checked" args ={{ checked : true }} />
4343<Story name ="Disabled" args ={{ disabled : true }} />
4444<Story name ="Focus" {play } />
45+ <Story
46+ name =" Truncated"
47+ args ={{
48+ label : ' This is a very long label that should be truncated with an ellipsis when the truncate prop is enabled' ,
49+ description :
50+ ' This is a very long description that should also be truncated with an ellipsis when the truncate prop is enabled' ,
51+ truncate : true
52+ }}
53+ />
You can’t perform that action at this time.
0 commit comments