mirror of
https://github.com/navikt/aksel.git
synced 2026-10-28 16:34:07 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46cbb4ba87 | ||
|
|
63fdacf0f8 | ||
|
|
b5c8a94378 | ||
|
|
212194964c | ||
|
|
d151cf4c07 | ||
|
|
44ba7a3a79 |
No files matched your search
@@ -1,5 +1,9 @@
|
||||
# @navikt/aksel-icons
|
||||
|
||||
## 2.8.10
|
||||
|
||||
## 2.8.9
|
||||
|
||||
## 2.8.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navikt/aksel-icons",
|
||||
"version": "2.8.8",
|
||||
"version": "2.8.10",
|
||||
"author": "Aksel | NAV",
|
||||
"homepage": "https://aksel.nav.no/ikoner",
|
||||
"repository": {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# @navikt/ds-codemod
|
||||
|
||||
## 2.8.10
|
||||
|
||||
## 2.8.9
|
||||
|
||||
## 2.8.8
|
||||
|
||||
## 2.8.7
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navikt/ds-codemod",
|
||||
"version": "2.8.8",
|
||||
"version": "2.8.10",
|
||||
"description": "Aksel codemods for NAVs designsystem",
|
||||
"author": "Aksel | NAV designsystem team",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
"build-pict": "svgr --silent --index-template index-template.js --out-dir src/pictograms pictograms"
|
||||
},
|
||||
"dependencies": {
|
||||
"@navikt/ds-icons": "^2.8.8",
|
||||
"@navikt/ds-react": "^2.8.8",
|
||||
"@navikt/ds-icons": "^2.8.10",
|
||||
"@navikt/ds-react": "^2.8.10",
|
||||
"clsx": "^1.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @navikt/ds-css
|
||||
|
||||
## 2.8.10
|
||||
|
||||
## 2.8.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#1905](https://github.com/navikt/aksel/pull/1905) [`212194964`](https://github.com/navikt/aksel/commit/212194964c4dd576e1ffc031316dff8cbe5016a2) Thanks [@KenAJoh](https://github.com/KenAJoh)! - :sparkles: Padding/border-radius tokens for button.css
|
||||
|
||||
## 2.8.8
|
||||
|
||||
## 2.8.7
|
||||
|
||||
@@ -16,38 +16,50 @@
|
||||
}
|
||||
|
||||
.navds-button {
|
||||
--__ac-button-padding: var(--a-spacing-3) var(--a-spacing-5);
|
||||
|
||||
display: inline-flex;
|
||||
cursor: pointer;
|
||||
margin: 0;
|
||||
text-decoration: none;
|
||||
border: none;
|
||||
background: none;
|
||||
border-radius: var(--a-border-radius-medium);
|
||||
padding: var(--a-spacing-3) var(--a-spacing-5);
|
||||
border-radius: var(--ac-button-border-radius, var(--a-border-radius-medium));
|
||||
padding: var(--ac-button-padding, var(--__ac-button-padding));
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--a-spacing-2);
|
||||
}
|
||||
|
||||
.navds-button--small {
|
||||
padding: 0.375rem var(--a-spacing-3);
|
||||
--__ac-button-padding: 0.375rem var(--a-spacing-3);
|
||||
|
||||
padding: var(--ac-button-padding-small, var(--__ac-button-padding));
|
||||
}
|
||||
|
||||
.navds-button--xsmall {
|
||||
padding: var(--a-spacing-05) var(--a-spacing-2);
|
||||
--__ac-button-padding: var(--a-spacing-05) var(--a-spacing-2);
|
||||
|
||||
padding: var(--ac-button-padding-xsmall, var(--__ac-button-padding));
|
||||
gap: var(--a-spacing-1);
|
||||
}
|
||||
|
||||
.navds-button--icon-only {
|
||||
padding: var(--a-spacing-3);
|
||||
--__ac-button-padding: var(--a-spacing-3);
|
||||
|
||||
padding: var(--ac-button-padding-icon-only, var(--__ac-button-padding));
|
||||
}
|
||||
|
||||
.navds-button--small.navds-button--icon-only {
|
||||
padding: 0.375rem;
|
||||
--__ac-button-padding: 0.375rem;
|
||||
|
||||
padding: var(--ac-button-padding-icon-only-small, var(--__ac-button-padding));
|
||||
}
|
||||
|
||||
.navds-button--xsmall.navds-button--icon-only {
|
||||
padding: var(--a-spacing-1);
|
||||
--__ac-button-padding: var(--a-spacing-1);
|
||||
|
||||
padding: var(--ac-button-padding-icon-only-xsmall, var(--__ac-button-padding));
|
||||
}
|
||||
|
||||
.navds-button:focus {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navikt/ds-css",
|
||||
"version": "2.8.8",
|
||||
"version": "2.8.10",
|
||||
"description": "CSS for NAV Designsystem",
|
||||
"author": "Aksel | NAV designsystem team",
|
||||
"keywords": [
|
||||
@@ -20,7 +20,7 @@
|
||||
"watch": "postcss --watch --use postcss-import -o dist/index.css index.css"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@navikt/ds-tokens": "^2.8.8",
|
||||
"@navikt/ds-tokens": "^2.8.10",
|
||||
"normalize.css": "^8.0.1",
|
||||
"postcss": "^8.4.0",
|
||||
"postcss-cli": "^9.0.0",
|
||||
|
||||
@@ -27,6 +27,13 @@
|
||||
"--ac-accordion-content-border-open": "--a-border-default"
|
||||
},
|
||||
"button": {
|
||||
"--ac-button-border-radius": "--a-border-radius-medium",
|
||||
"--ac-button-padding": "var(--a-spacing-3) var(--a-spacing-5)",
|
||||
"--ac-button-padding-small": "0.375rem var(--a-spacing-3)",
|
||||
"--ac-button-padding-xsmall": "var(--a-spacing-05) var(--a-spacing-2)",
|
||||
"--ac-button-padding-icon-only": "var(--a-spacing-3)",
|
||||
"--ac-button-padding-icon-only-small": "0.375rem",
|
||||
"--ac-button-padding-icon-only-xsmall": "var(--a-spacing-1)",
|
||||
"--ac-button-primary-bg": "--a-surface-action",
|
||||
"--ac-button-primary-text": "--a-text-on-action",
|
||||
"--ac-button-primary-hover-bg": "--a-surface-action-hover",
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
# @navikt/ds-react
|
||||
|
||||
## 2.8.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#1907](https://github.com/navikt/aksel/pull/1907) [`63fdacf0f`](https://github.com/navikt/aksel/commit/63fdacf0f8fa09593c64b35b49381d6c8a1befd1) Thanks [@KenAJoh](https://github.com/KenAJoh)! - :recycle: Refactor event-handling i datepicker-hooks
|
||||
|
||||
- Updated dependencies []:
|
||||
- @navikt/aksel-icons@2.8.10
|
||||
- @navikt/ds-icons@2.8.10
|
||||
|
||||
## 2.8.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @navikt/aksel-icons@2.8.9
|
||||
- @navikt/ds-icons@2.8.9
|
||||
|
||||
## 2.8.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navikt/ds-react",
|
||||
"version": "2.8.8",
|
||||
"version": "2.8.10",
|
||||
"description": "Aksel react-components for NAV designsystem",
|
||||
"author": "Aksel | NAV designsystem team",
|
||||
"license": "MIT",
|
||||
@@ -37,8 +37,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@floating-ui/react": "0.17.0",
|
||||
"@navikt/aksel-icons": "^2.8.8",
|
||||
"@navikt/ds-icons": "^2.8.8",
|
||||
"@navikt/aksel-icons": "^2.8.10",
|
||||
"@navikt/ds-icons": "^2.8.10",
|
||||
"@radix-ui/react-tabs": "1.0.0",
|
||||
"@radix-ui/react-toggle-group": "1.0.0",
|
||||
"clsx": "^1.2.1",
|
||||
|
||||
@@ -3,7 +3,7 @@ import cl from "clsx";
|
||||
import React, { forwardRef, InputHTMLAttributes } from "react";
|
||||
import { BodyShort, Button, ErrorMessage, Label, omit } from "..";
|
||||
import { FormFieldProps, useFormField } from "../form/useFormField";
|
||||
import { useDateInputContext } from "./hooks";
|
||||
import { useDateInputContext } from "./context";
|
||||
|
||||
export interface DateInputProps
|
||||
extends FormFieldProps,
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export { useDateInputContext, DateContext } from "./useDateInputContext";
|
||||
export {
|
||||
useSharedMonthContext,
|
||||
SharedMonthProvider,
|
||||
} from "./useSharedMonthContext";
|
||||
File renamed without changes.
File renamed without changes.
@@ -13,14 +13,14 @@ import {
|
||||
} from "react-day-picker";
|
||||
import { omit, Popover, useId } from "../..";
|
||||
import { DateInputType, DatePickerInput } from "../DateInput";
|
||||
import { DateContext } from "../hooks";
|
||||
import { DateContext } from "../context";
|
||||
import { getLocaleFromString, labels } from "../utils";
|
||||
import { Caption, DropdownCaption } from "./caption";
|
||||
import DatePickerStandalone, {
|
||||
DatePickerStandaloneType,
|
||||
} from "./DatePickerStandalone";
|
||||
import { DayButton } from "./DayButton";
|
||||
import { Head } from "./Head";
|
||||
import { TableHead } from "./TableHead";
|
||||
|
||||
export type ConditionalModeProps =
|
||||
| {
|
||||
@@ -221,7 +221,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
||||
components={{
|
||||
Caption: dropdownCaption ? DropdownCaption : Caption,
|
||||
Day: DayButton,
|
||||
Head: Head,
|
||||
Head: TableHead,
|
||||
}}
|
||||
className={cl("navds-date", className)}
|
||||
classNames={{
|
||||
|
||||
@@ -13,7 +13,7 @@ import { omit } from "../..";
|
||||
import { getLocaleFromString, labels } from "../utils";
|
||||
import { Caption, DropdownCaption } from "./caption";
|
||||
import { ConditionalModeProps, DatePickerDefaultProps } from "./DatePicker";
|
||||
import { Head } from "./Head";
|
||||
import { TableHead } from "./TableHead";
|
||||
|
||||
interface DatePickerStandaloneDefaultProps
|
||||
extends Omit<
|
||||
@@ -100,7 +100,7 @@ export const DatePickerStandalone: DatePickerStandaloneType = forwardRef<
|
||||
selected={selected ?? selectedDates}
|
||||
components={{
|
||||
Caption: dropdownCaption ? DropdownCaption : Caption,
|
||||
Head: Head,
|
||||
Head: TableHead,
|
||||
}}
|
||||
className="navds-date"
|
||||
classNames={{ vhidden: "navds-sr-only" }}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import React from "react";
|
||||
import { HeadRow, useDayPicker } from "react-day-picker";
|
||||
|
||||
/** Render the table head. */
|
||||
export function Head(): JSX.Element {
|
||||
export function TableHead(): JSX.Element {
|
||||
const { classNames, styles, components } = useDayPicker();
|
||||
const HeadRowComponent = components?.HeadRow ?? HeadRow;
|
||||
return (
|
||||
@@ -12,27 +12,6 @@ const disabledDays = [
|
||||
export default {
|
||||
title: "ds-react/Datepicker",
|
||||
component: DatePicker,
|
||||
argTypes: {
|
||||
size: {
|
||||
control: {
|
||||
type: "radio",
|
||||
options: ["medium", "small"],
|
||||
},
|
||||
},
|
||||
locale: {
|
||||
control: {
|
||||
type: "radio",
|
||||
options: ["nb", "nn", "en"],
|
||||
},
|
||||
},
|
||||
mode: {
|
||||
defaultValue: "single",
|
||||
control: {
|
||||
type: "radio",
|
||||
options: ["single", "multiple", "range"],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const Default = {
|
||||
@@ -123,6 +102,27 @@ export const Default = {
|
||||
inputfield: true,
|
||||
standalone: false,
|
||||
openOnFocus: true,
|
||||
mode: "single",
|
||||
},
|
||||
argTypes: {
|
||||
size: {
|
||||
control: {
|
||||
type: "radio",
|
||||
options: ["medium", "small"],
|
||||
},
|
||||
},
|
||||
locale: {
|
||||
control: {
|
||||
type: "radio",
|
||||
options: ["nb", "nn", "en"],
|
||||
},
|
||||
},
|
||||
mode: {
|
||||
control: {
|
||||
type: "radio",
|
||||
options: ["single", "multiple", "range"],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -4,8 +4,3 @@ export { useRangeDatepicker as UNSAFE_useRangeDatepicker } from "./useRangeDatep
|
||||
export type { RangeValidationT } from "./useRangeDatepicker";
|
||||
export { useMonthpicker as UNSAFE_useMonthpicker } from "./useMonthPicker";
|
||||
export type { MonthValidationT } from "./useMonthPicker";
|
||||
export { useDateInputContext, DateContext } from "./useDateInputContext";
|
||||
export {
|
||||
useSharedMonthContext,
|
||||
SharedMonthProvider,
|
||||
} from "./useSharedMonthContext";
|
||||
@@ -1,6 +1,6 @@
|
||||
import differenceInCalendarDays from "date-fns/differenceInCalendarDays";
|
||||
import isWeekend from "date-fns/isWeekend";
|
||||
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { DayClickEventHandler, isMatch } from "react-day-picker";
|
||||
import { DateInputProps } from "../DateInput";
|
||||
import { DatePickerProps } from "../datepicker/DatePicker";
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
isValidDate,
|
||||
parseDate,
|
||||
} from "../utils";
|
||||
import { useEscape } from "./useEscape";
|
||||
import { useOutsideClickHandler } from "./useOutsideClickHandler";
|
||||
|
||||
export interface UseDatepickerOptions
|
||||
extends Pick<
|
||||
@@ -134,7 +136,7 @@ export const useDatepicker = (
|
||||
const locale = getLocaleFromString(_locale);
|
||||
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const daypickerRef = useRef<HTMLDivElement>(null);
|
||||
const [daypickerRef, setDaypickerRef] = useState<HTMLDivElement>();
|
||||
|
||||
const [defaultSelected, setDefaultSelected] = useState(_defaultSelected);
|
||||
|
||||
@@ -148,45 +150,21 @@ export const useDatepicker = (
|
||||
: "";
|
||||
const [inputValue, setInputValue] = useState(defaultInputValue);
|
||||
|
||||
useOutsideClickHandler(open, setOpen, [
|
||||
daypickerRef,
|
||||
inputRef.current,
|
||||
inputRef.current?.nextSibling,
|
||||
]);
|
||||
|
||||
useEscape(open, setOpen, inputRef);
|
||||
|
||||
const updateDate = (date?: Date) => {
|
||||
onDateChange?.(date);
|
||||
setSelectedDay(date);
|
||||
};
|
||||
|
||||
const updateValidation = (val: Partial<DateValidationT> = {}) => {
|
||||
const msg = getValidationMessage(val);
|
||||
onValidate?.(msg);
|
||||
};
|
||||
|
||||
const handleFocusIn = useCallback(
|
||||
(e) => {
|
||||
/* Workaround for shadow-dom users (open) */
|
||||
const composed = e.composedPath?.()?.[0];
|
||||
if (!e?.target || !e?.target?.nodeType || !composed) {
|
||||
return;
|
||||
}
|
||||
|
||||
![
|
||||
daypickerRef.current,
|
||||
inputRef.current,
|
||||
inputRef.current?.nextSibling,
|
||||
].some(
|
||||
(element) => element?.contains(e.target) || element?.contains(composed)
|
||||
) &&
|
||||
open &&
|
||||
setOpen(false);
|
||||
},
|
||||
[open]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("focusin", handleFocusIn);
|
||||
window.addEventListener("pointerdown", handleFocusIn);
|
||||
return () => {
|
||||
window?.removeEventListener?.("focusin", handleFocusIn);
|
||||
window?.removeEventListener?.("pointerdown", handleFocusIn);
|
||||
};
|
||||
}, [handleFocusIn]);
|
||||
const updateValidation = (val: Partial<DateValidationT> = {}) =>
|
||||
onValidate?.(getValidationMessage(val));
|
||||
|
||||
const reset = () => {
|
||||
updateDate(defaultSelected);
|
||||
@@ -300,24 +278,6 @@ export const useDatepicker = (
|
||||
setMonth(defaultMonth ?? day);
|
||||
};
|
||||
|
||||
const handleClose = useCallback(() => {
|
||||
setOpen(false);
|
||||
inputRef.current && inputRef.current.focus();
|
||||
}, []);
|
||||
|
||||
const escape = useCallback(
|
||||
(e) => open && e.key === "Escape" && handleClose(),
|
||||
[handleClose, open]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("keydown", escape, false);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("keydown", escape, false);
|
||||
};
|
||||
}, [escape]);
|
||||
|
||||
const datepickerProps = {
|
||||
month,
|
||||
onMonthChange: (month) => setMonth(month),
|
||||
@@ -331,7 +291,7 @@ export const useDatepicker = (
|
||||
onOpenToggle: () => setOpen((x) => !x),
|
||||
disabled,
|
||||
disableWeekends,
|
||||
ref: daypickerRef,
|
||||
ref: setDaypickerRef,
|
||||
};
|
||||
|
||||
const inputProps = {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import React, { useCallback, useEffect } from "react";
|
||||
|
||||
export const useEscape = (
|
||||
open: boolean,
|
||||
setOpen: React.Dispatch<React.SetStateAction<boolean>>,
|
||||
focusRef: any
|
||||
) => {
|
||||
const handleClose = useCallback(() => {
|
||||
setOpen(false);
|
||||
focusRef?.current && focusRef.current.focus();
|
||||
}, [focusRef, setOpen]);
|
||||
|
||||
const escape = useCallback(
|
||||
(e) => open && e.key === "Escape" && handleClose(),
|
||||
[handleClose, open]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("keydown", escape, false);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("keydown", escape, false);
|
||||
};
|
||||
}, [escape]);
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { DateInputProps } from "../DateInput";
|
||||
import { MonthPickerProps } from "../monthpicker/MonthPicker";
|
||||
import {
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
isValidDate,
|
||||
parseDate,
|
||||
} from "../utils";
|
||||
import { useEscape } from "./useEscape";
|
||||
import { useOutsideClickHandler } from "./useOutsideClickHandler";
|
||||
|
||||
export interface UseMonthPickerOptions
|
||||
extends Pick<
|
||||
@@ -118,7 +120,7 @@ export const useMonthpicker = (
|
||||
const locale = getLocaleFromString(_locale);
|
||||
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const monthpickerRef = useRef<HTMLDivElement>(null);
|
||||
const [monthpickerRef, setMonthpickerRef] = useState<HTMLDivElement>();
|
||||
|
||||
// Initialize states
|
||||
const [year, setYear] = useState(defaultSelected ?? defaultYear ?? today);
|
||||
@@ -131,44 +133,21 @@ export const useMonthpicker = (
|
||||
|
||||
const [inputValue, setInputValue] = useState(defaultInputValue);
|
||||
|
||||
useOutsideClickHandler(open, setOpen, [
|
||||
monthpickerRef,
|
||||
inputRef.current,
|
||||
inputRef.current?.nextSibling,
|
||||
]);
|
||||
|
||||
useEscape(open, setOpen, inputRef);
|
||||
|
||||
const updateMonth = (date?: Date) => {
|
||||
onMonthChange?.(date);
|
||||
setSelectedMonth(date);
|
||||
};
|
||||
|
||||
const updateValidation = (val: Partial<MonthValidationT> = {}) => {
|
||||
const msg = getValidationMessage(val);
|
||||
onValidate?.(msg);
|
||||
};
|
||||
|
||||
const handleFocusIn = useCallback(
|
||||
(e) => {
|
||||
/* Workaround for shadow-dom users (open) */
|
||||
const composed = e.composedPath?.()?.[0];
|
||||
if (!e?.target || !e?.target?.nodeType || !composed) {
|
||||
return;
|
||||
}
|
||||
![
|
||||
monthpickerRef.current,
|
||||
inputRef.current,
|
||||
inputRef.current?.nextSibling,
|
||||
].some(
|
||||
(element) => element?.contains(e.target) || element?.contains(composed)
|
||||
) &&
|
||||
open &&
|
||||
setOpen(false);
|
||||
},
|
||||
[open]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("focusin", handleFocusIn);
|
||||
window.addEventListener("pointerdown", handleFocusIn);
|
||||
return () => {
|
||||
window?.removeEventListener?.("focusin", handleFocusIn);
|
||||
window?.removeEventListener?.("pointerdown", handleFocusIn);
|
||||
};
|
||||
}, [handleFocusIn]);
|
||||
const updateValidation = (val: Partial<MonthValidationT> = {}) =>
|
||||
onValidate?.(getValidationMessage(val));
|
||||
|
||||
const reset = () => {
|
||||
updateMonth(defaultSelected);
|
||||
@@ -294,24 +273,6 @@ export const useMonthpicker = (
|
||||
setYear(month);
|
||||
};
|
||||
|
||||
const handleClose = useCallback(() => {
|
||||
setOpen(false);
|
||||
inputRef.current && inputRef.current.focus();
|
||||
}, []);
|
||||
|
||||
const escape = useCallback(
|
||||
(e) => open && e.key === "Escape" && handleClose(),
|
||||
[handleClose, open]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("keydown", escape, false);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("keydown", escape, false);
|
||||
};
|
||||
}, [escape]);
|
||||
|
||||
const monthpickerProps = {
|
||||
year,
|
||||
onYearChange: (y?: Date) => setYear(y ?? today),
|
||||
@@ -323,7 +284,7 @@ export const useMonthpicker = (
|
||||
open,
|
||||
onOpenToggle: () => setOpen((x) => !x),
|
||||
disabled,
|
||||
ref: monthpickerRef,
|
||||
ref: setMonthpickerRef,
|
||||
};
|
||||
|
||||
const inputProps = {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import React, { useCallback, useEffect } from "react";
|
||||
|
||||
export const useOutsideClickHandler = (
|
||||
open: boolean,
|
||||
setOpen: React.Dispatch<React.SetStateAction<boolean>>,
|
||||
refs: Array<any>
|
||||
) => {
|
||||
const handleFocusIn = useCallback(
|
||||
(e) => {
|
||||
const composed = e.composedPath?.()?.[0];
|
||||
if (!e?.target || !e?.target?.nodeType || !composed) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
!refs.some(
|
||||
(element) =>
|
||||
element?.contains(e.target) || element?.contains(composed)
|
||||
)
|
||||
) {
|
||||
open && setOpen(false);
|
||||
}
|
||||
},
|
||||
[open, refs, setOpen]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("focusin", handleFocusIn);
|
||||
window.addEventListener("pointerdown", handleFocusIn);
|
||||
return () => {
|
||||
window?.removeEventListener?.("focusin", handleFocusIn);
|
||||
window?.removeEventListener?.("pointerdown", handleFocusIn);
|
||||
};
|
||||
}, [handleFocusIn]);
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
import differenceInCalendarDays from "date-fns/differenceInCalendarDays";
|
||||
import isBefore from "date-fns/isBefore";
|
||||
import isWeekend from "date-fns/isWeekend";
|
||||
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { DateRange, isMatch } from "react-day-picker";
|
||||
import { DateInputProps } from "../DateInput";
|
||||
import { DatePickerProps } from "../datepicker/DatePicker";
|
||||
@@ -12,6 +12,8 @@ import {
|
||||
parseDate,
|
||||
} from "../utils";
|
||||
import { DateValidationT, UseDatepickerOptions } from "./useDatepicker";
|
||||
import { useEscape } from "./useEscape";
|
||||
import { useOutsideClickHandler } from "./useOutsideClickHandler";
|
||||
|
||||
export type RangeValidationT = {
|
||||
from: DateValidationT;
|
||||
@@ -211,7 +213,7 @@ export const useRangeDatepicker = (
|
||||
|
||||
const inputRefTo = useRef<HTMLInputElement>(null);
|
||||
const inputRefFrom = useRef<HTMLInputElement>(null);
|
||||
const datePickerRef = useRef<HTMLDivElement | null>(null);
|
||||
const [daypickerRef, setDaypickerRef] = useState<HTMLDivElement>();
|
||||
|
||||
const [defaultSelected, setDefaultSelected] = useState(_defaultSelected);
|
||||
|
||||
@@ -241,6 +243,20 @@ export const useRangeDatepicker = (
|
||||
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
useOutsideClickHandler(open, setOpen, [
|
||||
daypickerRef,
|
||||
inputRefTo.current,
|
||||
inputRefFrom.current,
|
||||
inputRefTo.current?.nextSibling,
|
||||
inputRefFrom.current?.nextSibling,
|
||||
]);
|
||||
|
||||
useEscape(
|
||||
open,
|
||||
setOpen,
|
||||
selectedRange?.from && !selectedRange?.to ? inputRefTo : inputRefFrom
|
||||
);
|
||||
|
||||
const updateRange = (range?: DateRange) => {
|
||||
onRangeChange?.(range);
|
||||
setSelectedRange(range);
|
||||
@@ -255,37 +271,6 @@ export const useRangeDatepicker = (
|
||||
onValidate?.(msg);
|
||||
};
|
||||
|
||||
const handleFocusIn = useCallback(
|
||||
(e) => {
|
||||
/* Workaround for shadow-dom users (open) */
|
||||
const composed = e.composedPath?.()?.[0];
|
||||
if (!e?.target || !e?.target?.nodeType || !composed) {
|
||||
return;
|
||||
}
|
||||
![
|
||||
datePickerRef.current,
|
||||
inputRefTo.current,
|
||||
inputRefFrom.current,
|
||||
inputRefTo.current?.nextSibling,
|
||||
inputRefFrom.current?.nextSibling,
|
||||
].some(
|
||||
(element) => element?.contains(e.target) || element?.contains(composed)
|
||||
) &&
|
||||
open &&
|
||||
setOpen(false);
|
||||
},
|
||||
[open]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("focusin", handleFocusIn);
|
||||
window.addEventListener("pointerdown", handleFocusIn);
|
||||
return () => {
|
||||
window?.removeEventListener?.("focusin", handleFocusIn);
|
||||
window?.removeEventListener?.("pointerdown", handleFocusIn);
|
||||
};
|
||||
}, [handleFocusIn]);
|
||||
|
||||
const reset = () => {
|
||||
updateRange(defaultSelected ?? { from: undefined, to: undefined });
|
||||
setMonth(defaultSelected ? defaultSelected?.from : defaultMonth ?? today);
|
||||
@@ -527,28 +512,6 @@ export const useRangeDatepicker = (
|
||||
: toChange(e.target.value, day, isBefore, isAfter);
|
||||
};
|
||||
|
||||
const handleClose = useCallback(() => {
|
||||
setOpen(false);
|
||||
if (selectedRange?.from && !selectedRange?.to) {
|
||||
inputRefTo?.current?.focus();
|
||||
} else {
|
||||
inputRefFrom?.current?.focus();
|
||||
}
|
||||
}, [selectedRange]);
|
||||
|
||||
const escape = useCallback(
|
||||
(e) => open && e.key === "Escape" && handleClose(),
|
||||
[handleClose, open]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("keydown", escape, false);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("keydown", escape, false);
|
||||
};
|
||||
}, [escape]);
|
||||
|
||||
const datepickerProps = {
|
||||
month: month,
|
||||
onMonthChange: (month) => setMonth(month),
|
||||
@@ -563,7 +526,7 @@ export const useRangeDatepicker = (
|
||||
onOpenToggle: () => setOpen((x) => !x),
|
||||
disabled,
|
||||
disableWeekends,
|
||||
ref: datePickerRef,
|
||||
ref: setDaypickerRef,
|
||||
};
|
||||
|
||||
const fromInputProps = {
|
||||
|
||||
@@ -6,7 +6,7 @@ import isSameMonth from "date-fns/isSameMonth";
|
||||
import setYear from "date-fns/setYear";
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import { useDayPicker } from "react-day-picker";
|
||||
import { useSharedMonthContext } from "../hooks";
|
||||
import { useSharedMonthContext } from "../context";
|
||||
import { dateIsInCurrentMonth, isMatch, nextEnabled } from "../utils";
|
||||
|
||||
interface MonthType {
|
||||
|
||||
@@ -6,7 +6,7 @@ import startOfYear from "date-fns/startOfYear";
|
||||
import React from "react";
|
||||
import { useDayPicker } from "react-day-picker";
|
||||
import { Button, Select } from "../..";
|
||||
import { useSharedMonthContext } from "../hooks";
|
||||
import { useSharedMonthContext } from "../context";
|
||||
import { hasNextYear, labelNextYear, labelPrevYear } from "../utils";
|
||||
|
||||
export const MonthCaption = () => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import React, { forwardRef, useRef, useState } from "react";
|
||||
import { RootProvider } from "react-day-picker";
|
||||
import { Popover, useId } from "../..";
|
||||
import { DateInputType, MonthPickerInput } from "../DateInput";
|
||||
import { DateContext, SharedMonthProvider } from "../hooks";
|
||||
import { DateContext, SharedMonthProvider } from "../context";
|
||||
import { getLocaleFromString, Matcher } from "../utils";
|
||||
import MonthCaption from "./MonthCaption";
|
||||
import MonthPickerStandalone, {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import cl from "clsx";
|
||||
import React, { forwardRef, useState } from "react";
|
||||
import { RootProvider } from "react-day-picker";
|
||||
import { SharedMonthProvider } from "../hooks";
|
||||
import { SharedMonthProvider } from "../context";
|
||||
import { getLocaleFromString } from "../utils";
|
||||
import MonthCaption from "./MonthCaption";
|
||||
import { MonthPickerProps } from "./MonthPicker";
|
||||
|
||||
@@ -4,7 +4,7 @@ import setYear from "date-fns/setYear";
|
||||
import startOfMonth from "date-fns/startOfMonth";
|
||||
import React, { useState } from "react";
|
||||
import { BodyShort } from "../..";
|
||||
import { useSharedMonthContext } from "../hooks";
|
||||
import { useSharedMonthContext } from "../context";
|
||||
import { isMatch } from "../utils";
|
||||
import MonthButton from "./MonthButton";
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# @navikt/ds-tailwind
|
||||
|
||||
## 2.8.10
|
||||
|
||||
## 2.8.9
|
||||
|
||||
## 2.8.8
|
||||
|
||||
## 2.8.7
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navikt/ds-tailwind",
|
||||
"version": "2.8.8",
|
||||
"version": "2.8.10",
|
||||
"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": "^2.8.8",
|
||||
"@navikt/ds-tokens": "^2.8.10",
|
||||
"@types/jest": "^29.0.0",
|
||||
"color": "4.2.3",
|
||||
"jest": "^29.0.0",
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# @navikt/ds-tokens
|
||||
|
||||
## 2.8.10
|
||||
|
||||
## 2.8.9
|
||||
|
||||
## 2.8.8
|
||||
|
||||
## 2.8.7
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navikt/ds-tokens",
|
||||
"version": "2.8.8",
|
||||
"version": "2.8.10",
|
||||
"description": "Design-tokens for NAV designsystem",
|
||||
"author": "Aksel | NAV designsystem team",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# @navikt/ds-icons
|
||||
|
||||
## 2.8.10
|
||||
|
||||
## 2.8.9
|
||||
|
||||
## 2.8.8
|
||||
|
||||
## 2.8.7
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navikt/ds-icons",
|
||||
"version": "2.8.8",
|
||||
"version": "2.8.10",
|
||||
"description": "Aksel icons for NAV",
|
||||
"author": "Aksel | NAV designsystem team",
|
||||
"repository": {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# @navikt/ds-css-internal
|
||||
|
||||
## 2.8.10
|
||||
|
||||
## 2.8.9
|
||||
|
||||
## 2.8.8
|
||||
|
||||
## 2.8.7
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navikt/ds-css-internal",
|
||||
"version": "2.8.8",
|
||||
"version": "2.8.10",
|
||||
"description": "CSS for NAV internal Designsystem-components",
|
||||
"author": "Aksel | NAV designsystem team",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
# @navikt/ds-react-internal
|
||||
|
||||
## 2.8.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`63fdacf0f`](https://github.com/navikt/aksel/commit/63fdacf0f8fa09593c64b35b49381d6c8a1befd1)]:
|
||||
- @navikt/ds-react@2.8.10
|
||||
- @navikt/ds-icons@2.8.10
|
||||
|
||||
## 2.8.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @navikt/ds-react@2.8.9
|
||||
- @navikt/ds-icons@2.8.9
|
||||
|
||||
## 2.8.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navikt/ds-react-internal",
|
||||
"version": "2.8.8",
|
||||
"version": "2.8.10",
|
||||
"description": "Aksel react components for internal UIs in NAV",
|
||||
"author": "Aksel | NAV designsystem team",
|
||||
"license": "MIT",
|
||||
@@ -35,8 +35,8 @@
|
||||
"watch": "tsc --watch -p tsconfig.esm.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@navikt/ds-icons": "^2.8.8",
|
||||
"@navikt/ds-react": "^2.8.8",
|
||||
"@navikt/ds-icons": "^2.8.10",
|
||||
"@navikt/ds-react": "^2.8.10",
|
||||
"clsx": "^1.1.1",
|
||||
"copy-to-clipboard": "^3.3.1"
|
||||
},
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
"website"
|
||||
],
|
||||
"dependencies": {
|
||||
"@navikt/aksel-icons": "^2.8.8",
|
||||
"@navikt/ds-codemod": "^2.8.8",
|
||||
"@navikt/ds-css": "^2.8.8",
|
||||
"@navikt/ds-css-internal": "^2.8.8",
|
||||
"@navikt/ds-icons": "^2.8.8",
|
||||
"@navikt/ds-react": "^2.8.8",
|
||||
"@navikt/ds-react-internal": "^2.8.8",
|
||||
"@navikt/ds-tailwind": "^2.8.8",
|
||||
"@navikt/ds-tokens": "^2.8.8"
|
||||
"@navikt/aksel-icons": "^2.8.10",
|
||||
"@navikt/ds-codemod": "^2.8.10",
|
||||
"@navikt/ds-css": "^2.8.10",
|
||||
"@navikt/ds-css-internal": "^2.8.10",
|
||||
"@navikt/ds-icons": "^2.8.10",
|
||||
"@navikt/ds-react": "^2.8.10",
|
||||
"@navikt/ds-react-internal": "^2.8.10",
|
||||
"@navikt/ds-tailwind": "^2.8.10",
|
||||
"@navikt/ds-tokens": "^2.8.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier-plugin-tailwindcss": "^0.2.3"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ExternalLink } from "@navikt/ds-icons";
|
||||
import { ExternalLinkIcon } from "@navikt/aksel-icons";
|
||||
import { BodyLong, Detail, Heading, Ingress, Link } from "@navikt/ds-react";
|
||||
import BlockContent from "@sanity/block-content-to-react";
|
||||
import cl from "clsx";
|
||||
@@ -220,7 +220,7 @@ const serializers = {
|
||||
)
|
||||
}
|
||||
>
|
||||
{children} <ExternalLink title="åpner lenken i ny fane" />
|
||||
{children} <ExternalLinkIcon title="åpner lenken i ny fane" />
|
||||
</Link>
|
||||
) : (
|
||||
<NextLink href={href} passHref legacyBehavior>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Close, Hamburger as HamburgerIcon } from "@navikt/ds-icons";
|
||||
import { MenuHamburgerIcon, XMarkIcon } from "@navikt/aksel-icons";
|
||||
|
||||
import { Button } from "@navikt/ds-react";
|
||||
import cl from "clsx";
|
||||
import Link from "next/link";
|
||||
@@ -53,8 +54,9 @@ export const Hamburger = () => {
|
||||
aria-expanded={open}
|
||||
className="focus-visible:shadow-focus hover:bg-surface-neutral-subtle-hover ml-2 flex aspect-square items-center justify-center rounded px-3 py-3 focus:outline-none"
|
||||
>
|
||||
<HamburgerIcon
|
||||
className="pointer-events-none text-2xl"
|
||||
<MenuHamburgerIcon
|
||||
fontSize="2rem"
|
||||
className="pointer-events-none"
|
||||
aria-label="Åpne meny"
|
||||
/>
|
||||
</button>
|
||||
@@ -75,7 +77,7 @@ export const Hamburger = () => {
|
||||
styles.akselTertiaryButton,
|
||||
"absolute top-2 right-2"
|
||||
)}
|
||||
icon={<Close title="lukk meny" className="h-5 w-5" />}
|
||||
icon={<XMarkIcon title="lukk meny" fontSize="1.5rem" />}
|
||||
/>
|
||||
<LinkElement
|
||||
onClick={() => setOpen(false)}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { SearchLogT, useDebounce, logSearch } from "@/utils";
|
||||
import { Search as SearchIcon } from "@navikt/ds-icons";
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
@@ -15,6 +14,7 @@ import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||
import ReactModal from "react-modal";
|
||||
import { Group, GroupComponent } from "./Group";
|
||||
import styles from "../header.module.css";
|
||||
import { MagnifyingGlassIcon } from "@navikt/aksel-icons";
|
||||
|
||||
/**
|
||||
* https://www.figma.com/file/71Sm1h6VV23lbBbQ3CJJ9t/Aksel-v2?node-id=1861%3A186079&t=ARKgZcA6B7ysmG3V-0
|
||||
@@ -195,8 +195,8 @@ export const GlobalSearch = () => {
|
||||
className="hover:bg-deepblue-700 bg-deepblue-600 focus-visible:shadow-focus-gap h-11 focus:shadow-none"
|
||||
aria-keyshortcuts="Control+b"
|
||||
icon={
|
||||
<SearchIcon
|
||||
className="pointer-events-none -mt-[1px] shrink-0 text-xl"
|
||||
<MagnifyingGlassIcon
|
||||
className="pointer-events-none -mt-[1px] shrink-0 text-2xl"
|
||||
aria-label="Åpne meny"
|
||||
aria-hidden
|
||||
/>
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
/* eslint-disable @next/next/no-img-element */
|
||||
import { withErrorBoundary } from "@/error-boundary";
|
||||
import { SanityT, urlFor } from "@/lib";
|
||||
import { ErrorFilled, SuccessFilled, WarningFilled } from "@navikt/ds-icons";
|
||||
import {
|
||||
CheckmarkCircleFillIcon,
|
||||
ExclamationmarkTriangleFillIcon,
|
||||
XMarkOctagonFillIcon,
|
||||
} from "@navikt/aksel-icons";
|
||||
import { BodyShort } from "@navikt/ds-react";
|
||||
import cl from "clsx";
|
||||
import React from "react";
|
||||
@@ -10,23 +14,26 @@ const GetIcon = (s: string) => {
|
||||
switch (s) {
|
||||
case "do":
|
||||
return (
|
||||
<SuccessFilled
|
||||
<CheckmarkCircleFillIcon
|
||||
aria-hidden
|
||||
className="text-large mt-[1px] flex-shrink-0 text-green-500"
|
||||
fontSize="1.5rem"
|
||||
className="flex-shrink-0 text-green-500"
|
||||
/>
|
||||
);
|
||||
case "dont":
|
||||
return (
|
||||
<ErrorFilled
|
||||
<XMarkOctagonFillIcon
|
||||
aria-hidden
|
||||
className="text-large mt-[1px] flex-shrink-0 text-red-500"
|
||||
fontSize="1.5rem"
|
||||
className="flex-shrink-0 text-red-500"
|
||||
/>
|
||||
);
|
||||
case "warning":
|
||||
return (
|
||||
<WarningFilled
|
||||
<ExclamationmarkTriangleFillIcon
|
||||
aria-hidden
|
||||
className="text-large mt-[1px] flex-shrink-0 text-orange-500"
|
||||
fontSize="1.5rem"
|
||||
className="flex-shrink-0 text-orange-500"
|
||||
/>
|
||||
);
|
||||
default:
|
||||
@@ -60,14 +67,18 @@ const Element = ({
|
||||
{
|
||||
"border-t-border-success": block.variant === "do",
|
||||
"border-t-border-danger": block.variant === "dont",
|
||||
"border-t-border-warning": block.variant === "warning",
|
||||
"border-t-surface-warning": block.variant === "warning",
|
||||
}
|
||||
)}
|
||||
/>
|
||||
<figcaption data-variant={block.variant}>
|
||||
<div className="mt-3">
|
||||
{block.description && (
|
||||
<BodyShort size="small" as="span" className="inline-flex gap-2">
|
||||
<BodyShort
|
||||
size="small"
|
||||
as="span"
|
||||
className="inline-flex items-center gap-2"
|
||||
>
|
||||
{GetIcon(block.variant)}
|
||||
{block.description}
|
||||
</BodyShort>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { withErrorBoundary } from "@/error-boundary";
|
||||
import { SanityT } from "@/lib";
|
||||
import { ChevronDownCircleIcon } from "@navikt/aksel-icons";
|
||||
import internal from "@navikt/ds-css-internal/tokens.json";
|
||||
import core from "@navikt/ds-css/tokens.json";
|
||||
import { Expand } from "@navikt/ds-icons";
|
||||
import { BodyLong, Label, Link } from "@navikt/ds-react";
|
||||
import cl from "classnames";
|
||||
import CopyButton from "components/sanity-modules/code/CopyButton";
|
||||
@@ -94,14 +94,15 @@ const TokenTable = ({ node }: { node: SanityT.Schema.token_kategori }) => {
|
||||
{!open && showMore && (
|
||||
<button
|
||||
onClick={() => setOpen(true)}
|
||||
className="text-medium group mx-auto flex shrink-0 -translate-y-3/4 flex-col items-center focus:outline-none"
|
||||
className="text-medium group mx-auto flex shrink-0 -translate-y-3/4 flex-col items-center gap-1 focus:outline-none"
|
||||
>
|
||||
<span className="group-focus-visible:bg-border-focus group-focus-visible:text-text-on-action group-focus-visible:shadow-focus">
|
||||
Se alle tokens
|
||||
</span>
|
||||
<Expand
|
||||
className="h-4 w-4 transition-all group-hover:translate-y-1"
|
||||
<ChevronDownCircleIcon
|
||||
className="transition-all group-hover:translate-y-1"
|
||||
aria-hidden
|
||||
fontSize="1.5rem"
|
||||
/>
|
||||
</button>
|
||||
)}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Edit } from "@navikt/ds-icons";
|
||||
import { PencilIcon } from "@navikt/aksel-icons";
|
||||
import { getParameters } from "codesandbox/lib/api/define";
|
||||
|
||||
const indexTsx = `import React from 'react';
|
||||
@@ -29,6 +29,7 @@ export const CodeSandbox = ({ code }: { code: string }) => {
|
||||
"@navikt/ds-react-internal": "latest",
|
||||
"@navikt/ds-css-internal": "latest",
|
||||
"@navikt/ds-icons": "latest",
|
||||
"@navikt/aksel-icons": "latest",
|
||||
},
|
||||
} as any,
|
||||
isBinary: false,
|
||||
@@ -58,9 +59,9 @@ export const CodeSandbox = ({ code }: { code: string }) => {
|
||||
<input type="hidden" name="query" value="module=App.js" />
|
||||
<button
|
||||
type="submit"
|
||||
className="flex items-center justify-center gap-2 rounded-sm px-3 py-2 hover:bg-gray-100 focus:outline-none focus-visible:shadow-focus-inset active:bg-gray-200"
|
||||
className="focus-visible:shadow-focus-inset flex items-center justify-center gap-1 rounded-sm px-3 py-2 hover:bg-gray-100 focus:outline-none active:bg-gray-200"
|
||||
>
|
||||
<Edit aria-hidden />
|
||||
<PencilIcon aria-hidden fontSize="1.5rem" />
|
||||
CodeSandbox
|
||||
</button>
|
||||
</form>
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { withErrorBoundary } from "@/error-boundary";
|
||||
import { SanityT } from "@/lib";
|
||||
import { SanityBlockContent } from "@/sanity-block";
|
||||
import { Edit, LightBulb } from "@navikt/ds-icons";
|
||||
import { Detail, Link } from "@navikt/ds-react";
|
||||
import cl from "clsx";
|
||||
import React from "react";
|
||||
import style from "./tips.module.css";
|
||||
import { LightBulbIcon, PencilIcon } from "@navikt/aksel-icons";
|
||||
import { BodyShort, Detail, Link } from "@navikt/ds-react";
|
||||
|
||||
const Tips = ({ node }: { node: SanityT.Schema.tips }) => {
|
||||
if (!node || !node.body) {
|
||||
@@ -14,12 +11,7 @@ const Tips = ({ node }: { node: SanityT.Schema.tips }) => {
|
||||
|
||||
if (node.eksperiment) {
|
||||
return (
|
||||
<div
|
||||
className={cl(
|
||||
style.tips,
|
||||
"linear my-8 max-w-2xl rounded-r border-l-[6px] border-l-green-200 bg-white px-4 py-4 sm:px-8"
|
||||
)}
|
||||
>
|
||||
<div className="linear my-8 max-w-2xl rounded-r border-l-[6px] border-l-green-200 bg-white px-4 py-4 sm:px-8">
|
||||
<Detail
|
||||
className="text-text-subtle flex items-center gap-1 font-semibold uppercase"
|
||||
spacing
|
||||
@@ -57,10 +49,10 @@ const Tips = ({ node }: { node: SanityT.Schema.tips }) => {
|
||||
}}
|
||||
>
|
||||
Send feedback
|
||||
<Edit
|
||||
<PencilIcon
|
||||
aria-hidden
|
||||
aria-label="send inn feedback"
|
||||
className="text-base"
|
||||
fontSize="1.5rem"
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
@@ -68,19 +60,15 @@ const Tips = ({ node }: { node: SanityT.Schema.tips }) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cl(
|
||||
style.tips,
|
||||
"my-7 max-w-2xl px-4 py-3 shadow-[inset_5px_0_0_0_var(--a-gray-500),inset_0_0_0_1px_var(--a-gray-200)] sm:px-6"
|
||||
)}
|
||||
>
|
||||
<Detail
|
||||
className="override-text-no-max text-text-subtle -ml-[2px] flex items-center gap-1 font-semibold"
|
||||
<div className="border-l-deepblue-500 bg-deepblue-50 my-7 max-w-2xl border-l-4 px-4 py-3 sm:px-6">
|
||||
<BodyShort
|
||||
className="override-text-no-max text-deepblue-800 -ml-[2px] flex items-center gap-1 font-semibold"
|
||||
spacing
|
||||
size="small"
|
||||
>
|
||||
<LightBulb className="text-large" title="tips" aria-hidden />
|
||||
<LightBulbIcon fontSize="1.5rem" title="tips" aria-hidden />
|
||||
Tips
|
||||
</Detail>
|
||||
</BodyShort>
|
||||
<SanityBlockContent blocks={node.body} noLastMargin size="small" />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
.tips {
|
||||
@apply bg-gray-50;
|
||||
}
|
||||
|
||||
:global(.aksel-artikkel) .tips {
|
||||
@apply bg-white;
|
||||
}
|
||||
@@ -10,8 +10,8 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@navikt/ds-css": "2.8.8",
|
||||
"@navikt/ds-react": "2.8.8",
|
||||
"@navikt/ds-css": "2.8.10",
|
||||
"@navikt/ds-react": "2.8.10",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0"
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user