Compare commits

...
Author SHA1 Message Date
github-actions[bot]andgithub-actions[bot] 4bf6027518 Version Packages (#2147)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-09 15:34:18 +02:00
Halvor Haugan c8e203c523 ✏️ Fiks skrivefeil i suggestionblock (#2146) 2023-08-09 15:15:41 +02:00
267799ca0e update links (#2093)
* style links with inline

* tweak css spacing for inline links with SVG

* add break-all prop to link

* wrap link in span to allow for spacing

* more obvious spacing example

* remove spacing prop from link

* implement pr review comments

* add random icon visual fuzz testing in stories

* remove console.log

* changeset

* add examples to aksel.nav.no

* 🎨 make inline-flex version opt-in, improve prop naming

* 🐛 Fixed comments

* 🎨 Oppdatert props

* 🎨 refactor links, add examples (remove underline & inline)

* change is no longer major (pr review comment)

Co-authored-by: Ken <26967723+KenAJoh@users.noreply.github.com>

* cleaner changeset (pr review comment)

Co-authored-by: Ken <26967723+KenAJoh@users.noreply.github.com>

* norwegian changeset (pr review comment)

Co-authored-by: Ken <26967723+KenAJoh@users.noreply.github.com>

* update changeset (pr review comment)

Co-authored-by: Ken <26967723+KenAJoh@users.noreply.github.com>

* use neutral token for neutral link variant

Co-authored-by: Ken <26967723+KenAJoh@users.noreply.github.com>

* use neutral token for neutral link variant

Co-authored-by: Ken <26967723+KenAJoh@users.noreply.github.com>

* Update .changeset/proud-tigers-share.md

---------

Co-authored-by: Ken <26967723+KenAJoh@users.noreply.github.com>
Co-authored-by: Ken <ken.aleksander@gmail.com>
2023-08-09 15:00:44 +02:00
github-actions[bot]andgithub-actions[bot] 42934af3a1 Version Packages (#2145)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-09 14:38:31 +02:00
Vegard Haugstvedt eff8a902c5 Bugfix/combobox bugfixes and tweaks (#2144)
* Clear input field when clicking option in multiselect combobox

Makes the behaviour consistent when clicking with a mouse and when selecting an option with keyboard.

* MultiSelect with "add new" example should actually have the addnewValues prop set...

* Expose through onToggleSelected whether selected values in combobox are added by the user or not.

* Add the additional affordance of bold font-weight for selected options in combobox.

Done to account for screen magnifiers on screens that don't show the background color, where the checkmark is out-of-sight.

* Avoid "jumping" when selecting option in multiselect, stemming from the chips being slightly larger than the padding allowed for (equal to the width of the border)

* Added changeset and updated yarn.lock

* Do not use focus-visible inside fallback for when focus-visible is not supported

* Add fallback focus-styling using JS and a helper class for browsers not supporting :has (Firefox)

* Fix for onBlur in ComboboxWrapper. Without tabindex="-1" event.relatedTarget in onBlur will be null, and we can't check that focus has entirely moved outside the Combobox.
2023-08-09 14:15:26 +02:00
Ken d34a8f45ef 🐛 aria-live fix for button (#2143) 2023-08-09 11:01:45 +02:00
github-actions[bot]andgithub-actions[bot] d1ceb40439 Version Packages (#2141)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-07 13:58:17 +02:00
e033b34c3b Table component: adding click event on expandable table rows (#2127)
Co-authored-by: Vegard Haugstvedt <it.vegard@gmail.com>
Co-authored-by: Ken <26967723+KenAJoh@users.noreply.github.com>
2023-08-07 13:42:07 +02:00
Halvor Haugan de3991d0f0 📝 Fiks skrivefeil i Select-eksempler (#2140) 2023-08-04 18:30:41 +02:00
47 changed files with 645 additions and 100 deletions

No files matched your search

+6
View File
@@ -1,5 +1,11 @@
# @navikt/aksel-icons
## 4.10.0
## 4.9.1
## 4.9.0
## 4.8.0
## 4.7.4
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/aksel-icons",
"version": "4.8.0",
"version": "4.10.0",
"author": "Aksel | NAV",
"homepage": "https://aksel.nav.no/ikoner",
"repository": {
+6
View File
@@ -1,5 +1,11 @@
# @navikt/aksel-stylelint
## 4.10.0
## 4.9.1
## 4.9.0
## 4.8.0
## 4.7.4
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/aksel-stylelint",
"version": "4.8.0",
"version": "4.10.0",
"author": "Aksel | NAV",
"homepage": "https://aksel.nav.no/grunnleggende/kode/stylelint",
"repository": {
@@ -35,8 +35,8 @@
"dev": "yarn watch:lint"
},
"devDependencies": {
"@navikt/ds-css": "^4.8.0",
"@navikt/ds-tokens": "^4.8.0",
"@navikt/ds-css": "^4.10.0",
"@navikt/ds-tokens": "^4.10.0",
"@types/jest": "^29.0.0",
"concurrently": "7.2.1",
"copyfiles": "2.4.1",
+21
View File
@@ -1,5 +1,26 @@
# @navikt/aksel
## 4.10.0
### Patch Changes
- Updated dependencies [[`267799ca0`](https://github.com/navikt/aksel/commit/267799ca0ecc0c549e159f94124befb654e29331)]:
- @navikt/ds-css@4.10.0
## 4.9.1
### Patch Changes
- Updated dependencies [[`eff8a902c`](https://github.com/navikt/aksel/commit/eff8a902c50fd5ebc56616e866aa0a61b9eb5efc)]:
- @navikt/ds-css@4.9.1
## 4.9.0
### Patch Changes
- Updated dependencies [[`e033b34c3`](https://github.com/navikt/aksel/commit/e033b34c3b85fb98dd11dd0300bb20075e1b06e8)]:
- @navikt/ds-css@4.9.0
## 4.8.0
### Patch Changes
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/aksel",
"version": "4.8.0",
"version": "4.10.0",
"description": "Aksel command line interface. Handles css-imports, codemods and more",
"author": "Aksel | NAV designsystem team",
"license": "MIT",
@@ -29,7 +29,7 @@
},
"homepage": "https://aksel.nav.no/grunnleggende/kode/kommandolinje",
"dependencies": {
"@navikt/ds-css": "4.8.0",
"@navikt/ds-css": "4.10.0",
"axios": "1.3.6",
"chalk": "4.1.0",
"clipboardy": "^2.3.0",
+18
View File
@@ -1,5 +1,23 @@
# @navikt/ds-css
## 4.10.0
### Minor Changes
- Link: La til 'variant', 'underline' og 'inlineText'-prop ([#2093](https://github.com/navikt/aksel/pull/2093))
## 4.9.1
### Patch Changes
- Tweaks to combobox - updated example, small bugfixes, better affordance for selected options and added flag for "isAddedByUser" to onToggleSelected ([#2144](https://github.com/navikt/aksel/pull/2144))
## 4.9.0
### Minor Changes
- Table: ExpandableRow kan nå åpnes med 'expandOnRowClick'-prop ([#2127](https://github.com/navikt/aksel/pull/2127))
## 4.8.0
### Minor Changes
+20 -2
View File
@@ -9,9 +9,10 @@
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
width: 100%;
border: 1px solid var(--a-border-default);
padding: calc(var(--a-spacing-2) - 2px) var(--a-spacing-2);
}
.navds-combobox__wrapper-inner > :first-child {
@@ -33,6 +34,7 @@
.navds-combobox__selected-options {
gap: var(--a-spacing-2);
align-items: center;
}
.navds-combobox__selected-options > li {
@@ -67,6 +69,7 @@
margin: 0;
min-width: 10ch;
width: 100%;
height: 2rem;
}
.navds-combobox__input:focus-visible {
@@ -85,7 +88,7 @@
}
@supports not selector(:focus-visible) {
.navds-combobox__input:focus-visible {
.navds-combobox__input:focus {
outline: none;
border: none;
box-shadow: none;
@@ -101,6 +104,17 @@
}
}
@supports not selector(:has) {
.navds-combobox--focused .navds-combobox__wrapper-inner {
box-shadow: 0 0 0 1px var(--a-surface-default) inset, var(--a-shadow-focus);
box-shadow: var(--a-shadow-focus);
}
.navds-combobox--focused .navds-combobox__wrapper-inner.navds-combobox__wrapper-inner--virtually-unfocused {
box-shadow: none;
}
}
.navds-combobox__button-clear {
border-radius: var(--a-border-radius-medium);
color: var(--ac-combobox-clear-icon, var(--a-text-subtle));
@@ -243,6 +257,10 @@
background-color: var(--ac-combobox-list-item-selected-bg, var(--a-surface-selected));
}
.navds-combobox__list-item--selected p {
font-weight: var(--a-font-weight-bold);
}
.navds-combobox__list-item--selected.navds-combobox__list-item--focus,
.navds-combobox__list-item--selected:hover {
background-color: var(--ac-combobox-list-item-selected-hover-bg, var(--a-surface-action-subtle-hover));
+36 -3
View File
@@ -6,15 +6,36 @@
gap: var(--a-spacing-1);
}
.navds-alert .navds-link,
.navds-confirmation-panel .navds-link {
color: var(--a-text-default);
.navds-link.navds-link--inline-text {
display: inline;
}
.navds-link.navds-link--inline-text > svg {
margin: 0.1em 0.1em -0.1em;
transform: translateY(0.05em);
}
.navds-link:visited {
color: var(--ac-link-visited-text, var(--a-text-visited));
}
.navds-link:hover {
text-decoration: none;
}
.navds-link.navds-link--remove-underline {
text-decoration: none;
}
.navds-link.navds-link--remove-underline:hover {
text-decoration: underline;
}
.navds-alert .navds-link,
.navds-confirmation-panel .navds-link {
color: var(--a-text-default);
}
.navds-link:focus-visible {
outline: none;
color: var(--ac-link-focus-text, var(--a-text-on-action));
@@ -45,3 +66,15 @@
color: inherit;
flex-shrink: 0;
}
.navds-link--action {
color: var(--ac-link-action-text, var(--a-text-action));
}
.navds-link--neutral {
color: var(--ac-link-neutral-text, var(--a-text-default));
}
.navds-link--subtle {
color: var(--ac-link-subtle-text, var(--a-text-subtle));
}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/ds-css",
"version": "4.8.0",
"version": "4.10.0",
"description": "CSS for NAV Designsystem",
"author": "Aksel | NAV designsystem team",
"keywords": [
@@ -27,7 +27,7 @@
"css:get-version": "node config/get-version.js"
},
"devDependencies": {
"@navikt/ds-tokens": "^4.8.0",
"@navikt/ds-tokens": "^4.10.0",
"cssnano": "6.0.0",
"fast-glob": "3.2.11",
"lodash": "4.17.21",
+5 -1
View File
@@ -16,7 +16,7 @@
display: table-row;
}
.navds-table__body .navds-table__row--shade-on-hover:hover {
.navds-table__body .navds-table__row--shade-on-hover:not(.navds-table__expandable-row--expansion-disabled):hover {
background-color: var(--ac-table-row-hover, var(--a-bg-subtle));
}
@@ -154,6 +154,10 @@
transition: border-bottom-color 190ms cubic-bezier(0.6, 0.04, 0.98, 0.335);
}
.navds-table__expandable-row:not(.navds-table__expandable-row--expansion-disabled):hover {
cursor: pointer;
}
.navds-table__expandable-row--open .navds-table__data-cell {
border-bottom-color: transparent;
}
+5 -1
View File
@@ -175,7 +175,11 @@
"--ac-link-focus-border": "--a-border-focus",
"--ac-link-active-text": "--a-text-on-action",
"--ac-link-active-bg": "--a-border-focus",
"--ac-link-active-border": "--a-border-focus"
"--ac-link-active-border": "--a-border-focus",
"--ac-link-action-text": "--a-text-action",
"--ac-link-neutral-text": "--a-text-default",
"--ac-link-subtle-text": "--a-text-subtle",
"--ac-link-visited-text": "--a-text-visited"
},
"list": {
"--ac-list-marker-ul-color": "--ac-list-marker-color",
+33
View File
@@ -1,5 +1,38 @@
# @navikt/ds-react
## 4.10.0
### Minor Changes
- Link: La til 'variant', 'underline' og 'inlineText'-prop ([#2093](https://github.com/navikt/aksel/pull/2093))
### Patch Changes
- Updated dependencies []:
- @navikt/aksel-icons@4.10.0
## 4.9.1
### Patch Changes
- Button: Fikset aria-live bug der knapp alltid ble lest opp av skjermleser ved render ([#2143](https://github.com/navikt/aksel/pull/2143))
- Tweaks to combobox - updated example, small bugfixes, better affordance for selected options and added flag for "isAddedByUser" to onToggleSelected ([#2144](https://github.com/navikt/aksel/pull/2144))
- Updated dependencies []:
- @navikt/aksel-icons@4.9.1
## 4.9.0
### Minor Changes
- Table: ExpandableRow kan nå åpnes med 'expandOnRowClick'-prop ([#2127](https://github.com/navikt/aksel/pull/2127))
### Patch Changes
- Updated dependencies []:
- @navikt/aksel-icons@4.9.0
## 4.8.0
### Minor Changes
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/ds-react",
"version": "4.8.0",
"version": "4.10.0",
"description": "Aksel react-components for NAV designsystem",
"author": "Aksel | NAV designsystem team",
"license": "MIT",
@@ -38,7 +38,7 @@
},
"dependencies": {
"@floating-ui/react": "0.24.1",
"@navikt/aksel-icons": "^4.8.0",
"@navikt/aksel-icons": "^4.10.0",
"@radix-ui/react-tabs": "1.0.0",
"@radix-ui/react-toggle-group": "1.0.0",
"clsx": "^1.2.1",
+1 -5
View File
@@ -126,11 +126,7 @@ export const Button: OverridableComponent<ButtonProps, HTMLButtonElement> =
<span className="navds-button__icon">{icon}</span>
)}
{children && (
<Label
as="span"
size={size === "medium" ? "medium" : "small"}
aria-live="polite"
>
<Label as="span" size={size === "medium" ? "medium" : "small"}>
{children}
</Label>
)}
@@ -148,8 +148,9 @@ export const Loading = {
</div>
),
args: { chromatic: { disableSnapshot: true } },
chromatic: { disableSnapshot: true },
parameters: {
chromatic: { disableSnapshot: true },
},
};
export const Icon = () => (
@@ -275,6 +276,7 @@ export const LoadingWithAs = {
</div>
),
args: { chromatic: { disableSnapshot: true } },
chromatic: { disableSnapshot: true },
parameters: {
chromatic: { disableSnapshot: true },
},
};
@@ -1,5 +1,5 @@
import cl from "clsx";
import React, { useRef } from "react";
import React, { useRef, useState } from "react";
type ComboboxWrapperProps = {
children: any;
@@ -23,6 +23,7 @@ const ComboboxWrapper = ({
toggleListButtonRef,
}: ComboboxWrapperProps) => {
const wrapperRef = useRef<HTMLDivElement | null>(null);
const [hasFocusWithin, setHasFocusWithin] = useState(false);
function onFocusInsideWrapper(e) {
if (
@@ -30,12 +31,14 @@ const ComboboxWrapper = ({
toggleListButtonRef?.current !== e.target
) {
toggleIsListOpen(true);
setHasFocusWithin(true);
}
}
function onBlurWrapper(e) {
if (!wrapperRef.current?.contains(e.relatedTarget)) {
toggleIsListOpen(false);
setHasFocusWithin(false);
}
}
@@ -50,10 +53,12 @@ const ComboboxWrapper = ({
{
"navds-search--error": hasError,
"navds-search--disabled": !!inputProps.disabled,
"navds-combobox--focused": hasFocusWithin,
}
)}
onFocus={onFocusInsideWrapper}
onBlur={onBlurWrapper}
tabIndex={-1}
>
{children}
</div>
@@ -8,6 +8,7 @@ import { useInputContext } from "../Input/inputContext";
const FilteredOptions = () => {
const {
clearInput,
inputProps: { id },
size,
value,
@@ -48,7 +49,10 @@ const FilteredOptions = () => {
{isValueNew && allowNewValues && (
<li
tabIndex={-1}
onPointerUp={(event) => toggleOption(value, event)}
onPointerUp={(event) => {
toggleOption(value, event);
clearInput(event);
}}
id={`${id}-combobox-new-option`}
className={cl("navds-combobox__list-item__new-option", {
"navds-combobox__list-item__new-option--focus":
@@ -88,6 +92,7 @@ const FilteredOptions = () => {
tabIndex={-1}
onPointerUp={(event) => {
toggleOption(option, event);
clearInput(event);
if (!isMultiSelect) {
toggleIsListOpen(false);
}
@@ -60,11 +60,10 @@ export const SelectedOptionsProvider = ({
const addSelectedOption = useCallback(
(option: string) => {
if (
!options
.map((opt) => opt.toLowerCase())
.includes(option?.toLowerCase?.())
) {
const isAddedByUser = !options
.map((opt) => opt.toLowerCase())
.includes(option?.toLowerCase?.());
if (isAddedByUser) {
allowNewValues && addCustomOption(option);
} else if (isMultiSelect) {
setSelectedOptions((prevSelectedOptions) => [
@@ -74,14 +73,15 @@ export const SelectedOptionsProvider = ({
} else {
setSelectedOptions([option]);
}
onToggleSelected?.(option, true);
onToggleSelected?.(option, true, isAddedByUser);
},
[addCustomOption, allowNewValues, isMultiSelect, onToggleSelected, options]
);
const removeSelectedOption = useCallback(
(option: string) => {
if (customOptions.includes(option)) {
const isAddedByUser = customOptions.includes(option);
if (isAddedByUser) {
removeCustomOption(option);
} else {
setSelectedOptions((prevSelectedOptions) =>
@@ -90,7 +90,7 @@ export const SelectedOptionsProvider = ({
)
);
}
onToggleSelected?.(option, false);
onToggleSelected?.(option, false, isAddedByUser);
},
[customOptions, onToggleSelected, removeCustomOption]
);
@@ -82,6 +82,7 @@ export function MultiSelect(props) {
label="Komboboks - velg flere"
options={props.options}
isMultiSelect={props.isMultiSelect}
size={props.size}
/>
</DemoContainer>
);
@@ -90,6 +91,7 @@ export function MultiSelect(props) {
MultiSelect.args = {
options,
isMultiSelect: true,
size: "medium",
};
export function MultiSelectWithAddNewOptions(props) {
@@ -78,10 +78,15 @@ export interface ComboboxProps
* Callback function triggered whenever an option is selected or de-selected
*
* @param option
* @param isSelected
* @param isSelected - Whether the option has been selected or unselected
* @param isAddedByUser - Whether the option comes from user input, instead of from the list
* @returns
*/
onToggleSelected?: (option: string, isSelected: boolean) => void;
onToggleSelected?: (
option: string,
isSelected: boolean,
isAddedByUser: boolean
) => void;
/**
* List of selected options.
*
+47 -3
View File
@@ -4,6 +4,23 @@ import { OverridableComponent } from "../util/OverridableComponent";
export interface LinkProps
extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
/**
* Inverts when the underline appears. If this is false,
* the underline does not appear by default, but does appear when the link is hovered.
* This makes it more suitable for use when inlined in text.
* @default true
*/
underline?: boolean;
/**
* Renders link with `display: inline` for better wrapping in text.
* @default false
*/
inlineText?: boolean;
/**
* Variant of the component to use.
* @default "action"
*/
variant?: "action" | "neutral" | "subtle";
/**
* Link text
*/
@@ -22,10 +39,37 @@ export interface LinkProps
* <Link href="#">lenke til ny side</Link>
* <Link as={ReactRouter.Link} to="#">lenke til ny side</Link>
* ```
* @example
* ```jsx
* <BodyLong>
* ...
* <Link href="#" inlineText>lenke til ny side</Link>
* ...
* </BodyLong>
* ```
*/
export const Link: OverridableComponent<LinkProps, HTMLAnchorElement> =
forwardRef(({ as: Component = "a", className, ...rest }, ref) => (
<Component {...rest} ref={ref} className={cl("navds-link", className)} />
));
forwardRef(
(
{
as: Component = "a",
className,
underline = true,
variant = "action",
inlineText = false,
...rest
},
ref
) => (
<Component
{...rest}
ref={ref}
className={cl("navds-link", className, `navds-link--${variant}`, {
"navds-link--remove-underline": !underline,
"navds-link--inline-text": inlineText,
})}
/>
)
);
export default Link;
+127 -13
View File
@@ -6,29 +6,76 @@ import {
ConfirmationPanel as DsConfirmationPanel,
Link,
} from "..";
import { RandomIcon } from "../util/RandomIcon";
export default {
title: "ds-react/Link",
component: Link,
};
const LinkWrapper = ({
children = "Ex aliqua incididunt",
iconRight = false,
iconLeft = false,
variant = "action",
underline = false,
inlineText = true,
}) => (
<>
{" "}
<Link
href="#"
underline={underline}
variant={variant as "action" | "neutral" | "subtle"}
inlineText={inlineText}
>
{iconLeft && (
<>
<RandomIcon />{" "}
</>
)}
{children}
{iconRight && (
<>
{" "}
<RandomIcon />
</>
)}
</Link>{" "}
</>
);
export const Default = {
render: (props) => {
render: ({ icon, inline }) => {
const LinkD = () => (
<Link href="#">
{props.icon && <PlusCircleFillIcon />}Ex aliqua incididunt{" "}
{props.icon && <PlusCircleFillIcon />}
</Link>
<>
{" "}
<Link href="#" underline={!inline} inlineText={inline}>
{icon && <PlusCircleFillIcon />}Ex aliqua incididunt
{icon && <PlusCircleFillIcon />}
</Link>{" "}
</>
);
if (props.inline) {
if (inline) {
return (
<BodyLong>
Incididunt laborum nisi nisi Lorem <LinkD /> in. Laborum aute fugiat
officia adipisicing non veniam dolor nulla non ex consectetur fugiat
eiusmod aute. Culpa sit aute est duis minim in in voluptate velit
fugiat. Laboris est id deserunt ut ea Lorem eu. Esse elit laboris aute
commodo sint laborum fugiat aliqua.
</BodyLong>
<div
className="colgap"
style={{
width: "800px",
border: "1px solid black",
borderRadius: "8px",
}}
>
<BodyLong>
Incididunt laborum nisi nisi Lorem
<LinkD />
in. Laborum aute fugiat officia adipisicing non veniam dolor nulla
non ex consectetur fugiat eiusmod aute. Culpa sit aute est duis
minim in in voluptate velit fugiat. Laboris est id deserunt ut ea
Lorem eu. Esse elit laboris aute commodo sint laborum fugiat aliqua.
</BodyLong>
</div>
);
}
return <LinkD />;
@@ -40,6 +87,49 @@ export const Default = {
},
};
export const InlineInsideBodyLong = {
render: ({ iconLeft, iconRight }) => {
return (
<div
className="colgap"
style={{
width: "800px",
border: "1px solid black",
borderRadius: "8px",
}}
>
<style>{`.storybook-custom-spacing { white-space: pre;}`}</style>
<BodyLong>
<LinkWrapper underline iconLeft={iconLeft} iconRight={iconRight} />
Eiusmod aute.
<LinkWrapper underline iconLeft={iconLeft} iconRight={iconRight} />
Culpa sit aute est duis minim in in voluptate velit Incididunt laborum
nisi nisi Lorem officia adipisicing non veniam
<LinkWrapper underline iconLeft={iconLeft} iconRight={iconRight}>
blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah
</LinkWrapper>
dolor eu. Esse elit laboris aute commodo sint laborum fugiat aliqua.
<LinkWrapper underline iconLeft={iconLeft} iconRight={iconRight}>
Link
</LinkWrapper>
</BodyLong>
<BodyLong className="storybook-custom-spacing">
Custom{" "}
<LinkWrapper underline iconLeft={iconLeft} iconRight={iconRight}>
link
</LinkWrapper>
{" "}spacing.
</BodyLong>
</div>
);
},
args: {
iconLeft: false,
iconRight: false,
},
};
const DemoLink = () => (
<Link href="#">
<PlusCircleFillIcon aria-hidden /> Ex aliqua incididunt{" "}
@@ -83,3 +173,27 @@ export const ConfirmationPanel = () => {
</div>
);
};
export const Variants = {
render: ({ iconLeft, iconRight }) => {
return (
<div className="colgap">
{["action", "neutral", "subtle"].map((variant) => (
<>
<div>
<LinkWrapper
iconLeft={iconLeft}
iconRight={iconRight}
variant={variant}
/>
</div>
</>
))}
</div>
);
},
args: {
iconLeft: false,
iconRight: false,
},
};
+28 -8
View File
@@ -31,10 +31,15 @@ export interface ExpandableRowProps extends Omit<RowProps, "content"> {
*/
onOpenChange?: (open: boolean) => void;
/**
* Disable expansio
* Disable expansion. shadeOnHover will not be visible.
* @default false
*/
expansionDisabled?: boolean;
/**
* Makes the whole row clickable
* @default false
*/
expandOnRowClick?: boolean;
/**
* The width of the expanded row's internal cell
* @default 999
@@ -58,6 +63,7 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
open,
onOpenChange,
expansionDisabled = false,
expandOnRowClick = false,
colSpan = 999,
...rest
},
@@ -65,9 +71,22 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
) => {
const [internalOpen, setInternalOpen] = useState<boolean>(defaultOpen);
const id = useId();
const isOpen = open ?? internalOpen;
const expansionHandler = (e) => {
onOpenChange?.(!isOpen);
if (open === undefined) {
setInternalOpen((open) => !open);
}
e.stopPropagation();
};
const onRowClick = (e) => {
if (e.target.nodeName === "TD" || e.target.nodeName === "TH") {
expansionHandler(e);
}
};
return (
<>
<Row
@@ -75,7 +94,13 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
ref={ref}
className={cl("navds-table__expandable-row", className, {
"navds-table__expandable-row--open": isOpen,
"navds-table__expandable-row--expansion-disabled":
expansionDisabled,
})}
onClick={(e) => {
!expansionDisabled && expandOnRowClick && onRowClick(e);
rest?.onClick?.(e);
}}
>
{togglePlacement === "right" && children}
<DataCell
@@ -89,12 +114,7 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
className="navds-table__toggle-expand-button"
aria-controls={id}
aria-expanded={isOpen}
onClick={() => {
onOpenChange?.(!isOpen);
if (open === undefined) {
setInternalOpen((open) => !open);
}
}}
onClick={expansionHandler}
>
<ChevronDownIcon
className="navds-table__expandable-icon"
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import { Table } from "..";
import { Link } from "../..";
import { Button, Checkbox, Link } from "../..";
export default {
title: "ds-react/Table",
@@ -37,6 +37,7 @@ export const Expandable = () => {
};
export const ExpandableSmall = () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const [open, setOpen] = useState(false);
return (
<Table size="small">
@@ -227,3 +228,63 @@ export const ExpandableOpen = () => {
</Table>
);
};
export const ClickableRow = {
render: () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const [isRowOpen1, setIsRowOpen1] = useState(false);
// eslint-disable-next-line react-hooks/rules-of-hooks
const [isRowOpen2, setIsRowOpen2] = useState(false);
return (
<>
<Table zebraStripes>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Navn</Table.HeaderCell>
<Table.HeaderCell>Info</Table.HeaderCell>
<Table.HeaderCell aria-hidden />
</Table.Row>
</Table.Header>
<Table.Body>
<Table.ExpandableRow
content={<div>placeholder row 1</div>}
togglePlacement="right"
onOpenChange={setIsRowOpen1}
data-testid="row1"
open={isRowOpen1}
expandOnRowClick
>
<Table.DataCell>Ola</Table.DataCell>
<Table.DataCell>
<Button
size="xsmall"
onClick={(e) => {
alert("Mer info");
}}
>
Mer info
</Button>
</Table.DataCell>
</Table.ExpandableRow>
<Table.ExpandableRow
content={<div>placeholder row 2</div>}
togglePlacement="right"
onOpenChange={setIsRowOpen2}
data-testid="row2"
open={isRowOpen2}
expandOnRowClick
>
<Table.DataCell>Hans</Table.DataCell>
<Table.DataCell>
<Checkbox hideLabel size="small">
Sett
</Checkbox>
</Table.DataCell>
</Table.ExpandableRow>
</Table.Body>
</Table>
</>
);
},
};
@@ -0,0 +1,9 @@
import * as AllIcons from "@navikt/aksel-icons";
import React from "react";
const icons = Object.keys(AllIcons).map((key) => AllIcons[key]);
export const RandomIcon = () => {
const Icon = icons[Math.floor(Math.random() * icons.length)];
return <Icon />;
};
+6
View File
@@ -1,5 +1,11 @@
# @navikt/ds-tailwind
## 4.10.0
## 4.9.1
## 4.9.0
## 4.8.0
## 4.7.4
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/ds-tailwind",
"version": "4.8.0",
"version": "4.10.0",
"description": "Tailwind config based on @navikt/ds-tokens",
"author": "Aksel | NAV designsystem team",
"keywords": [
@@ -22,7 +22,7 @@
"directory": "@navikt/core/tailwind"
},
"devDependencies": {
"@navikt/ds-tokens": "^4.8.0",
"@navikt/ds-tokens": "^4.10.0",
"@types/jest": "^29.0.0",
"color": "4.2.3",
"jest": "^29.0.0",
+6
View File
@@ -1,5 +1,11 @@
# @navikt/ds-tokens
## 4.10.0
## 4.9.1
## 4.9.0
## 4.8.0
## 4.7.4
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/ds-tokens",
"version": "4.8.0",
"version": "4.10.0",
"description": "Design-tokens for NAV designsystem",
"author": "Aksel | NAV designsystem team",
"keywords": [
+32
View File
@@ -1,5 +1,37 @@
# Changelog
## 4.10.0
### @navikt/ds-css
- Link: La til 'variant', 'underline' og 'inlineText'-prop ([#2093](https://github.com/navikt/aksel/pull/2093))
### @navikt/ds-react
- Link: La til 'variant', 'underline' og 'inlineText'-prop ([#2093](https://github.com/navikt/aksel/pull/2093))
## 4.9.1
### @navikt/ds-css
- Tweaks to combobox - updated example, small bugfixes, better affordance for selected options and added flag for "isAddedByUser" to onToggleSelected ([#2144](https://github.com/navikt/aksel/pull/2144))
### @navikt/ds-react
- Button: Fikset aria-live bug der knapp alltid ble lest opp av skjermleser ved render ([#2143](https://github.com/navikt/aksel/pull/2143))
- Tweaks to combobox - updated example, small bugfixes, better affordance for selected options and added flag for "isAddedByUser" to onToggleSelected ([#2144](https://github.com/navikt/aksel/pull/2144))
## 4.9.0
### @navikt/ds-css
- Table: ExpandableRow kan nå åpnes med 'expandOnRowClick'-prop ([#2127](https://github.com/navikt/aksel/pull/2127))
### @navikt/ds-react
- Table: ExpandableRow kan nå åpnes med 'expandOnRowClick'-prop ([#2127](https://github.com/navikt/aksel/pull/2127))
## 4.8.0
### @navikt/ds-css
+5 -5
View File
@@ -15,11 +15,11 @@
"website"
],
"dependencies": {
"@navikt/aksel-icons": "^4.8.0",
"@navikt/ds-css": "^4.8.0",
"@navikt/ds-react": "^4.8.0",
"@navikt/ds-tailwind": "^4.8.0",
"@navikt/ds-tokens": "^4.8.0"
"@navikt/aksel-icons": "^4.10.0",
"@navikt/ds-css": "^4.10.0",
"@navikt/ds-react": "^4.10.0",
"@navikt/ds-tailwind": "^4.10.0",
"@navikt/ds-tokens": "^4.10.0"
},
"devDependencies": {
"prettier-plugin-tailwindcss": "^0.2.3"
@@ -186,7 +186,7 @@ const options: {
icon: <ChangeLogIconOutline />,
},
"komponent-beta": {
text: "Komponenten er under utvikling, men klar for adopsjon. Vi er ønsker gjerne innspill på hvordan den fungerer og hvilken forbedringer vi kan gjøre.",
text: "Komponenten er under utvikling, men klar for adopsjon. Vi ønsker gjerne innspill på hvordan den fungerer og hvilken forbedringer vi kan gjøre.",
link: `${issueUrl}&labels=forespørsel+🥰%2Ckomponenter+🧩%2Cbeta+🧪&template=update-component.yml&title=%5BInnspill+til+komponent%5D%3A+`,
heading: "Beta",
icon: (
@@ -23,6 +23,8 @@ const initialSelectedOptions = ["Norge"];
export const Example = () => {
const [value, setValue] = useState("");
const mockPersistUserAddedValues = (value, isSelected) => undefined;
const [selectedOptions, setSelectedOptions] = useState(
initialSelectedOptions
);
@@ -31,17 +33,25 @@ export const Example = () => {
[value]
);
const onToggleSelected = (option, isSelected) => {
const onToggleSelected = (
option: string,
isSelected: boolean,
isAddedByUser: boolean
) => {
if (isSelected) {
setSelectedOptions([...selectedOptions, option]);
} else {
setSelectedOptions(selectedOptions.filter((o) => o !== option));
}
if (isAddedByUser) {
mockPersistUserAddedValues(option, isSelected);
}
};
return (
<div>
<UNSAFE_Combobox
allowNewValues
label="Hvilke land har du besøkt de siste 6 ukene? Velg opptil flere."
filteredOptions={filteredOptions}
isMultiSelect
@@ -20,6 +20,7 @@ export const Example = () => {
return (
<div>
<UNSAFE_Combobox
allowNewValues
label="Hva er dine favorittdrikker? Legg gjerne til flere alternativer."
options={initialOptions}
isMultiSelect
@@ -0,0 +1,30 @@
import { PlusCircleFillIcon } from "@navikt/aksel-icons";
import { BodyLong, Link } from "@navikt/ds-react";
import { withDsExample } from "components/website-modules/examples/withDsExample";
const Example = () => {
return (
<BodyLong>
Officia incididunt Culpa sit aute est duis minim in in voluptate velit
Incididunt laborum nisi nisi Lorem officia adipisicing non veniam{" "}
<Link href="#" inlineText={true}>
lenke til ny side
<PlusCircleFillIcon aria-hidden />
</Link>{" "}
Culpa sit aute est duis minim in in voluptate velit Incididunt laborum
nisi nisi Lorem officia adipisicing non veniam occaecat commodo id ad
aliquip.
</BodyLong>
);
};
export default withDsExample(Example);
/* Storybook story */
export const Demo = {
render: Example,
};
export const args = {
index: 0,
};
@@ -0,0 +1,25 @@
import { BodyLong, Link } from "@navikt/ds-react";
import { withDsExample } from "components/website-modules/examples/withDsExample";
const Example = () => {
return (
<BodyLong>
Officia incididunt{" "}
<Link href="#" underline={false}>
lenke til ny side
</Link>{" "}
occaecat commodo id ad aliquip.
</BodyLong>
);
};
export default withDsExample(Example);
/* Storybook story */
export const Demo = {
render: Example,
};
export const args = {
index: 0,
};
@@ -0,0 +1,29 @@
import { Link } from "@navikt/ds-react";
import { withDsExample } from "components/website-modules/examples/withDsExample";
const Example = () => {
return (
<div className="colgap">
{["action", "neutral", "subtle"].map((variant) => (
<>
<div>
<Link variant={variant as "action" | "neutral" | "subtle"}>
Ex aliqua incididunt
</Link>
</div>
</>
))}
</div>
);
};
export default withDsExample(Example);
/* Storybook story */
export const Demo = {
render: Example,
};
export const args = {
index: 0,
};
@@ -3,7 +3,7 @@ import { withDsExample } from "components/website-modules/examples/withDsExample
const Example = () => {
return (
<Select label="Hvilket land har du bosted i.">
<Select label="Hvilket land har du bosted i?">
<option value="">Velg land</option>
<option value="norge">Norge</option>
<option value="sverige">Sverige</option>
@@ -4,7 +4,7 @@ import { withDsExample } from "components/website-modules/examples/withDsExample
const Example = () => {
return (
<Select
label="Hvilket land har du bosted i."
label="Hvilket land har du bosted i?"
description="Velg det landet du tilbringer mest tid."
>
<option value="">Velg land</option>
@@ -3,7 +3,7 @@ import { withDsExample } from "components/website-modules/examples/withDsExample
const Example = () => {
return (
<Select label="Hvilket land har du bosted i." disabled>
<Select label="Hvilket land har du bosted i?" disabled>
<option value="">Velg land</option>
<option value="norge">Norge</option>
<option value="sverige">Sverige</option>
@@ -4,7 +4,7 @@ import { withDsExample } from "components/website-modules/examples/withDsExample
const Example = () => {
return (
<Select
label="Hvilket land har du bosted i."
label="Hvilket land har du bosted i?"
error="Adressen matcher ikke landet du har satt som bosted."
>
<option value="">Velg land</option>
@@ -3,7 +3,7 @@ import { withDsExample } from "components/website-modules/examples/withDsExample
const Example = () => {
return (
<Select label="Hvilket land har du bosted i." hideLabel>
<Select label="Hvilket land har du bosted i?" hideLabel>
<option value="">Velg land</option>
<option value="norge">Norge</option>
<option value="sverige">Sverige</option>
@@ -3,7 +3,7 @@ import { withDsExample } from "components/website-modules/examples/withDsExample
const Example = () => {
return (
<Select label="Hvilket land har du bosted i." readOnly value="sverige">
<Select label="Hvilket land har du bosted i?" readOnly value="sverige">
<option value="">Velg land</option>
<option value="norge">Norge</option>
<option value="sverige">Sverige</option>
@@ -3,7 +3,7 @@ import { withDsExample } from "components/website-modules/examples/withDsExample
const Example = () => {
return (
<Select label="Hvilket land har du bosted i." size="small">
<Select label="Hvilket land har du bosted i?" size="small">
<option value="">Velg land</option>
<option value="norge">Norge</option>
<option value="sverige">Sverige</option>
+2 -2
View File
@@ -10,8 +10,8 @@
"preview": "vite preview"
},
"dependencies": {
"@navikt/ds-css": "4.8.0",
"@navikt/ds-react": "4.8.0",
"@navikt/ds-css": "4.10.0",
"@navikt/ds-react": "4.10.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
+18 -18
View File
@@ -3496,7 +3496,7 @@ __metadata:
languageName: node
linkType: hard
"@navikt/aksel-icons@^4.7.3, @navikt/aksel-icons@workspace:@navikt/aksel-icons":
"@navikt/aksel-icons@^4.9.0, @navikt/aksel-icons@workspace:@navikt/aksel-icons":
version: 0.0.0-use.local
resolution: "@navikt/aksel-icons@workspace:@navikt/aksel-icons"
dependencies:
@@ -3523,8 +3523,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "@navikt/aksel-stylelint@workspace:@navikt/aksel-stylelint"
dependencies:
"@navikt/ds-css": ^4.7.3
"@navikt/ds-tokens": ^4.7.3
"@navikt/ds-css": ^4.9.0
"@navikt/ds-tokens": ^4.9.0
"@types/jest": ^29.0.0
concurrently: 7.2.1
copyfiles: 2.4.1
@@ -3541,7 +3541,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@navikt/aksel@workspace:@navikt/aksel"
dependencies:
"@navikt/ds-css": 4.7.3
"@navikt/ds-css": 4.9.0
"@types/inquirer": ^9.0.3
"@types/jest": ^29.0.0
axios: 1.3.6
@@ -3565,11 +3565,11 @@ __metadata:
languageName: unknown
linkType: soft
"@navikt/ds-css@*, @navikt/ds-css@4.7.3, @navikt/ds-css@^4.7.3, @navikt/ds-css@workspace:@navikt/core/css":
"@navikt/ds-css@*, @navikt/ds-css@4.9.0, @navikt/ds-css@^4.9.0, @navikt/ds-css@workspace:@navikt/core/css":
version: 0.0.0-use.local
resolution: "@navikt/ds-css@workspace:@navikt/core/css"
dependencies:
"@navikt/ds-tokens": ^4.7.3
"@navikt/ds-tokens": ^4.9.0
cssnano: 6.0.0
fast-glob: 3.2.11
lodash: 4.17.21
@@ -3582,12 +3582,12 @@ __metadata:
languageName: unknown
linkType: soft
"@navikt/ds-react@*, @navikt/ds-react@4.7.3, @navikt/ds-react@^4.7.3, @navikt/ds-react@workspace:@navikt/core/react":
"@navikt/ds-react@*, @navikt/ds-react@4.9.0, @navikt/ds-react@^4.9.0, @navikt/ds-react@workspace:@navikt/core/react":
version: 0.0.0-use.local
resolution: "@navikt/ds-react@workspace:@navikt/core/react"
dependencies:
"@floating-ui/react": 0.24.1
"@navikt/aksel-icons": ^4.7.3
"@navikt/aksel-icons": ^4.9.0
"@radix-ui/react-tabs": 1.0.0
"@radix-ui/react-toggle-group": 1.0.0
"@testing-library/dom": 8.13.0
@@ -3623,11 +3623,11 @@ __metadata:
languageName: unknown
linkType: soft
"@navikt/ds-tailwind@^4.7.3, @navikt/ds-tailwind@workspace:@navikt/core/tailwind":
"@navikt/ds-tailwind@^4.9.0, @navikt/ds-tailwind@workspace:@navikt/core/tailwind":
version: 0.0.0-use.local
resolution: "@navikt/ds-tailwind@workspace:@navikt/core/tailwind"
dependencies:
"@navikt/ds-tokens": ^4.7.3
"@navikt/ds-tokens": ^4.9.0
"@types/jest": ^29.0.0
color: 4.2.3
jest: ^29.0.0
@@ -3638,7 +3638,7 @@ __metadata:
languageName: unknown
linkType: soft
"@navikt/ds-tokens@^4.7.3, @navikt/ds-tokens@workspace:@navikt/core/tokens":
"@navikt/ds-tokens@^4.9.0, @navikt/ds-tokens@workspace:@navikt/core/tokens":
version: 0.0.0-use.local
resolution: "@navikt/ds-tokens@workspace:@navikt/core/tokens"
dependencies:
@@ -7969,11 +7969,11 @@ __metadata:
version: 0.0.0-use.local
resolution: "aksel.nav.no@workspace:aksel.nav.no"
dependencies:
"@navikt/aksel-icons": ^4.7.3
"@navikt/ds-css": ^4.7.3
"@navikt/ds-react": ^4.7.3
"@navikt/ds-tailwind": ^4.7.3
"@navikt/ds-tokens": ^4.7.3
"@navikt/aksel-icons": ^4.9.0
"@navikt/ds-css": ^4.9.0
"@navikt/ds-react": ^4.9.0
"@navikt/ds-tailwind": ^4.9.0
"@navikt/ds-tokens": ^4.9.0
prettier-plugin-tailwindcss: ^0.2.3
languageName: unknown
linkType: soft
@@ -21952,8 +21952,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "shadow-dom@workspace:examples/shadow-dom"
dependencies:
"@navikt/ds-css": 4.7.3
"@navikt/ds-react": 4.7.3
"@navikt/ds-css": 4.9.0
"@navikt/ds-react": 4.9.0
"@types/react": ^18.0.0
"@types/react-dom": ^18.0.0
"@vitejs/plugin-react": ^3.1.0