Skip to content

Commit

Permalink
Nav bar and sidebar menu redesign (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattias800 committed Sep 14, 2023
1 parent d736f91 commit 7075fdf
Show file tree
Hide file tree
Showing 29 changed files with 310 additions and 285 deletions.
55 changes: 55 additions & 0 deletions packages/elements/src/icons/StenaFlag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/elements/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { ReactComponent as StenaFlagSvg } from "./icons/StenaFlag.svg";

export const StenaFlag = StenaFlagSvg;
export * from "./icons/ui/IconsUi";
export * from "./icons/misc/IconsMisc";
export * from "./components/ui/banners/banner/Banner";
Expand Down
4 changes: 4 additions & 0 deletions packages/modal/src/components/drawer/Drawer.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
position: absolute;
transition: transform var(--swui-animation-time-medium) ease-in-out;

&:focus-visible {
outline: unset;
}

&.slideFromLeft,
&.slideFromRight {
transform: translateX(var(--translate-x-outside-screen, 0));
Expand Down
2 changes: 1 addition & 1 deletion packages/panels/src/components/nav-bar/NavBar.module.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.navBar {
/* Theme vars */
--swui-navbar-background-color: var(--lhds-color-blue-500);
--swui-navbar-background-color: var(--lhds-color-ui-50);
--swui-navbar-item-background-color-hover: var(--lhds-color-blue-700);
--swui-navbar-item-background-color-selected: var(--lhds-color-blue-600);
--swui-navbar-item-background-color-selected-hover: var(
Expand Down
27 changes: 4 additions & 23 deletions packages/panels/src/components/nav-bar/NavBar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
faUserFriends,
} from "@fortawesome/free-solid-svg-icons";
import { SidebarMenuCollapsible } from "../sidebar-menu/SidebarMenuCollapsible";
import { SidebarMenuSeparator } from "../sidebar-menu/SidebarMenuSeparator";
import { Story } from "@storybook/react";
import { NavBarHeading } from "./NavBarHeading";
import { SidebarRailMenu } from "../sidebar-menu/rail/SidebarRailMenu";
Expand Down Expand Up @@ -93,19 +92,12 @@ export const Demo: Story<Pick<NavBarProps, "variant">> = ({ variant }) => {
label={"Selected"}
/>
<SidebarMenuCollapsible label={"Level 1.2"} leftIcon={faChartBar}>
<SidebarMenuLink indent label={"Level 2.1"} onClick={onClick} />
<SidebarMenuLink indent label={"Level 2.2"} onClick={onClick} />
<SidebarMenuLink
indent
label={"Level 2.3"}
onClick={onClick}
selected
/>
<SidebarMenuLink indent label={"Level 2.4"} onClick={onClick} />
<SidebarMenuLink label={"Level 2.1"} onClick={onClick} />
<SidebarMenuLink label={"Level 2.2"} onClick={onClick} />
<SidebarMenuLink label={"Level 2.3"} onClick={onClick} selected />
<SidebarMenuLink label={"Level 2.4"} onClick={onClick} />
</SidebarMenuCollapsible>

<SidebarMenuSeparator />

<SidebarMenuHeading label={"Support"} />
<SidebarMenuLink
leftIcon={faBook}
Expand All @@ -117,17 +109,6 @@ export const Demo: Story<Pick<NavBarProps, "variant">> = ({ variant }) => {
label={"Contact"}
onClick={() => alert("Click on contact")}
/>

<Box>
<Box spacing={8}>
<Icon
icon={faPaperPlane}
color={"var(--swui-white)"}
size={50}
data-hover={true}
/>
</Box>
</Box>
</SidebarMenu>
</Column>
</Drawer>
Expand Down
16 changes: 8 additions & 8 deletions packages/panels/src/components/nav-bar/NavBarButton.module.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
.navBarButton {
/* Theme vars */
--swui-nav-bar-button-text-color: var(--lhds-color-ui-50);
--swui-nav-bar-button-text-color: var(--lhds-color-blue-600);
--swui-nav-bar-button-background-color: transparent;
--swui-nav-bar-button-background-color-hover: var(--lhds-color-blue-900);
--swui-nav-bar-button-background-color-focus: var(--lhds-color-blue-700);
--swui-nav-bar-button-background-color-active: var(--lhds-color-blue-800);
--swui-nav-bar-button-background-color-selected: var(--lhds-color-blue-600);
--swui-nav-bar-button-background-color-hover: var(--lhds-color-ui-100);
--swui-nav-bar-button-background-color-focus: var(--lhds-color-ui-200);
--swui-nav-bar-button-background-color-active: var(--lhds-color-ui-200);
--swui-nav-bar-button-background-color-selected: var(--lhds-color-blue-200);
--swui-nav-bar-button-background-color-selected-hover: var(
--lhds-color-blue-700
--lhds-color-blue-100
);
--swui-nav-bar-button-background-color-selected-focus: var(
--lhds-color-blue-700
--lhds-color-blue-300
);
--swui-nav-bar-button-background-color-selected-active: var(
--lhds-color-blue-800
--lhds-color-blue-200
);

/* Flatbutton overrrides */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const NavBarPopoverButton: React.FC<NavBarPopoverButtonProps> = ({
children,
...navBarButtonProps
}) => {
const [isOpen, open, close] = useBoolean(false);
const [isOpen, , close, toggle] = useBoolean(false);

return (
<Popover
Expand All @@ -34,7 +34,7 @@ export const NavBarPopoverButton: React.FC<NavBarPopoverButtonProps> = ({
</>
}
>
<NavBarButton {...navBarButtonProps} onClick={open} />
<NavBarButton {...navBarButtonProps} onClick={toggle} />
</Popover>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
--swui-textinput-animation-time: var(--swui-animation-time-fast);

--swui-textinput-placeholder-color: var(--lhds-color-ui-500);
--swui-textinput-bg-color: var(--lhds-color-blue-600);
--swui-textinput-bg-color: var(--lhds-color-blue-50);
--swui-textinput-border-color: transparent;
--swui-textinput-border-color-hover: transparent;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.sidebarMenuButton {
/* Theme vars */
--swui-nav-bar-side-menu-button-text-color: var(--lhds-color-ui-50);
--swui-nav-bar-side-menu-button-background-color: var(--lhds-color-blue-500);
--swui-nav-bar-side-menu-button-text-color: var(--lhds-color-blue-600);
--swui-nav-bar-side-menu-button-background-color: var(--lhds-color-ui-50);
--swui-nav-bar-side-menu-button-background-color-hover: var(
--lhds-color-blue-600
--lhds-color-ui-100
);
--swui-nav-bar-side-menu-button-background-color-focus: var(
--lhds-color-blue-600
--lhds-color-ui-200
);
--swui-nav-bar-side-menu-button-background-color-active: var(
--lhds-color-blue-700
--lhds-color-ui-200
);

/* State vars */
Expand Down Expand Up @@ -53,6 +53,8 @@
}

.icon {
color: var(--swui-nav-bar-side-menu-button-text-color);
path {
fill: var(--swui-nav-bar-side-menu-button-text-color);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
.navBarUserButton {
/* Theme vars */
--swui-nav-bar-user-button-text-color: var(--lhds-color-ui-50);
--swui-nav-bar-user-button-background-color: var(--lhds-color-blue-700);
--swui-nav-bar-user-button-background-color-hover: var(--lhds-color-blue-900);
--swui-nav-bar-user-button-background-color-focus: var(--lhds-color-blue-700);
--swui-nav-bar-user-button-background-color-active: var(
--lhds-color-blue-800
);
--swui-nav-bar-user-button-text-color: var(--lhds-color-blue-600);
--swui-nav-bar-user-button-background-color: var(--lhds-color-ui-50);
--swui-nav-bar-user-button-background-color-hover: var(--lhds-color-ui-100);
--swui-nav-bar-user-button-background-color-focus: var(--lhds-color-ui-100);
--swui-nav-bar-user-button-background-color-active: var(--lhds-color-ui-200);

/* FlatButton overrides */
--swui-flat-button-text-color: var(--swui-nav-bar-user-button-text-color);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NavBarVariant } from "./NavBar";

const variantToHeight: Record<NavBarVariant, number> = {
compact: 40,
standard: 48,
compact: 32,
standard: 40,
relaxed: 64,
};

Expand Down
33 changes: 21 additions & 12 deletions packages/panels/src/components/sidebar-menu/SidebarMenu.module.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
.sidebarMenu {
/* Theme vars */
--swui-sidebar-menu-separator-color: var(--lhds-color-blue-700);
--swui-sidebar-menu-text-color: var(--swui-white);
--swui-sidebar-menu-icon-color: var(--swui-white);
--swui-sidebar-menu-background-color: var(--lhds-color-blue-500);
--swui-sidebar-menu-background-color-hover: var(--lhds-color-blue-700);
--swui-sidebar-menu-background-color-focus: var(--lhds-color-blue-700);
--swui-sidebar-menu-background-color-active: var(--lhds-color-blue-600);
--swui-sidebar-menu-item-selected: var(--lhds-color-blue-800);
--swui-sidebar-menu-content-padding: var(--swui-metrics-indent)
var(--swui-metrics-indent) var(--swui-metrics-indent) 0;
--swui-sidebar-menu-separator-color: var(--swui-white);
--swui-sidebar-menu-text-color: var(--lhds-color-ui-900);
--swui-sidebar-menu-icon-color: var(--lhds-color-ui-900);
--swui-sidebar-menu-background-color: transparent;
--swui-sidebar-menu-background-color-hover: var(--lhds-color-ui-400);
--swui-sidebar-menu-background-color-focus: var(--lhds-color-ui-400);
--swui-sidebar-menu-background-color-active: var(--lhds-color-ui-300);
--swui-sidebar-menu-background-selected: var(--lhds-color-blue-100);
--swui-sidebar-menu-background-selected-hover: var(--lhds-color-blue-200);
--swui-sidebar-menu-background-selected-focus: var(--lhds-color-blue-200);
--swui-sidebar-menu-background-selected-active: var(--lhds-color-blue-100);

/* State vars */
--current-separator-color: var(--swui-sidebar-menu-separator-color);
Expand All @@ -25,8 +26,16 @@
--current-background-color-active: var(
--swui-sidebar-menu-background-color-active
);
--current-item-selected: var(--swui-sidebar-menu-item-selected);
--current-content-padding: var(--swui-sidebar-menu-content-padding);
--current-background-selected: var(--swui-sidebar-menu-background-selected);
--current-background-selected-hover: var(
--swui-sidebar-menu-background-selected-hover
);
--current-background-selected-focus: var(
--swui-sidebar-menu-background-selected-focus
);
--current-background-selected-active: var(
--swui-sidebar-menu-background-selected-active
);

/* Styling */

Expand Down
33 changes: 19 additions & 14 deletions packages/panels/src/components/sidebar-menu/SidebarMenu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,23 @@ export const Overview = () => {
label={"Selected"}
/>
<SidebarMenuCollapsible label={"Level 1.2"} leftIcon={faChartBar}>
<SidebarMenuLink indent label={"Level 2.1"} onClick={onClick} />
<SidebarMenuLink indent label={"Level 2.2"} onClick={onClick} />
<SidebarMenuLink
indent
label={"Level 2.3"}
onClick={onClick}
selected
/>
<SidebarMenuLink indent label={"Level 2.4"} onClick={onClick} />
<SidebarMenuLink label={"Level 2.1"} onClick={onClick} />
<SidebarMenuLink label={"Level 2.2"} onClick={onClick} />
<SidebarMenuLink label={"Level 2.3"} onClick={onClick} selected />
<SidebarMenuLink label={"Level 2.4"} onClick={onClick} />
<SidebarMenuCollapsible label={"Level 2.5"} leftIcon={faChartBar}>
<SidebarMenuLink label={"Level 3.1"} onClick={onClick} />
<SidebarMenuLink label={"Level 3.2"} onClick={onClick} />
<SidebarMenuCollapsible label={"Level 3.3"} leftIcon={faChartBar}>
<SidebarMenuLink label={"Level 4.1"} onClick={onClick} />
<SidebarMenuLink label={"Level 4.2"} onClick={onClick} />
</SidebarMenuCollapsible>
</SidebarMenuCollapsible>
</SidebarMenuCollapsible>

<SidebarMenuSeparator />
<SidebarMenuCollapsible label={"No icon"}>
<SidebarMenuLink label={"Level 2"} onClick={onClick} />
</SidebarMenuCollapsible>

<SidebarMenuHeading label={"Support"} />
<SidebarMenuLink
Expand Down Expand Up @@ -103,10 +108,10 @@ export const WithoutIcons = () => {
label={"Customers"}
/>
<SidebarMenuCollapsible label={"Statistics"}>
<SidebarMenuLink indent label={"Total"} onClick={onClick} />
<SidebarMenuLink indent label={"Sales region"} onClick={onClick} />
<SidebarMenuLink indent label={"Routes"} onClick={onClick} selected />
<SidebarMenuLink indent label={"Sellers"} onClick={onClick} />
<SidebarMenuLink label={"Total"} onClick={onClick} />
<SidebarMenuLink label={"Sales region"} onClick={onClick} />
<SidebarMenuLink label={"Routes"} onClick={onClick} selected />
<SidebarMenuLink label={"Sellers"} onClick={onClick} />
</SidebarMenuCollapsible>

<SidebarMenuSeparator />
Expand Down
21 changes: 12 additions & 9 deletions packages/panels/src/components/sidebar-menu/SidebarMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ import cx from "classnames";
import * as React from "react";
import styles from "./SidebarMenu.module.css";
import {
SidebarMenuCloseButton,
SidebarMenuCloseButtonProps,
} from "./SidebarMenuCloseButton";
SidebarMenuCloseButtonRow,
SidebarMenuCloseButtonRowProps,
} from "./SidebarMenuCloseButtonRow";
import { getNavbarHeight } from "../nav-bar/NavbarHeightStyleUtil";
import { NavBarVariant } from "../nav-bar/NavBar";
import { SidebarMenuSeparator } from "./SidebarMenuSeparator";

export type SidebarMenuVariant = NavBarVariant;

export interface SidebarMenuProps extends BoxProps {
onCloseClick?: SidebarMenuCloseButtonProps["onClick"];
onCloseClick?: SidebarMenuCloseButtonRowProps["onClick"];
hideCloseButton?: boolean;
collapsed?: boolean;
variant?: SidebarMenuVariant;
Expand All @@ -32,6 +31,7 @@ export const SidebarMenu: React.FC<SidebarMenuProps> = ({

return (
<Box
indent={1}
className={cx(
styles.sidebarMenu,
collapsed ? styles.collapsed : null,
Expand All @@ -44,19 +44,22 @@ export const SidebarMenu: React.FC<SidebarMenuProps> = ({
data-collapsed={collapsed || undefined}
{...boxProps}
>
<Space num={1.5} />

{!hideCloseButton && (
<>
<SidebarMenuCloseButton onClick={onCloseClick} />
<SidebarMenuSeparator />
<Space />
<SidebarMenuCloseButtonRow onClick={onCloseClick} />
<Space num={1.5} />
</>
)}
<Box
className={styles.sidebarMenuContent}
height={"100%"}
background={"var(--current-background-color)"}
>
<Column flex={1}>{children}</Column>
<Column flex={1} gap={1}>
{children}
</Column>
</Box>
</Box>
);
Expand Down
Loading

0 comments on commit 7075fdf

Please sign in to comment.