Skip to content

Commit

Permalink
feat: adds simple icons to button stories
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Gaukler committed Dec 20, 2024
1 parent 1073594 commit 6d9ed2b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@
"storybook-addon-pseudo-states": "4.0.2",
"typescript": "^5.4.5",
"typescript-eslint": "^8.0.0-alpha.16"
},
"dependencies": {
"lucide": "0.469.0"
}
}
23 changes: 17 additions & 6 deletions packages/documentation/src/elements/button/button-story-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ArgTypes } from "@storybook/web-components";
import { html } from "lit";
import { ArrowRight, Check, createIcons } from "lucide";

type ButtonSize = "default" | "small";
type ButtonVariant = "primary" | "secondary" | "tertiary" | "destructive";
Expand Down Expand Up @@ -46,32 +47,42 @@ export const renderButtons = (args: ButtonArgs, colorScheme: ColorScheme) =>
...args,
size: "default",
label: "Default",
icon: "[Icon]",
icon: "check",
})}
${renderButton({
...args,
size: "default",
label: "Default",
icon: "[Icon]",
icon: "arrow-right",
iconPosition: "right",
})}
${renderButton({ ...args, size: "small", label: "Small" })}
${renderButton({
...args,
size: "small",
label: "Small",
icon: "[Icon]",
icon: "check",
})}
${renderButton({
...args,
size: "small",
label: "Small",
icon: "[Icon]",
icon: "arrow-right",
iconPosition: "right",
})}
</div> `;

const renderButton = (args: ButtonArgs) => {
createIcons({
icons: {
Check,
ArrowRight,
},
attrs: {
// TODO: make icons as high as line-height
},
});

return html`
<button
class="hap-button ${args.variant} ${args.size} ${args.disabled
Expand All @@ -80,11 +91,11 @@ const renderButton = (args: ButtonArgs) => {
?disabled=${args.disabled}
>
${args.icon && args.iconPosition === "left"
? html`<span class="icon">${args.icon}</span>`
? html`<i data-lucide=${args.icon}></i>`
: ""}
${args.label}
${args.icon && args.iconPosition === "right"
? html`<span class="icon">${args.icon}</span>`
? html`<i data-lucide=${args.icon}></i>`
: ""}
</button>
`;
Expand Down
4 changes: 4 additions & 0 deletions packages/foundation/src/elements/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
padding: var(--hap-spacing-sm) var(--hap-spacing-md);
cursor: pointer;
width: max-content;
display: flex;
gap: var(--hap-spacing-sm);
align-items: center;

&.small {
padding: var(--hap-spacing-xs) var(--hap-spacing-sm);
font-size: var(--hap-typography-font-size-bodytext-s);
line-height: var(--hap-typography-line-height-bodytext-s-singleline);
gap: var(--hap-spacing-xs);
}

&:disabled {
Expand Down

0 comments on commit 6d9ed2b

Please sign in to comment.