mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
refactor: use $$restProps API
- add ref prop for applicable components (#196) - add slot to Content Switcher `Switch` component (#183) - remove fillArray, css utilities
This commit is contained in:
parent
4e2959080b
commit
e886d772c7
288 changed files with 4681 additions and 4498 deletions
|
@ -1,20 +1,15 @@
|
|||
<script>
|
||||
let className = undefined;
|
||||
export { className as class };
|
||||
export let selected = undefined;
|
||||
export let border = false;
|
||||
export let selection = false;
|
||||
export let style = undefined;
|
||||
|
||||
import { createEventDispatcher, setContext } from 'svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
import { cx } from '../../lib';
|
||||
import { createEventDispatcher, setContext } from "svelte";
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
const selectedValue = writable(selected);
|
||||
|
||||
let selectedValue = writable(selected);
|
||||
|
||||
setContext('StructuredListWrapper', {
|
||||
setContext("StructuredListWrapper", {
|
||||
selectedValue,
|
||||
update: value => {
|
||||
selectedValue.set(value);
|
||||
|
@ -22,18 +17,18 @@
|
|||
});
|
||||
|
||||
$: selected = $selectedValue;
|
||||
$: {
|
||||
dispatch('change', $selectedValue);
|
||||
}
|
||||
$: dispatch("change", $selectedValue);
|
||||
</script>
|
||||
|
||||
<section
|
||||
aria-label="Structured list section"
|
||||
class:bx--structured-list={true}
|
||||
class:bx--structured-list--border={border}
|
||||
class:bx--structured-list--selection={selection}
|
||||
{...$$restProps}
|
||||
on:click
|
||||
on:mouseover
|
||||
on:mouseenter
|
||||
on:mouseleave
|
||||
aria-label={$$props['aria-label'] || 'Structured list section'}
|
||||
class={cx('--structured-list', border && '--structured-list--border', selection && '--structured-list--selection', className)}
|
||||
{style}>
|
||||
on:mouseleave>
|
||||
<slot />
|
||||
</section>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue