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

[Darkside] 💄 New ToggleGroup design #3460

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
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
28 changes: 19 additions & 9 deletions @navikt/core/css/darkside/toggle-group.darkside.css
KenAJoh marked this conversation as resolved.
Show resolved Hide resolved
HalvorHaugan marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
border-radius: var(--ax-border-radius-medium);
background-color: transparent;
box-shadow: inset 0 0 0 1px var(--ax-border-default);
padding: var(--ax-spacing-1);
gap: var(--ax-spacing-1);
display: inline-grid;
grid-auto-flow: column;
grid-auto-columns: 1fr;
gap: 1px;
}

/* Button */
Expand All @@ -26,13 +25,14 @@
align-items: center;
justify-content: center;
padding: var(--ax-spacing-1) var(--ax-spacing-3);
min-height: 2.5rem;
min-height: 3rem;
border: none;
cursor: pointer;
background-color: transparent;
color: var(--ax-text-default);
border-radius: var(--ax-border-radius-small);
border-radius: var(--ax-border-radius-medium);
min-width: fit-content;
position: relative;

&:hover {
background-color: var(--ax-bg-accent-moderate-hoverA);
Expand All @@ -42,12 +42,23 @@
&:focus-visible {
outline: 2px solid var(--ax-border-focus);
outline-offset: 2px;
z-index: 1;
}

&[aria-checked="true"] {
&[data-selected="true"] {
background-color: var(--ax-bg-accent-strong-pressed);
color: var(--ax-text-accent-contrast);
}

&:not([data-selected="true"], :first-child, &[data-selected="true"] + &)::before {
content: "";
display: block;
width: 1px;
height: 50%;
background-color: var(--ax-border-subtleA);
left: -1px;
position: absolute;
}
}

.navds-toggle-group__button-inner {
Expand All @@ -70,7 +81,7 @@
background-color: var(--ax-bg-neutral-moderate-hoverA);
}

&[aria-checked="true"] {
&[data-selected="true"] {
background-color: var(--ax-bg-neutral-strong-pressed);
color: var(--ax-text-neutral-contrast);
}
Expand All @@ -80,7 +91,7 @@
.navds-toggle-group--small {
& .navds-toggle-group__button {
padding: var(--ax-spacing-05) var(--ax-spacing-3);
min-height: 1.5rem;
min-height: 2rem;
}

& .navds-toggle-group__button-inner > svg {
Expand All @@ -94,14 +105,13 @@
border: 2px solid transparent;
}

.navds-toggle-group__button[aria-checked="true"]:hover,
.navds-toggle-group__button:hover {
background-color: highlighttext;
color: highlight;
outline: 1px solid highlight;
}

.navds-toggle-group__button[aria-checked="true"] {
.navds-toggle-group__button[data-selected="true"] {
background-color: selecteditem;
color: selecteditemtext;
forced-color-adjust: none;
Expand Down
6 changes: 6 additions & 0 deletions @navikt/core/react/src/toggle-group/ToggleGroup.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
EnvelopeClosedIcon,
EnvelopeOpenIcon,
InboxUpIcon,
SparklesIcon,
} from "@navikt/aksel-icons";
import { VStack } from "../layout/stack";
import ToggleGroup from "./ToggleGroup";
Expand Down Expand Up @@ -44,6 +45,11 @@ const Items = (icon?: boolean, both?: boolean) => {
icon={(both ?? icon) && <EnvelopeClosedIcon {...iconProps} />}
label={hasLabel && "Uleste"}
/>
<ToggleGroup.Item
value="ny"
icon={(both ?? icon) && <SparklesIcon {...iconProps} />}
label={hasLabel && "Ny"}
/>
<ToggleGroup.Item
value="lest"
icon={(both ?? icon) && <EnvelopeOpenIcon {...iconProps} />}
Expand Down
1 change: 1 addition & 0 deletions @navikt/core/react/src/toggle-group/parts/ToggleItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const ToggleItem = forwardRef<HTMLButtonElement, ToggleGroupItemProps>(
type="button"
role="radio"
aria-checked={itemCtx.isSelected}
data-selected={itemCtx.isSelected}
tabIndex={itemCtx.isFocused ? 0 : -1}
onClick={itemCtx.onClick}
onFocus={itemCtx.onFocus}
Expand Down
Loading