diff --git a/packages/materialdesign-components/package.json b/packages/materialdesign-components/package.json index ba2e4dc891..1629b78963 100644 --- a/packages/materialdesign-components/package.json +++ b/packages/materialdesign-components/package.json @@ -46,5 +46,8 @@ ], "version": "0.0.24", "license": "MIT", - "gitHead": "115189f72a850bfb52b65ec61d932531bf327072" + "gitHead": "115189f72a850bfb52b65ec61d932531bf327072", + "dependencies": { + "@material/select": "4.0.0" + } } diff --git a/packages/materialdesign-components/src/Button/Button.svelte b/packages/materialdesign-components/src/Button/Button.svelte index 84e3395987..7c8821547a 100644 --- a/packages/materialdesign-components/src/Button/Button.svelte +++ b/packages/materialdesign-components/src/Button/Button.svelte @@ -34,10 +34,6 @@ const clicked = () => _bb.call(onClick) - $: if (icon) { - setContext("BBMD:icon:context", "button") - } - $: renderLeadingIcon = !!icon && !trailingIcon $: renderTrailingIcon = !!icon && trailingIcon @@ -54,11 +50,11 @@ {disabled} on:click={clicked}> {#if renderLeadingIcon} - + {/if} {text} {#if renderTrailingIcon} - + {/if} {/if} diff --git a/packages/materialdesign-components/src/Common/Icon.svelte b/packages/materialdesign-components/src/Common/Icon.svelte index e2c309f73e..d4820fcf6c 100644 --- a/packages/materialdesign-components/src/Common/Icon.svelte +++ b/packages/materialdesign-components/src/Common/Icon.svelte @@ -2,11 +2,9 @@ import { getContext } from "svelte" export let icon = "" + export let context = "" - let iconContext = getContext("BBMD:icon:context") - let cls = iconContext - ? `material-icons mdc-${iconContext}__icon` - : "material-icons" + let cls = !!context ? `material-icons mdc-${context}__icon` : "material-icons" {icon} diff --git a/packages/materialdesign-components/src/List/List.svelte b/packages/materialdesign-components/src/List/List.svelte index 21cecbeada..eae7018d1b 100644 --- a/packages/materialdesign-components/src/List/List.svelte +++ b/packages/materialdesign-components/src/List/List.svelte @@ -17,31 +17,25 @@ export let onSelect = selectedItems => {} export let singleSelection = false - export let variant = "two-line" + export let variant = "one-line" export let inputElement = null let selectedItemsStore let role = "listbox" - function createOrAcceptItemStore() { - let store = _bb.getContext("BBMD:list:selectItemStore") - if (!!store) { - selectedItemsStore = store - } else { - selectedItemsStore = createItemsStore(() => onSelect($selectedItemsStore)) - _bb.setContext("BBMD:list:selectItemStore", selectedItemsStore) - } - } - onMount(() => { - createOrAcceptItemStore() + let ctx = getContext("BBMD:list:context") + + selectedItemsStore = createItemsStore(() => onSelect($selectedItemsStore)) + _bb.setContext("BBMD:list:selectItemStore", selectedItemsStore) _bb.setContext("BBMD:list:props", { inputElement, variant, singleSelection, }) + if (!!list) { if (!inputElement) { instance = new MDCList(list) diff --git a/packages/materialdesign-components/src/List/ListItem.svelte b/packages/materialdesign-components/src/List/ListItem.svelte index 775d73d2e2..f60396ae4d 100644 --- a/packages/materialdesign-components/src/List/ListItem.svelte +++ b/packages/materialdesign-components/src/List/ListItem.svelte @@ -2,13 +2,12 @@ import { onMount, getContext } from "svelte" import { Radiobutton } from "../Radiobutton" import { Checkbox } from "../Checkbox" + import Icon from "../Common/Icon.svelte" import ClassBuilder from "../ClassBuilder.js" import { generate } from "shortid" const cb = new ClassBuilder("list-item") - export let onClick = item => {} - let _id let listProps = null @@ -16,7 +15,7 @@ export let _bb - export let value = null + export let value = "" export let text = "" export let secondaryText = "" @@ -24,6 +23,7 @@ export let trailingIcon = "" export let selected = false export let disabled = false + export let dividerAfter = false let role = "option" @@ -84,7 +84,13 @@ listProps && listProps.variant === "two-line" && !!secondaryText -
  • +
  • {#if leadingIcon}
  • +{#if dividerAfter} +