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

feat(OnyxNavItem): Implement OnyxNavItem #1367

Merged
merged 29 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e709131
Implement OnyxNavItem
MajaZarkova Jun 20, 2024
9d54e97
docs(changeset): Implement new OnyxNavItem component
MajaZarkova Jun 20, 2024
3a401e5
Merge branch 'main' into feat/883-Implement-OnyxNavItem
MajaZarkova Jun 20, 2024
784ae5e
Update screenshot tests
MajaZarkova Jun 20, 2024
21b03bb
Merge branch 'main' into feat/883-Implement-OnyxNavItem
MajaZarkova Jun 20, 2024
dc45d03
Merge branch 'main' into feat/883-Implement-OnyxNavItem
BoppLi Jun 21, 2024
df220f8
Merge branch 'main' into feat/883-Implement-OnyxNavItem
MajaZarkova Jun 21, 2024
468249b
Merge branch 'main' into feat/883-Implement-OnyxNavItem
BoppLi Jun 21, 2024
96f20ad
Update from main
MajaZarkova Jun 24, 2024
417987f
Merge branch 'main' into feat/883-Implement-OnyxNavItem
MajaZarkova Jun 24, 2024
c4adc91
Mob session work
MajaZarkova Jun 24, 2024
f858247
add href fallback
JoCa96 Jun 24, 2024
63690ee
added more keyboard handlers
JoCa96 Jun 24, 2024
4f5c908
Merge branch 'main' into feat/883-Implement-OnyxNavItem
MajaZarkova Jun 25, 2024
be99d78
Fix composable test
MajaZarkova Jun 25, 2024
eb01d8f
Merge branch 'main' into feat/883-Implement-OnyxNavItem
MajaZarkova Jun 25, 2024
2b3d325
Fix styles
MajaZarkova Jun 25, 2024
fc5f8c5
Fix test
MajaZarkova Jun 25, 2024
435f8db
Add composable tests
MajaZarkova Jun 25, 2024
d499800
Merge branch 'main' into feat/883-Implement-OnyxNavItem
MajaZarkova Jun 26, 2024
9594868
Apply code suggestions
MajaZarkova Jun 26, 2024
08de3e0
Merge branch 'main' into feat/883-Implement-OnyxNavItem
MajaZarkova Jun 26, 2024
e70736e
Resolve conflicts
MajaZarkova Jun 26, 2024
64859e3
Apply code suggestions
MajaZarkova Jun 26, 2024
44d6f89
Merge branch 'main' into feat/883-Implement-OnyxNavItem
MajaZarkova Jun 26, 2024
e2cdfe9
Merge branch 'main' into feat/883-Implement-OnyxNavItem
MajaZarkova Jun 27, 2024
01931b5
Merge branch 'main' into feat/883-Implement-OnyxNavItem
MajaZarkova Jun 27, 2024
1365f46
Add JSDocs
MajaZarkova Jun 27, 2024
7a13014
Merge branch 'main' into feat/883-Implement-OnyxNavItem
BoppLi Jun 27, 2024
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
5 changes: 5 additions & 0 deletions .changeset/little-clouds-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"sit-onyx": minor
---

Implement new OnyxNavItem component
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Locator } from "@playwright/test";
import { expect, test } from "../../playwright/a11y";
import { executeMatrixScreenshotTest } from "../../playwright/screenshots";
import OnyxListItem from "../OnyxListItem/OnyxListItem.vue";
import OnyxNavItem from "../OnyxNavItem/future/OnyxNavItem.vue";
import OnyxNavButton from "./OnyxNavButton.vue";

test.describe("Screenshot tests", () => {
Expand Down Expand Up @@ -58,9 +58,9 @@ test.describe("Screenshot tests with nested children", () => {
component: (column) => (
<OnyxNavButton label="Item" href="#" active={column === "active"}>
<template v-slot:children>
<OnyxListItem>Nested Item 1</OnyxListItem>
<OnyxListItem>Nested Item 2</OnyxListItem>
<OnyxListItem>Nested Item 3</OnyxListItem>
<OnyxNavItem>Nested Item 1</OnyxNavItem>
<OnyxNavItem>Nested Item 2</OnyxNavItem>
<OnyxNavItem>Nested Item 3</OnyxNavItem>
</template>
</OnyxNavButton>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineStorybookActionsAndVModels } from "@sit-onyx/storybook-utils";
import type { Meta, StoryObj } from "@storybook/vue3";
import { h } from "vue";
import OnyxNavButton from "./OnyxNavButton.vue";
import OnyxListItem from "../OnyxListItem/OnyxListItem.vue";
import OnyxNavItem from "../OnyxNavItem/future/OnyxNavItem.vue";
import OnyxBadge from "../OnyxBadge/OnyxBadge.vue";

/**
Expand Down Expand Up @@ -59,7 +59,10 @@ export const WithChildren: Story = {
args: {
...Default.args,
active: true,
children: () => nestedChildren.map(({ label }) => h(OnyxListItem, label)),
children: () =>
nestedChildren.map(({ label, active }) =>
h(OnyxNavItem, { "aria-selected": active }, [label]),
MajaZarkova marked this conversation as resolved.
Show resolved Hide resolved
),
},
decorators: [
(story) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<script setup lang="ts">
MajaZarkova marked this conversation as resolved.
Show resolved Hide resolved
const props = defineProps<{ active?: boolean }>();
</script>
<template>
<li
MajaZarkova marked this conversation as resolved.
Show resolved Hide resolved
MajaZarkova marked this conversation as resolved.
Show resolved Hide resolved
:class="{
'onyx-future-nav-item': true,
'onyx-future-nav-item--active': props.active,
}"
MajaZarkova marked this conversation as resolved.
Show resolved Hide resolved
>
<slot></slot>
</li>
</template>
<style lang="scss">
@use "../../../styles/mixins/layers";
@use "../../../styles/mixins/density.scss";

// TODO: Remove 'future' from className after officialy merging this component with current OnyxNavItem
.onyx-future-nav-item {
@include density.compact {
--onyx-nav-item-padding: var(--onyx-spacing-4xs) var(--onyx-spacing-sm);
}
@include density.default {
--onyx-nav-item-padding: var(--onyx-spacing-2xs) var(--onyx-spacing-sm);
}
@include density.cozy {
--onyx-nav-item-padding: var(--onyx-spacing-sm) var(--onyx-spacing-sm);
}

@include layers.component() {
--onyx-nav-item-color: var(--onyx-color-text-icons-neutral-intense);
--onyx-nav-item-color-selected: var(--onyx-color-text-icons-primary-bold);
--onyx-nav-item-background-hover: var(--onyx-color-base-primary-100);
--onyx-nav-item-background-selected: var(--onyx-color-base-primary-200);

font-family: var(--onyx-font-family);
color: var(--onyx-nav-item-color);
padding: var(--onyx-nav-item-padding);
background-color: var(--onyx-color-base-background-blank);
font-weight: 400;
font-size: 1rem;
line-height: 1.5rem;

border: none;
width: 100%;
outline: none;

display: flex;
align-items: center;
gap: var(--onyx-spacing-sm);

&:not([aria-disabled="true"]) {
cursor: pointer;

&:hover,
&.onyx-future-nav-item--active {
background-color: var(--onyx-nav-item-background-hover);
}

&[aria-selected="true"] {
background-color: var(--onyx-nav-item-background-selected);

&:hover,
&.onyx-future-nav-item--active {
color: var(--onyx-nav-item-color-selected);
}
}
}

&[aria-disabled="true"] {
color: var(--onyx-color-text-icons-neutral-soft);
}
}
}
</style>