Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(OnyxSelect): Add new OnyxSelect storybook example #2019

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/* eslint-disable @typescript-eslint/no-unused-expressions */
import bag from "@sit-onyx/icons/bag.svg?raw";
import plusSmall from "@sit-onyx/icons/plus-small.svg?raw";
import type { Meta, StoryObj } from "@storybook/vue3";
import { computed, h, ref, watchEffect } from "vue";
import { normalizedIncludes } from "../../utils/strings";
import OnyxBadge from "../OnyxBadge/OnyxBadge.vue";
import OnyxButton from "../OnyxButton/OnyxButton.vue";
import OnyxIcon from "../OnyxIcon/OnyxIcon.vue";
import OnyxTag from "../OnyxTag/OnyxTag.vue";
import OnyxSelect from "./OnyxSelect.vue";
import type { SelectOption } from "./types";

Expand Down Expand Up @@ -60,6 +64,15 @@ const GROUPED_DEMO_OPTIONS = [
{ value: "owl", label: "Owl", group: "Air" },
];

const OPTIONS_WITH_ADDITIONAL_DATA = [
"Selected items",
"Price tag",
"Shopping bag",
].map<SelectOption>((option) => ({
value: option.toLowerCase(),
label: option,
}));

/**
* The select is a fundamental element utilized across various components such as
* dropdowns, navigation bars, pagination, tables, etc.
Expand Down Expand Up @@ -432,10 +445,22 @@ export const Skeleton = {
* This example shows a single select with fully custom option content that can be
* passed as slot.
*/
export const CustomOptions = {
export const WithCustomOptions = {
args: {
...Default.args,
option: ({ label }: SelectOption) => ["custom ", h("strong", label), " content"],
options: OPTIONS_WITH_ADDITIONAL_DATA,
option: ({ label }: SelectOption) => {
const style = { display: "flex", "align-items": "center", gap: "0.5rem" };

switch (label) {
case "Selected items":
return [h("div", { style }, [label, h(OnyxBadge, { color: "danger" }, "Sale!")])];
case "Price tag":
return h(OnyxTag, { label });
case "Shopping bag":
return [h("div", { style }, [h(OnyxIcon, { icon: bag }), label])];
}
},
},
} satisfies Story;

Expand Down
Loading