mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
chore: lift components folder
This commit is contained in:
parent
76df51674d
commit
2200b29b92
301 changed files with 57 additions and 76 deletions
40
src/TooltipIcon/TooltipIcon.svelte
Normal file
40
src/TooltipIcon/TooltipIcon.svelte
Normal file
|
@ -0,0 +1,40 @@
|
|||
<script>
|
||||
export let tooltipText = "";
|
||||
export let align = "center"; // "start" | "center" | "end"
|
||||
export let direction = "bottom"; // "top" | "right" | "bottom" | "left"
|
||||
export let id = "ccs-" + Math.random().toString(36);
|
||||
export let ref = null;
|
||||
|
||||
$: hidden = false;
|
||||
</script>
|
||||
|
||||
<svelte:body
|
||||
on:keydown={e => {
|
||||
if (e.key === 'Escape') {
|
||||
hidden = true;
|
||||
}
|
||||
}} />
|
||||
|
||||
<button
|
||||
bind:this={ref}
|
||||
aria-describedby={id}
|
||||
class:bx--tooltip__trigger={true}
|
||||
class:bx--tooltip--a11y={true}
|
||||
class:bx--tooltip--hidden={hidden}
|
||||
class="{direction && `bx--tooltip--${direction}`}
|
||||
{align && `bx--tooltip--align-${align}`}"
|
||||
{...$$restProps}
|
||||
on:click
|
||||
on:mouseover
|
||||
on:mouseenter
|
||||
on:mouseenter={() => {
|
||||
hidden = false;
|
||||
}}
|
||||
on:mouseleave
|
||||
on:focus
|
||||
on:focus={() => {
|
||||
hidden = false;
|
||||
}}>
|
||||
<span {id} class:bx--assistive-text={true}>{tooltipText}</span>
|
||||
<slot />
|
||||
</button>
|
Loading…
Add table
Add a link
Reference in a new issue