diff --git a/packages/materialdesign-components/package.json b/packages/materialdesign-components/package.json index 02997ee31e..7d09e4b492 100644 --- a/packages/materialdesign-components/package.json +++ b/packages/materialdesign-components/package.json @@ -45,6 +45,7 @@ "@material/data-table": "4.0.0", "@material/form-field": "^4.0.0", "@material/list": "4.0.0", + "@material/menu": "4.0.0", "@material/radio": "^4.0.0", "@material/textfield": "^4.0.0" } diff --git a/packages/materialdesign-components/src/List/List.svelte b/packages/materialdesign-components/src/List/List.svelte index 2ec00c1cd1..7c0cd34282 100644 --- a/packages/materialdesign-components/src/List/List.svelte +++ b/packages/materialdesign-components/src/List/List.svelte @@ -1,64 +1,71 @@ -
+
+ diff --git a/packages/materialdesign-components/src/List/ListItem.svelte b/packages/materialdesign-components/src/List/ListItem.svelte index 92a6f817ed..e676099006 100644 --- a/packages/materialdesign-components/src/List/ListItem.svelte +++ b/packages/materialdesign-components/src/List/ListItem.svelte @@ -1,30 +1,39 @@
  • + import { List } from "../List"; + import { MDCMenu } from "@material/menu"; + import { onMount, setContext } from "svelte"; + export let items = []; + export let singleSelection = true; + export let width = "400px"; + export let open = true; + export let useFixedPosition = false; + export let useAbsolutePosition = false; + //{x: number, y: number} + export let absolutePositionCoords = null; + + let menu = null; + let instance = null; + + onMount(() => { + if (!!menu) { + instance = new MDCMenu(menu); + instance.open = open; + if (useFixedPosition) { + instance.setFixedPosition(true); + } else if (useAbsolutePosition) { + let { x, y } = absolutePositionCoords; + instance.setAbsolutePosition(x | 0, y | 0); + } + } + setContext("BBMD:list:context", "menu"); + }); + + +{#if useFixedPosition || useAbsolutePosition} +
    + +
    +{:else} +
    + + +
    + +
    +
    +{/if} diff --git a/packages/materialdesign-components/src/Menu/_styles.scss b/packages/materialdesign-components/src/Menu/_styles.scss new file mode 100644 index 0000000000..13bd3f1d98 --- /dev/null +++ b/packages/materialdesign-components/src/Menu/_styles.scss @@ -0,0 +1,2 @@ +@import "@material/menu-surface/mdc-menu-surface.scss"; +@import "@material/menu/mdc-menu.scss"; diff --git a/packages/materialdesign-components/src/Menu/index.js b/packages/materialdesign-components/src/Menu/index.js new file mode 100644 index 0000000000..662027b75e --- /dev/null +++ b/packages/materialdesign-components/src/Menu/index.js @@ -0,0 +1,2 @@ +import "./_styles.scss"; +export { default as Menu } from "./Menu.svelte";