diff --git a/.changeset/spotty-worms-leave.md b/.changeset/spotty-worms-leave.md
new file mode 100644
index 000000000..ab1f407a9
--- /dev/null
+++ b/.changeset/spotty-worms-leave.md
@@ -0,0 +1,5 @@
+---
+"sit-onyx": minor
+---
+
+feat: implement OnyxColorSchemeMenuItem
diff --git a/.changeset/wicked-sloths-obey.md b/.changeset/wicked-sloths-obey.md
new file mode 100644
index 000000000..8d0efeac9
--- /dev/null
+++ b/.changeset/wicked-sloths-obey.md
@@ -0,0 +1,5 @@
+---
+"sit-onyx": patch
+---
+
+fix(OnyxMenuItem): make whole button/anchor clickable
diff --git a/apps/alpha-test-app/src/App.vue b/apps/alpha-test-app/src/App.vue
index e4cb57698..0f1705a68 100644
--- a/apps/alpha-test-app/src/App.vue
+++ b/apps/alpha-test-app/src/App.vue
@@ -1,10 +1,9 @@
@@ -66,10 +63,7 @@ const isColorSchemeDialogOpen = ref(false);
-
-
- Appearance
-
+
@@ -87,12 +81,6 @@ const isColorSchemeDialogOpen = ref(false);
-
-
diff --git a/apps/docs/src/development/theming.md b/apps/docs/src/development/theming.md
index 85696eaa2..cdbd2cded 100644
--- a/apps/docs/src/development/theming.md
+++ b/apps/docs/src/development/theming.md
@@ -9,45 +9,26 @@ Per default, onyx will be displayed in light mode after the [initial setup](/dev
## Let the user decide
-In order to let the user switch between light, dark and auto mode, we recommend to use the [OnyxColorSchemeDialog](https://storybook.onyx.schwarz/?path=/docs/navigation-modules-colorschemedialog--docs) component inside the [nav bar](https://storybook.onyx.schwarz/?path=/story/navigation-navbar--with-context-area) together with the [@vueuse/core](https://vueuse.org/core/useColorMode) library:
+In order to let the user switch between light, dark and auto mode, we recommend to use the pre-built [OnyxColorSchemeMenuItem](https://storybook.onyx.schwarz/?path=/docs/navigation-modules-colorschememenuitem--docs) component inside the [nav bar](https://storybook.onyx.schwarz/?path=/story/navigation-navbar--with-context-area) together with the [@vueuse/core](https://vueuse.org/core/useColorMode) library as shown in the example below.
```vue
-
+
+
+
-
-
```
+
+Alternatively, you can use the [OnyxColorSchemeDialog](https://storybook.onyx.schwarz/?path=/docs/navigation-modules-colorschemedialog--docs) component to build your own custom component.
diff --git a/packages/sit-onyx/playwright/snapshots/components/OnyxColorSchemeMenuItem/Color-scheme-menu-item-chromium-linux.png b/packages/sit-onyx/playwright/snapshots/components/OnyxColorSchemeMenuItem/Color-scheme-menu-item-chromium-linux.png
new file mode 100644
index 000000000..b951a93bc
Binary files /dev/null and b/packages/sit-onyx/playwright/snapshots/components/OnyxColorSchemeMenuItem/Color-scheme-menu-item-chromium-linux.png differ
diff --git a/packages/sit-onyx/playwright/snapshots/components/OnyxColorSchemeMenuItem/Color-scheme-menu-item-firefox-linux.png b/packages/sit-onyx/playwright/snapshots/components/OnyxColorSchemeMenuItem/Color-scheme-menu-item-firefox-linux.png
new file mode 100644
index 000000000..486dfa660
Binary files /dev/null and b/packages/sit-onyx/playwright/snapshots/components/OnyxColorSchemeMenuItem/Color-scheme-menu-item-firefox-linux.png differ
diff --git a/packages/sit-onyx/playwright/snapshots/components/OnyxColorSchemeMenuItem/Color-scheme-menu-item-webkit-linux.png b/packages/sit-onyx/playwright/snapshots/components/OnyxColorSchemeMenuItem/Color-scheme-menu-item-webkit-linux.png
new file mode 100644
index 000000000..d5d7bc410
Binary files /dev/null and b/packages/sit-onyx/playwright/snapshots/components/OnyxColorSchemeMenuItem/Color-scheme-menu-item-webkit-linux.png differ
diff --git a/packages/sit-onyx/src/components/OnyxColorSchemeDialog/OnyxColorSchemeDialog.ct.tsx b/packages/sit-onyx/src/components/OnyxColorSchemeDialog/OnyxColorSchemeDialog.ct.tsx
index 985ed1a6b..ec59e728f 100644
--- a/packages/sit-onyx/src/components/OnyxColorSchemeDialog/OnyxColorSchemeDialog.ct.tsx
+++ b/packages/sit-onyx/src/components/OnyxColorSchemeDialog/OnyxColorSchemeDialog.ct.tsx
@@ -34,8 +34,7 @@ test.describe("Screenshot tests", () => {
);
if (row === "hover") {
- // eslint-disable-next-line playwright/no-force-option -- since the radio button is visually hidden, we need to use force here
- await component.getByLabel("Auto").hover({ force: true });
+ await component.getByRole("heading", { name: "Auto" }).hover();
}
},
});
@@ -59,8 +58,7 @@ test("should behave correctly", async ({ mount, page }) => {
);
const clickOption = (label: string) => {
- // eslint-disable-next-line playwright/no-force-option -- since the radio button is visually hidden, we need to use force here
- return component.getByLabel(label).click({ force: true });
+ return component.getByRole("heading", { name: label }).click();
};
// ASSERT (should be focussed initially)
diff --git a/packages/sit-onyx/src/components/OnyxColorSchemeMenuItem/OnyxColorSchemeMenuItem.ct.tsx b/packages/sit-onyx/src/components/OnyxColorSchemeMenuItem/OnyxColorSchemeMenuItem.ct.tsx
new file mode 100644
index 000000000..13b8f8bf4
--- /dev/null
+++ b/packages/sit-onyx/src/components/OnyxColorSchemeMenuItem/OnyxColorSchemeMenuItem.ct.tsx
@@ -0,0 +1,55 @@
+import { expect, test } from "../../playwright/a11y";
+import { executeMatrixScreenshotTest } from "../../playwright/screenshots";
+import type { ColorSchemeValue } from "../OnyxColorSchemeDialog/types";
+import OnyxColorSchemeMenuItem from "./OnyxColorSchemeMenuItem.vue";
+
+test.describe("Screenshot tests", () => {
+ executeMatrixScreenshotTest({
+ name: "Color scheme menu item",
+ columns: ["default"],
+ rows: ["default", "hover"],
+ // TODO: remove when contrast issues are fixed in https://github.com/SchwarzIT/onyx/issues/410
+ disabledAccessibilityRules: ["color-contrast"],
+ component: () => (
+
+ ),
+ beforeScreenshot: async (component, page, column, row) => {
+ if (row === "hover") await component.getByText("Appearance: Auto").hover();
+ },
+ });
+});
+
+test("should behave correctly", async ({ page, mount }) => {
+ const modelValueEvents: ColorSchemeValue[] = [];
+
+ // ARRANGE
+ const component = await mount(OnyxColorSchemeMenuItem, {
+ props: {
+ modelValue: "auto",
+ },
+ on: {
+ "update:modelValue": (value: ColorSchemeValue) => modelValueEvents.push(value),
+ },
+ });
+
+ // ASSERT
+ await expect(component).toContainText("Appearance: Auto");
+
+ // ACT
+ await component.click();
+
+ // ASSERT
+ const dialog = page.getByRole("dialog");
+ await expect(dialog).toBeVisible();
+
+ // ACT
+ await dialog.getByRole("heading", { name: "Light" }).click();
+ await dialog.getByRole("button", { name: "Apply" }).click();
+ await component.update({ props: { modelValue: "light" } });
+
+ // ASSERT
+ await expect(modelValueEvents).toStrictEqual(["light"]);
+ await expect(component).toContainText("Appearance: Light");
+});
diff --git a/packages/sit-onyx/src/components/OnyxColorSchemeMenuItem/OnyxColorSchemeMenuItem.stories.ts b/packages/sit-onyx/src/components/OnyxColorSchemeMenuItem/OnyxColorSchemeMenuItem.stories.ts
new file mode 100644
index 000000000..eea9cd4e3
--- /dev/null
+++ b/packages/sit-onyx/src/components/OnyxColorSchemeMenuItem/OnyxColorSchemeMenuItem.stories.ts
@@ -0,0 +1,30 @@
+import { defineStorybookActionsAndVModels } from "@sit-onyx/storybook-utils";
+import type { Meta, StoryObj } from "@storybook/vue3";
+import OnyxColorSchemeMenuItem from "./OnyxColorSchemeMenuItem.vue";
+
+/**
+ * Pre-built menu item for the `OnyxUserMenu` that can be used inside the nav bar to
+ * display the current color scheme to the user and allow changing it by displaying a `OnyxColorSchemeDialog`.
+ */
+const meta: Meta = {
+ title: "Navigation/modules/ColorSchemeMenuItem",
+ ...defineStorybookActionsAndVModels({
+ component: OnyxColorSchemeMenuItem,
+ events: ["update:modelValue"],
+ decorators: [
+ (story) => ({
+ components: { story },
+ template: `
`,
+ }),
+ ],
+ }),
+};
+
+export default meta;
+type Story = StoryObj;
+
+export const Default = {
+ args: {
+ modelValue: "auto",
+ },
+} satisfies Story;
diff --git a/packages/sit-onyx/src/components/OnyxColorSchemeMenuItem/OnyxColorSchemeMenuItem.vue b/packages/sit-onyx/src/components/OnyxColorSchemeMenuItem/OnyxColorSchemeMenuItem.vue
new file mode 100644
index 000000000..006aa9aea
--- /dev/null
+++ b/packages/sit-onyx/src/components/OnyxColorSchemeMenuItem/OnyxColorSchemeMenuItem.vue
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
diff --git a/packages/sit-onyx/src/components/OnyxColorSchemeMenuItem/types.ts b/packages/sit-onyx/src/components/OnyxColorSchemeMenuItem/types.ts
new file mode 100644
index 000000000..e9513a101
--- /dev/null
+++ b/packages/sit-onyx/src/components/OnyxColorSchemeMenuItem/types.ts
@@ -0,0 +1,8 @@
+import type { ColorSchemeValue } from "../OnyxColorSchemeDialog/types";
+
+export type OnyxColorSchemeMenuItemProps = {
+ /**
+ * Currently active color scheme.
+ */
+ modelValue: ColorSchemeValue;
+};
diff --git a/packages/sit-onyx/src/components/OnyxMenuItem/OnyxMenuItem.vue b/packages/sit-onyx/src/components/OnyxMenuItem/OnyxMenuItem.vue
index 4b0ee8e63..6de0c9e72 100644
--- a/packages/sit-onyx/src/components/OnyxMenuItem/OnyxMenuItem.vue
+++ b/packages/sit-onyx/src/components/OnyxMenuItem/OnyxMenuItem.vue
@@ -1,10 +1,10 @@
+
+