mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
Merge pull request #40 from metonym/refactor
refactor: remove exported props
This commit is contained in:
commit
abcecc645e
7 changed files with 36 additions and 22 deletions
|
@ -24,6 +24,7 @@ Currently, the following components are supported:
|
||||||
- CodeSnippetSkeleton
|
- CodeSnippetSkeleton
|
||||||
- Copy
|
- Copy
|
||||||
- CopyButton
|
- CopyButton
|
||||||
|
- DataTableSkeleton
|
||||||
- InlineLoading
|
- InlineLoading
|
||||||
- Loading
|
- Loading
|
||||||
- Link
|
- Link
|
||||||
|
|
|
@ -15,17 +15,16 @@
|
||||||
isCurrentPage && ariaCurrent !== 'page' && '--breadcrumb-item--current',
|
isCurrentPage && ariaCurrent !== 'page' && '--breadcrumb-item--current',
|
||||||
className
|
className
|
||||||
);
|
);
|
||||||
$: itemProps = { 'aria-current': ariaCurrent, class: cx('--link') };
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if href}
|
{#if href}
|
||||||
<li class={_class} {...props}>
|
<li class={_class} {...props}>
|
||||||
<Link {href} props={itemProps}>
|
<Link {href} aria-current={ariaCurrent}>
|
||||||
<slot />
|
<slot />
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
{:else}
|
{:else}
|
||||||
<li class={_class} {...props}>
|
<li class={_class} {...props}>
|
||||||
<slot props={itemProps} />
|
<slot props={{ 'aria-current': ariaCurrent, class: cx('--link') }} />
|
||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
export let rowCount = 5;
|
export let rowCount = 5;
|
||||||
export let columnCount = 5;
|
export let columnCount = 5;
|
||||||
export let headers = [];
|
export let headers = [];
|
||||||
export let props = {};
|
export let style = undefined;
|
||||||
|
|
||||||
import { cx } from '../../lib';
|
import { cx } from '../../lib';
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<table {...props} on:click on:mouseover on:mouseenter on:mouseleave class={_class}>
|
<table on:click on:mouseover on:mouseenter on:mouseleave {style} class={_class}>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
{#each columns as column, i (column)}
|
{#each columns as column, i (column)}
|
||||||
|
|
|
@ -41,10 +41,6 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 300px;
|
width: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(.loader) {
|
|
||||||
margin-left: 1rem;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<Layout>
|
<Layout>
|
||||||
|
@ -53,7 +49,7 @@
|
||||||
<Button kind="secondary" {disabled}>Cancel</Button>
|
<Button kind="secondary" {disabled}>Cancel</Button>
|
||||||
{#if disabled}
|
{#if disabled}
|
||||||
<InlineLoading
|
<InlineLoading
|
||||||
class="loader"
|
style="margin-left: 1rem;"
|
||||||
description={loadingDescription}
|
description={loadingDescription}
|
||||||
status={success ? 'finished' : 'active'}
|
status={success ? 'finished' : 'active'}
|
||||||
aria-live={ariaLive} />
|
aria-live={ariaLive} />
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
export let description = undefined;
|
export let description = undefined;
|
||||||
export let iconDescription = undefined;
|
export let iconDescription = undefined;
|
||||||
export let successDelay = 1500;
|
export let successDelay = 1500;
|
||||||
export let props = {};
|
export let style = undefined;
|
||||||
|
|
||||||
import { createEventDispatcher, onDestroy } from 'svelte';
|
import { createEventDispatcher, onDestroy } from 'svelte';
|
||||||
import CheckmarkFilled16 from 'carbon-icons-svelte/lib/CheckmarkFilled16';
|
import CheckmarkFilled16 from 'carbon-icons-svelte/lib/CheckmarkFilled16';
|
||||||
|
@ -20,19 +20,26 @@
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
if (timeoutId !== undefined) {
|
if (timeoutId !== undefined) {
|
||||||
clearTimeout(timeoutId);
|
window.clearTimeout(timeoutId);
|
||||||
timeoutId = undefined;
|
timeoutId = undefined;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$: if (status === 'finished') {
|
$: if (status === 'finished') {
|
||||||
timeoutId = setTimeout(() => {
|
timeoutId = window.setTimeout(() => {
|
||||||
dispatch('success');
|
dispatch('success');
|
||||||
}, successDelay);
|
}, successDelay);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div {...props} class={_class} aria-live={$$props['aria-live'] || 'assertive'}>
|
<div
|
||||||
|
on:click
|
||||||
|
on:mouseover
|
||||||
|
on:mouseenter
|
||||||
|
on:mouseleave
|
||||||
|
{style}
|
||||||
|
class={_class}
|
||||||
|
aria-live={$$props['aria-live'] || 'assertive'}>
|
||||||
<div class={cx('--inline-loading__animation')}>
|
<div class={cx('--inline-loading__animation')}>
|
||||||
{#if status === 'error'}
|
{#if status === 'error'}
|
||||||
<Error20 class={cx('--inline-loading--error')} />
|
<Error20 class={cx('--inline-loading--error')} />
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
<script>
|
<script>
|
||||||
export let href = undefined;
|
|
||||||
export let inline = undefined;
|
|
||||||
export let disabled = undefined;
|
|
||||||
|
|
||||||
import Layout from '../../internal/ui/Layout.svelte';
|
import Layout from '../../internal/ui/Layout.svelte';
|
||||||
import Link from './Link.svelte';
|
import Link from './Link.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Layout>
|
<Layout>
|
||||||
<div>
|
<div>
|
||||||
<Link {href} {inline} {disabled}>Link</Link>
|
<Link {...$$props}>Link</Link>
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
export let href = undefined;
|
export let href = undefined;
|
||||||
export let disabled = false;
|
export let disabled = false;
|
||||||
export let inline = false;
|
export let inline = false;
|
||||||
export let props = {};
|
export let style = undefined;
|
||||||
|
|
||||||
import { cx } from '../../lib';
|
import { cx } from '../../lib';
|
||||||
|
|
||||||
|
@ -17,11 +17,26 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if disabled}
|
{#if disabled}
|
||||||
<p {...props} class={_class}>
|
<p
|
||||||
|
on:click
|
||||||
|
on:mouseover
|
||||||
|
on:mouseenter
|
||||||
|
on:mouseleave
|
||||||
|
{style}
|
||||||
|
aria-current={$$props['aria-current']}
|
||||||
|
class={_class}>
|
||||||
<slot />
|
<slot />
|
||||||
</p>
|
</p>
|
||||||
{:else}
|
{:else}
|
||||||
<a {...props} class={_class} {href}>
|
<a
|
||||||
|
on:click
|
||||||
|
on:mouseover
|
||||||
|
on:mouseenter
|
||||||
|
on:mouseleave
|
||||||
|
{style}
|
||||||
|
aria-current={$$props['aria-current']}
|
||||||
|
class={_class}
|
||||||
|
{href}>
|
||||||
<slot />
|
<slot />
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue