File tree Expand file tree Collapse file tree 4 files changed +26
-6
lines changed Expand file tree Collapse file tree 4 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ export let tooltipID
99export let positionX = undefined
1010/** @type {string} can be one of: "above" or "below" */
1111export let positionY = undefined
12+ /** @type {boolean} whether to show a rich tooltip */
13+ export let rich = false
1214
1315let element = {}
1416let mdcToolTip = {}
@@ -35,8 +37,20 @@ onMount(() => {
3537})
3638 </script >
3739
38- <div bind:this ={element } id ={tooltipID } class =" mdc-tooltip" role =" tooltip" aria-hidden =" true" >
39- <div class ="mdc-tooltip__surface mdc-tooltip__surface-animation {$$props .class || ' ' }" >
40- <slot />
40+ {#if rich }
41+ <div bind:this ={element } id ={tooltipID } class =" mdc-tooltip mdc-tooltip--rich" aria-hidden =" true" role =" tooltip" >
42+ <div class ="mdc-tooltip__surface mdc-tooltip__surface-animation {$$props .class || ' ' }" >
43+ <p class =" mdc-tooltip__content" >
44+ <slot />
45+ </p >
46+ </div >
4147 </div >
42- </div >
48+ {:else }
49+ <div bind:this ={element } id ={tooltipID } class =" mdc-tooltip" role =" tooltip" aria-hidden =" true" >
50+ <div class ="mdc-tooltip__surface mdc-tooltip__surface-animation {$$props .class || ' ' }" >
51+ <span class =" mdc-tooltip__label" >
52+ <slot />
53+ </span >
54+ </div >
55+ </div >
56+ {/if }
Original file line number Diff line number Diff line change 11<script >
22/** @type {string} The id of the element that describes the tooltip. */
33export let ariaDescribedBy
4+ /** @type {string} If the tooltip is rich set this to rich as well */
5+ export let rich = false
46 </script >
57
6- <div class ={$$props .class || ' ' } aria-describedby ={ariaDescribedBy }>
8+ <div class ={( rich ? ' mdc-tooltip-wrapper--rich ' : ' ' ) + ( $$props .class || ' ' ) } aria-describedby ={ariaDescribedBy }>
79 <slot />
810</div >
Original file line number Diff line number Diff line change @@ -306,13 +306,15 @@ declare module '@silintl/ui-components' {
306306 tooltipID ?: string
307307 positionX ?: 'start' | 'center' | 'end'
308308 positionY ?: 'above' | 'below'
309+ rich ?: boolean
309310 class ?: string
310311 }
311312 export class Tooltip extends SvelteComponentTyped < TooltipProps > { }
312313
313314 export namespace Tooltip {
314315 interface TooltipWrapperProps {
315316 ariaDescribedBy ?: string
317+ rich ?: boolean
316318 class ?: string
317319 }
318320 export class Wrapper extends SvelteComponentTyped < TooltipWrapperProps > { }
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ const args = {
1313
1414<Template let:args >
1515 <div class =" flex justify-center my-4" >
16- <Tooltip .Wrapper ariaDescribedBy ={args .tooltipID }>wrapper slot</Tooltip .Wrapper >
16+ <Tooltip .Wrapper rich ={ args . rich } ariaDescribedBy ={args .tooltipID }>wrapper slot</Tooltip .Wrapper >
1717 </div >
1818
1919 <Tooltip {...args }>Tooltip main slot here</Tooltip >
@@ -22,3 +22,5 @@ const args = {
2222<Story name ="Default" {args } />
2323
2424<Story name ="Position" args ={copyAndModifyArgs (args , { positionX: ' start' , positionY: ' above' })} />
25+
26+ <Story name ="Rich" args ={copyAndModifyArgs (args , { rich: true })} />
You can’t perform that action at this time.
0 commit comments