mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
feat: initial commit
This commit is contained in:
parent
bde7dd644f
commit
72dc38ea56
119 changed files with 14925 additions and 1 deletions
14
src/components/Link/Link.Story.svelte
Normal file
14
src/components/Link/Link.Story.svelte
Normal file
|
@ -0,0 +1,14 @@
|
|||
<script>
|
||||
export let href = undefined;
|
||||
export let inline = undefined;
|
||||
export let disabled = undefined;
|
||||
|
||||
import Layout from '../../internal/ui/Layout.svelte';
|
||||
import Link from './Link.svelte';
|
||||
</script>
|
||||
|
||||
<Layout>
|
||||
<div>
|
||||
<Link {href} {inline} {disabled}>Link</Link>
|
||||
</div>
|
||||
</Layout>
|
13
src/components/Link/Link.stories.js
Normal file
13
src/components/Link/Link.stories.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { withKnobs, boolean, text } from '@storybook/addon-knobs';
|
||||
import Component from './Link.Story.svelte';
|
||||
|
||||
export default { title: 'Link', decorators: [withKnobs] };
|
||||
|
||||
export const Default = () => ({
|
||||
Component,
|
||||
props: {
|
||||
href: text('The link href (href)', '#'),
|
||||
inline: boolean('Use the in-line variant (inline)', false),
|
||||
disabled: boolean('Disabled (disabled)', false)
|
||||
}
|
||||
});
|
27
src/components/Link/Link.svelte
Normal file
27
src/components/Link/Link.svelte
Normal file
|
@ -0,0 +1,27 @@
|
|||
<script>
|
||||
let className = undefined;
|
||||
export { className as class };
|
||||
export let href = undefined;
|
||||
export let disabled = false;
|
||||
export let inline = false;
|
||||
export let props = {};
|
||||
|
||||
import { cx } from '../../lib';
|
||||
|
||||
const _class = cx(
|
||||
'--link',
|
||||
disabled && '--link--disabled',
|
||||
inline && '--link--inline',
|
||||
className
|
||||
);
|
||||
</script>
|
||||
|
||||
{#if disabled}
|
||||
<p {...props} class={_class}>
|
||||
<slot />
|
||||
</p>
|
||||
{:else}
|
||||
<a {...props} class={_class} {href}>
|
||||
<slot />
|
||||
</a>
|
||||
{/if}
|
3
src/components/Link/index.js
Normal file
3
src/components/Link/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import Link from './Link.svelte';
|
||||
|
||||
export default Link;
|
Loading…
Add table
Add a link
Reference in a new issue