mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-16 02:41:05 +00:00
feat: initial commit
This commit is contained in:
parent
bde7dd644f
commit
72dc38ea56
119 changed files with 14925 additions and 1 deletions
13
src/components/TooltipIcon/TooltipIcon.Story.svelte
Normal file
13
src/components/TooltipIcon/TooltipIcon.Story.svelte
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<script>
|
||||
import Filter16 from 'carbon-icons-svelte/lib/Filter16';
|
||||
import Layout from '../../internal/ui/Layout.svelte';
|
||||
import TooltipIcon from './TooltipIcon.svelte';
|
||||
</script>
|
||||
|
||||
<Layout>
|
||||
<div>
|
||||
<TooltipIcon {...$$props}>
|
||||
<Filter16 />
|
||||
</TooltipIcon>
|
||||
</div>
|
||||
</Layout>
|
||||
26
src/components/TooltipIcon/TooltipIcon.stories.js
Normal file
26
src/components/TooltipIcon/TooltipIcon.stories.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { withKnobs, select, text } from '@storybook/addon-knobs';
|
||||
import Component from './TooltipIcon.Story.svelte';
|
||||
|
||||
export default { title: 'TooltipIcon', decorators: [withKnobs] };
|
||||
|
||||
const directions = {
|
||||
'Top (top)': 'top',
|
||||
'Right (right)': 'right',
|
||||
'Bottom (bottom)': 'bottom',
|
||||
'Left (left)': 'left'
|
||||
};
|
||||
|
||||
const alignments = {
|
||||
'Start (start)': 'start',
|
||||
'Center (center)': 'center',
|
||||
'End (end)': 'end'
|
||||
};
|
||||
|
||||
export const Default = () => ({
|
||||
Component,
|
||||
props: {
|
||||
direction: select('Tooltip direction (direction)', directions, 'bottom'),
|
||||
align: select('Tooltip alignment (align)', alignments, 'center'),
|
||||
tooltipText: text('Tooltip content (tooltipText)', 'Filter')
|
||||
}
|
||||
});
|
||||
31
src/components/TooltipIcon/TooltipIcon.svelte
Normal file
31
src/components/TooltipIcon/TooltipIcon.svelte
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<script>
|
||||
let className = undefined;
|
||||
export { className as class };
|
||||
export let direction = 'bottom';
|
||||
export let align = 'center';
|
||||
export let id = Math.random();
|
||||
export let tooltipText = '';
|
||||
export let props = {};
|
||||
|
||||
import { cx } from '../../lib';
|
||||
|
||||
const _class = cx(
|
||||
'--tooltip__trigger',
|
||||
'--tooltip--a11y',
|
||||
`--tooltip--${direction}`,
|
||||
`--tooltip--align-${align}`,
|
||||
className
|
||||
);
|
||||
</script>
|
||||
|
||||
<button
|
||||
{...props}
|
||||
on:click
|
||||
on:mouseover
|
||||
on:mouseenter
|
||||
on:mouseleave
|
||||
class={_class}
|
||||
aria-describedby={id}>
|
||||
<span class={cx('--assistive-text')} {id}>{tooltipText}</span>
|
||||
<slot />
|
||||
</button>
|
||||
3
src/components/TooltipIcon/index.js
Normal file
3
src/components/TooltipIcon/index.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import TooltipIcon from './TooltipIcon.svelte';
|
||||
|
||||
export default TooltipIcon;
|
||||
Loading…
Add table
Add a link
Reference in a new issue