diff --git a/src/components/dropdown/Dropdown.js b/src/components/dropdown/Dropdown.js index e6e6cced..12e14018 100644 --- a/src/components/dropdown/Dropdown.js +++ b/src/components/dropdown/Dropdown.js @@ -1,13 +1,15 @@ -import { html, LitElement } from "lit" +import { html, LitElement, nothing } from "lit" import { createRef, ref } from "lit/directives/ref.js" -import styles from "./dropdown.css" +import { HasSlotController } from "../../lib/hasSlotController.js" import "../button/leu-button.js" import "../menu/leu-menu.js" import "../menu/leu-menu-item.js" import "../popup/leu-popup.js" +import styles from "./dropdown.css" + /** * @tagname leu-dropdown */ @@ -19,6 +21,8 @@ export class LeuDropdown extends LitElement { expanded: { type: Boolean, reflect: true }, } + hasSlotController = new HasSlotController(this, ["icon"]) + constructor() { super() @@ -114,6 +118,7 @@ export class LeuDropdown extends LitElement { } render() { + const hasIcon = this.hasSlotController.test("icon") return html` - ${this - .label}` : nothing} + ${this.label}
- +
` diff --git a/src/components/dropdown/stories/dropdown.stories.js b/src/components/dropdown/stories/dropdown.stories.js index 28ab4f63..1a0a6721 100644 --- a/src/components/dropdown/stories/dropdown.stories.js +++ b/src/components/dropdown/stories/dropdown.stories.js @@ -1,6 +1,12 @@ -import { html } from "lit" +import { html, nothing } from "lit" import "../leu-dropdown.js" +import "../../icon/leu-icon.js" +import { paths as iconPaths } from "../../icon/paths.js" + +/** + * @type {import("@storybook/web-components").Meta} + */ export default { title: "Dropdown", component: "leu-dropdown", @@ -10,10 +16,17 @@ export default { url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=136815-217650&mode=design&t=lzVrtq8lxYVJU5TB-11", }, }, + argTypes: { + icon: { + control: "select", + options: Object.keys(iconPaths), + }, + }, } -function Template({ label, expanded }) { +function Template({ label, expanded, icon }) { return html` + ${icon ? html`` : nothing} Als CSV Tabelle Als XLS Tabelle @@ -28,4 +41,10 @@ function Template({ label, expanded }) { export const Regular = Template.bind({}) Regular.args = { label: "Download", + icon: "download", +} + +export const WithoutIcon = Template.bind({}) +WithoutIcon.args = { + label: "Download", }