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
|
@ -0,0 +1,10 @@
|
|||
<script>
|
||||
import Layout from '../../internal/ui/Layout.svelte';
|
||||
import TooltipDefinition from './TooltipDefinition.svelte';
|
||||
</script>
|
||||
|
||||
<Layout>
|
||||
<div>
|
||||
<TooltipDefinition {...$$props}>Defintion Tooltip</TooltipDefinition>
|
||||
</div>
|
||||
</Layout>
|
|
@ -0,0 +1,30 @@
|
|||
import { withKnobs, select, text } from '@storybook/addon-knobs';
|
||||
import Component from './TooltipDefinition.Story.svelte';
|
||||
|
||||
export default { title: 'TooltipDefinition', 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: {
|
||||
triggerClass: text('Trigger element CSS class name (triggerClassName)', ''),
|
||||
direction: select('Tooltip direction (direction)', directions, 'bottom'),
|
||||
align: select('Tooltip alignment to trigger button (align)', alignments, 'start'),
|
||||
tooltipText: text(
|
||||
'Tooltip content (tooltipText)',
|
||||
'Brief description of the dotted, underlined word above.'
|
||||
)
|
||||
}
|
||||
});
|
36
src/components/TooltipDefinition/TooltipDefinition.svelte
Normal file
36
src/components/TooltipDefinition/TooltipDefinition.svelte
Normal file
|
@ -0,0 +1,36 @@
|
|||
<script>
|
||||
let className = undefined;
|
||||
export { className as class };
|
||||
export let direction = 'bottom';
|
||||
export let align = 'center';
|
||||
export let id = Math.random();
|
||||
export let triggerClassName = undefined;
|
||||
export { triggerClassName as triggerClass };
|
||||
export let tooltipText = '';
|
||||
export let props = {};
|
||||
|
||||
import { cx } from '../../lib';
|
||||
|
||||
const _class = cx('--tooltip--definition', '--tooltip--a11y', className);
|
||||
const _triggerClass = cx(
|
||||
'--tooltip__trigger',
|
||||
'--tooltip--a11y',
|
||||
'--tooltip__trigger--definition',
|
||||
`--tooltip--${direction}`,
|
||||
`--tooltip--align-${align}`,
|
||||
triggerClassName
|
||||
);
|
||||
</script>
|
||||
|
||||
<div {...props} class={_class}>
|
||||
<button
|
||||
on:click
|
||||
on:mouseover
|
||||
on:mouseenter
|
||||
on:mouseleave
|
||||
class={_triggerClass}
|
||||
aria-describedby={id}>
|
||||
<slot />
|
||||
</button>
|
||||
<div role="tooltip" class={cx('--assistive-text')} {id}>{tooltipText}</div>
|
||||
</div>
|
3
src/components/TooltipDefinition/index.js
Normal file
3
src/components/TooltipDefinition/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import TooltipDefinition from './TooltipDefinition.svelte';
|
||||
|
||||
export default TooltipDefinition;
|
Loading…
Add table
Add a link
Reference in a new issue