-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(OnyxNavBar): implement basic mobile nav bar (#1252)
Relates to #1073 - implement basic mobile nav bar - fix selected styles for nested OnyxNavItem options
- Loading branch information
1 parent
c58780d
commit 0511127
Showing
33 changed files
with
443 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"sit-onyx": patch | ||
--- | ||
|
||
fix(OnyxNavItem): fix styles for selected child items |
Binary file added
BIN
+18.7 KB
...t/snapshots/components/OnyxMobileNavButton/Mobile-nav-button-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+22.5 KB
...ht/snapshots/components/OnyxMobileNavButton/Mobile-nav-button-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.7 KB
...ght/snapshots/components/OnyxMobileNavButton/Mobile-nav-button-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+120 Bytes
(100%)
.../playwright/snapshots/components/OnyxNavAppArea/Nav-app-area-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-448 Bytes
(99%)
...x/playwright/snapshots/components/OnyxNavAppArea/Nav-app-area-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-87 Bytes
(100%)
...yx/playwright/snapshots/components/OnyxNavAppArea/Nav-app-area-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-9.44 KB
(66%)
...aywright/snapshots/components/OnyxNavBar/Navigation-bar-2xs--chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-10.3 KB
(71%)
...laywright/snapshots/components/OnyxNavBar/Navigation-bar-2xs--firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-9.76 KB
(64%)
...playwright/snapshots/components/OnyxNavBar/Navigation-bar-2xs--webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.09 KB
(97%)
.../playwright/snapshots/components/OnyxNavBar/Navigation-bar-lg--webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.11 KB
(97%)
.../playwright/snapshots/components/OnyxNavBar/Navigation-bar-md--webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.11 KB
(96%)
.../playwright/snapshots/components/OnyxNavBar/Navigation-bar-sm--webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.15 KB
(97%)
.../playwright/snapshots/components/OnyxNavBar/Navigation-bar-xl--webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-12.1 KB
(62%)
...laywright/snapshots/components/OnyxNavBar/Navigation-bar-xs--chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-13.5 KB
(67%)
...playwright/snapshots/components/OnyxNavBar/Navigation-bar-xs--firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-12.5 KB
(59%)
.../playwright/snapshots/components/OnyxNavBar/Navigation-bar-xs--webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
packages/sit-onyx/src/components/OnyxMobileNavButton/OnyxMobileNavButton.ct.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { test } from "../../playwright/a11y"; | ||
import { executeMatrixScreenshotTest, mockPlaywrightIcon } from "../../playwright/screenshots"; | ||
import OnyxMobileNavButton from "./OnyxMobileNavButton.vue"; | ||
|
||
test.describe("Screenshot tests", () => { | ||
executeMatrixScreenshotTest({ | ||
name: "Mobile nav button", | ||
columns: ["default", "open"], | ||
rows: ["default", "hover", "active", "focus-visible"], | ||
component: (column) => ( | ||
<OnyxMobileNavButton label="Label" icon={mockPlaywrightIcon} open={column === "open"} /> | ||
), | ||
beforeScreenshot: async (component, page, column, row) => { | ||
if (row === "hover") await component.hover(); | ||
if (row === "focus-visible") await page.keyboard.press("Tab"); | ||
if (row === "active") { | ||
const box = (await component.boundingBox())!; | ||
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2); | ||
await page.mouse.down(); | ||
} | ||
}, | ||
}); | ||
}); |
37 changes: 37 additions & 0 deletions
37
packages/sit-onyx/src/components/OnyxMobileNavButton/OnyxMobileNavButton.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import menu from "@sit-onyx/icons/menu.svg?raw"; | ||
import { defineStorybookActionsAndVModels } from "@sit-onyx/storybook-utils"; | ||
import type { Meta, StoryObj } from "@storybook/vue3"; | ||
import { defineIconSelectArgType } from "../../utils/storybook"; | ||
import OnyxMobileNavButton from "./OnyxMobileNavButton.vue"; | ||
|
||
/** | ||
* Nav button that is mainly used inside the nav bar on mobile, e.g. for the burger and context menu buttons. | ||
*/ | ||
const meta: Meta<typeof OnyxMobileNavButton> = { | ||
title: "support/MobileNavButton", | ||
...defineStorybookActionsAndVModels({ | ||
component: OnyxMobileNavButton, | ||
events: ["update:open"], | ||
argTypes: { | ||
icon: defineIconSelectArgType(), | ||
}, | ||
}), | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof OnyxMobileNavButton>; | ||
|
||
export const Default = { | ||
args: { | ||
label: "Open burger menu", | ||
icon: menu, | ||
}, | ||
} satisfies Story; | ||
|
||
export const Open = { | ||
args: { | ||
label: "Close burger menu", | ||
icon: menu, | ||
open: true, | ||
}, | ||
} satisfies Story; |
60 changes: 60 additions & 0 deletions
60
packages/sit-onyx/src/components/OnyxMobileNavButton/OnyxMobileNavButton.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<script lang="ts" setup> | ||
import x from "@sit-onyx/icons/x.svg?raw"; | ||
import OnyxIcon from "../OnyxIcon/OnyxIcon.vue"; | ||
import type { OnyxMobileNavButtonProps } from "./types"; | ||
const props = withDefaults(defineProps<OnyxMobileNavButtonProps>(), { | ||
open: false, | ||
}); | ||
const emit = defineEmits<{ | ||
/** | ||
* Emitted when the open state changes on click. | ||
*/ | ||
"update:open": [isOpen: boolean]; | ||
}>(); | ||
</script> | ||
|
||
<template> | ||
<button | ||
class="onyx-mobile-nav-button" | ||
:class="{ 'onyx-mobile-nav-button--active': props.open }" | ||
:aria-label="props.label" | ||
@click="emit('update:open', !props.open)" | ||
> | ||
<OnyxIcon :icon="props.open ? x : props.icon" /> | ||
</button> | ||
</template> | ||
|
||
<style lang="scss"> | ||
@use "../../styles/mixins/layers.scss"; | ||
.onyx-mobile-nav-button { | ||
@include layers.component() { | ||
display: flex; | ||
background-color: var(--onyx-color-base-background-blank); | ||
color: var(--onyx-color-text-icons-neutral-medium); | ||
padding: var(--onyx-spacing-md); | ||
cursor: pointer; | ||
:where(&) { | ||
border: none; | ||
} | ||
&:hover:not(&--active) { | ||
background-color: var(--onyx-color-base-background-tinted); | ||
} | ||
&:focus-visible { | ||
background-color: var(--onyx-color-base-secondary-100); | ||
outline: none; | ||
} | ||
&:active, | ||
&--active { | ||
background-color: var(--onyx-color-base-secondary-100); | ||
color: var(--onyx-color-text-icons-secondary-intense); | ||
} | ||
} | ||
} | ||
</style> |
15 changes: 15 additions & 0 deletions
15
packages/sit-onyx/src/components/OnyxMobileNavButton/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export type OnyxMobileNavButtonProps = { | ||
/** | ||
* Aria label that describes the action when clicking the button. | ||
*/ | ||
label: string; | ||
/** | ||
* Icon to show when closed. | ||
*/ | ||
icon: string; | ||
/** | ||
* Whether the button is considered open / is connected to an open menu/flyout. | ||
* If `true`, an "x" icon will be displayed. | ||
*/ | ||
open?: boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.