From 9e677697a71277e63c89b3aa871305ad2953a586 Mon Sep 17 00:00:00 2001 From: Halvor Haugan Date: Tue, 15 Oct 2024 12:15:24 +0200 Subject: [PATCH 1/5] [aksel.nav.no] Fix copy-pasting snippets in Firefox --- .../website/components/sanity-modules/code-snippet/Snippet.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/aksel.nav.no/website/components/sanity-modules/code-snippet/Snippet.tsx b/aksel.nav.no/website/components/sanity-modules/code-snippet/Snippet.tsx index 6f621b9e2c..04e0c589d2 100644 --- a/aksel.nav.no/website/components/sanity-modules/code-snippet/Snippet.tsx +++ b/aksel.nav.no/website/components/sanity-modules/code-snippet/Snippet.tsx @@ -88,6 +88,7 @@ const CodeSnippet = ({ node: { code, title } }: CodeSnippetProps) => { {line.map((token, key) => ( ))} + {`\n` /* Needed for copy-pasting in some browsers */} ))} From cfcd78a45079e4a77b0d200ff943a7397c653f76 Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 15 Oct 2024 15:40:45 +0200 Subject: [PATCH 2/5] [sanity] Grunnleggende now has access to props block --- aksel.nav.no/website/sanity/schema/objects/shared/riktekst.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aksel.nav.no/website/sanity/schema/objects/shared/riktekst.tsx b/aksel.nav.no/website/sanity/schema/objects/shared/riktekst.tsx index 042c0a8b5c..cf187ec088 100644 --- a/aksel.nav.no/website/sanity/schema/objects/shared/riktekst.tsx +++ b/aksel.nav.no/website/sanity/schema/objects/shared/riktekst.tsx @@ -188,7 +188,7 @@ const Riktekst = ( const templates = ["kode_eksempler", "exampletext_block"]; - const grunnleggende = ["spesial_seksjon", "attachment"]; + const grunnleggende = ["spesial_seksjon", "attachment", "props_seksjon"]; fields.push(...standard); From 7c468b18d19dcea3c3479f0a23c5c310f7c3bde2 Mon Sep 17 00:00:00 2001 From: Halvor Haugan <83693529+HalvorHaugan@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:35:45 +0200 Subject: [PATCH 3/5] Adjust dates in Date/MonthPicker examples (#3238) --- .../react/src/date/datepicker/DatePicker.tsx | 4 ++-- .../react/src/date/monthpicker/MonthPicker.tsx | 4 ++-- .../pages/eksempler/datepicker/disabled-days.tsx | 14 +++++++------- .../pages/eksempler/datepicker/dropdown.tsx | 6 ++++-- .../eksempler/monthpicker/disabled-months.tsx | 16 +++++++++------- .../pages/eksempler/monthpicker/dropdown.tsx | 6 ++++-- 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/@navikt/core/react/src/date/datepicker/DatePicker.tsx b/@navikt/core/react/src/date/datepicker/DatePicker.tsx index 2e6bf89d7b..53f2f96d0a 100644 --- a/@navikt/core/react/src/date/datepicker/DatePicker.tsx +++ b/@navikt/core/react/src/date/datepicker/DatePicker.tsx @@ -27,8 +27,8 @@ interface DatePickerComponent * ```jsx * * ``` */ diff --git a/@navikt/core/react/src/date/monthpicker/MonthPicker.tsx b/@navikt/core/react/src/date/monthpicker/MonthPicker.tsx index c58f9d48b0..649dfe205c 100644 --- a/@navikt/core/react/src/date/monthpicker/MonthPicker.tsx +++ b/@navikt/core/react/src/date/monthpicker/MonthPicker.tsx @@ -19,8 +19,8 @@ interface MonthPickerComponent * ```jsx * * ``` */ diff --git a/aksel.nav.no/website/pages/eksempler/datepicker/disabled-days.tsx b/aksel.nav.no/website/pages/eksempler/datepicker/disabled-days.tsx index af427fd928..42886a5c45 100644 --- a/aksel.nav.no/website/pages/eksempler/datepicker/disabled-days.tsx +++ b/aksel.nav.no/website/pages/eksempler/datepicker/disabled-days.tsx @@ -1,16 +1,16 @@ import { DatePicker } from "@navikt/ds-react"; import { withDsExample } from "@/web/examples/withDsExample"; -const Example = () => { - const disabledDays = [ - new Date("Oct 10 2022"), - { from: new Date("Oct 17 2022"), to: new Date("Nov 10 2022") }, - (date) => isFriday(date), - ]; +const disabledDays = [ + new Date("Oct 14 2024"), + { from: new Date("Oct 21 2024"), to: new Date("Nov 10 2024") }, + (date) => isFriday(date), +]; +const Example = () => { return ( diff --git a/aksel.nav.no/website/pages/eksempler/datepicker/dropdown.tsx b/aksel.nav.no/website/pages/eksempler/datepicker/dropdown.tsx index e509e7bbd7..761ddd3ecf 100644 --- a/aksel.nav.no/website/pages/eksempler/datepicker/dropdown.tsx +++ b/aksel.nav.no/website/pages/eksempler/datepicker/dropdown.tsx @@ -1,13 +1,15 @@ import { DatePicker } from "@navikt/ds-react"; import { withDsExample } from "@/web/examples/withDsExample"; +const year = new Date().getFullYear(); + const Example = () => { return ( ); }; diff --git a/aksel.nav.no/website/pages/eksempler/monthpicker/disabled-months.tsx b/aksel.nav.no/website/pages/eksempler/monthpicker/disabled-months.tsx index 4570669cdc..86e322bc77 100644 --- a/aksel.nav.no/website/pages/eksempler/monthpicker/disabled-months.tsx +++ b/aksel.nav.no/website/pages/eksempler/monthpicker/disabled-months.tsx @@ -1,18 +1,20 @@ import { MonthPicker } from "@navikt/ds-react"; import { withDsExample } from "@/web/examples/withDsExample"; -const Example = () => { - const disabledDays = [ - new Date("May 10 2022"), - { from: new Date("Nov 17 2022"), to: new Date("Feb 10 2023") }, - ]; +const year = new Date().getFullYear(); + +const disabledDays = [ + new Date(`May 10 ${year}`), + { from: new Date(`Nov 17 ${year}`), to: new Date(`Feb 10 ${year + 1}`) }, +]; +const Example = () => { return ( ); diff --git a/aksel.nav.no/website/pages/eksempler/monthpicker/dropdown.tsx b/aksel.nav.no/website/pages/eksempler/monthpicker/dropdown.tsx index 8fe162aecd..d874ed8433 100644 --- a/aksel.nav.no/website/pages/eksempler/monthpicker/dropdown.tsx +++ b/aksel.nav.no/website/pages/eksempler/monthpicker/dropdown.tsx @@ -1,13 +1,15 @@ import { MonthPicker } from "@navikt/ds-react"; import { withDsExample } from "@/web/examples/withDsExample"; +const year = new Date().getFullYear(); + const Example = () => { return ( ); }; From a05dbadfa41347329dd5e063f2ceae6b4a234a5b Mon Sep 17 00:00:00 2001 From: Ken <26967723+KenAJoh@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:55:05 +0200 Subject: [PATCH 4/5] [darkside]: Added support for darkside views in chromatic (#3239) --- @navikt/core/react/src/button/button.stories.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/@navikt/core/react/src/button/button.stories.tsx b/@navikt/core/react/src/button/button.stories.tsx index 2520c836a0..a38e01441b 100644 --- a/@navikt/core/react/src/button/button.stories.tsx +++ b/@navikt/core/react/src/button/button.stories.tsx @@ -190,3 +190,19 @@ export const ChromaticForcedColors: Story = { chromatic: { disable: false, forcedColors: "active" }, }, }; + +export const ChromaticDarksideDark: Story = { + render: Chromatic.render, + parameters: { + chromatic: { disable: false }, + }, + globals: { theme: "dark", mode: "darkside" }, +}; + +export const ChromaticDarksideLight: Story = { + render: Chromatic.render, + parameters: { + chromatic: { disable: false }, + }, + globals: { theme: "light", mode: "darkside" }, +}; From 64a9762286ab3f574235f5de652eee95f01d2215 Mon Sep 17 00:00:00 2001 From: Ken <26967723+KenAJoh@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:29:39 +0200 Subject: [PATCH 5/5] change: Updated exports to make docgen work (#3235) --- .../src/overlays/action-menu/ActionMenu.tsx | 72 +++++++++---------- .../react/src/overlays/action-menu/index.ts | 1 + 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/@navikt/core/react/src/overlays/action-menu/ActionMenu.tsx b/@navikt/core/react/src/overlays/action-menu/ActionMenu.tsx index fe99aba64e..f0af892133 100644 --- a/@navikt/core/react/src/overlays/action-menu/ActionMenu.tsx +++ b/@navikt/core/react/src/overlays/action-menu/ActionMenu.tsx @@ -274,7 +274,7 @@ const ActionMenuRoot = ({ ); }; -const ActionMenu = ActionMenuRoot as ActionMenuComponent; +export const ActionMenu = ActionMenuRoot as ActionMenuComponent; /* -------------------------------------------------------------------------- */ /* ActionMenuTrigger */ @@ -284,7 +284,10 @@ interface ActionMenuTriggerProps children: React.ReactElement; } -const ActionMenuTrigger = forwardRef( +export const ActionMenuTrigger = forwardRef< + HTMLButtonElement, + ActionMenuTriggerProps +>( ( { children, onKeyDown, style, onClick, ...rest }: ActionMenuTriggerProps, ref, @@ -330,7 +333,10 @@ interface ActionMenuContentProps children?: React.ReactNode; } -const ActionMenuContent = forwardRef( +export const ActionMenuContent = forwardRef< + HTMLDivElement, + ActionMenuContentProps +>( ( { children, @@ -382,7 +388,7 @@ interface ActionMenuLabelProps extends React.HTMLAttributes { children: React.ReactNode; } -const ActionMenuLabel = forwardRef( +export const ActionMenuLabel = forwardRef( ({ children, className, ...rest }: ActionMenuLabelProps, ref) => { return (
& ActionMenuGroupLabelingProps; -const ActionMenuGroup = forwardRef< +export const ActionMenuGroup = forwardRef< ActionMenuGroupElement, ActionMenuGroupProps >(({ children, className, label, ...rest }: ActionMenuGroupProps, ref) => { @@ -519,7 +525,7 @@ interface ActionMenuItemProps extends Omit { icon?: React.ReactNode; } -const ActionMenuItem: OverridableComponent< +export const ActionMenuItem: OverridableComponent< ActionMenuItemProps, ActionMenuItemElement > = forwardRef( @@ -577,7 +583,7 @@ interface ActionMenuCheckboxItemProps shortcut?: string; } -const ActionMenuCheckboxItem = forwardRef< +export const ActionMenuCheckboxItem = forwardRef< ActionMenuCheckboxItemElement, ActionMenuCheckboxItemProps >( @@ -687,7 +693,7 @@ type ActionMenuRadioGroupProps = ActionMenuGroupLabelingProps & children: React.ReactNode; }; -const ActionMenuRadioGroup = forwardRef< +export const ActionMenuRadioGroup = forwardRef< ActionMenuRadioGroupElement, ActionMenuRadioGroupProps >(({ children, label, ...rest }: ActionMenuRadioGroupProps, ref) => { @@ -719,7 +725,7 @@ interface ActionMenuRadioItemProps extends Omit { children: React.ReactNode; } -const ActionMenuRadioItem = forwardRef< +export const ActionMenuRadioItem = forwardRef< ActionMenuRadioItemElement, ActionMenuRadioItemProps >( @@ -810,7 +816,7 @@ type ActionMenuDividerElement = React.ElementRef; type MenuDividerProps = React.ComponentPropsWithoutRef; type ActionMenuDividerProps = Omit; -const ActionMenuDivider = forwardRef< +export const ActionMenuDivider = forwardRef< ActionMenuDividerElement, ActionMenuDividerProps >(({ className, ...rest }: ActionMenuDividerProps, ref) => { @@ -843,7 +849,7 @@ interface ActionMenuSubProps { onOpenChange?: (open: boolean) => void; } -const ActionMenuSub = (props: ActionMenuSubProps) => { +export const ActionMenuSub = (props: ActionMenuSubProps) => { const { children, open: openProp, onOpenChange, defaultOpen = false } = props; const [open = false, setOpen] = useControllableState({ @@ -871,7 +877,7 @@ interface ActionMenuSubTriggerProps icon?: React.ReactNode; } -const ActionMenuSubTrigger = forwardRef< +export const ActionMenuSubTrigger = forwardRef< ActionMenuSubTriggerElement, ActionMenuSubTriggerProps >(({ children, className, icon, ...rest }: ActionMenuSubTriggerProps, ref) => { @@ -910,7 +916,7 @@ interface ActionMenuSubContentProps children: React.ReactNode; } -const ActionMenuSubContent = forwardRef< +export const ActionMenuSubContent = forwardRef< ActionMenuSubContentElement, ActionMenuSubContentProps >( @@ -973,30 +979,18 @@ ActionMenu.Sub = ActionMenuSub; ActionMenu.SubTrigger = ActionMenuSubTrigger; ActionMenu.SubContent = ActionMenuSubContent; -export { - ActionMenu, - ActionMenuCheckboxItem, - ActionMenuContent, - ActionMenuDivider, - ActionMenuGroup, - ActionMenuItem, - ActionMenuLabel, - ActionMenuRadioGroup, - ActionMenuRadioItem, - ActionMenuSub, - ActionMenuSubContent, - ActionMenuSubTrigger, - ActionMenuTrigger, - type ActionMenuCheckboxItemProps, - type ActionMenuContentProps, - type ActionMenuDividerProps, - type ActionMenuGroupProps, - type ActionMenuLabelProps, - type ActionMenuProps, - type ActionMenuRadioGroupProps, - type ActionMenuRadioItemProps, - type ActionMenuSubContentProps, - type ActionMenuSubProps, - type ActionMenuSubTriggerProps, - type ActionMenuTriggerProps, +export type { + ActionMenuItemProps, + ActionMenuCheckboxItemProps, + ActionMenuContentProps, + ActionMenuDividerProps, + ActionMenuGroupProps, + ActionMenuLabelProps, + ActionMenuProps, + ActionMenuRadioGroupProps, + ActionMenuRadioItemProps, + ActionMenuSubContentProps, + ActionMenuSubProps, + ActionMenuSubTriggerProps, + ActionMenuTriggerProps, }; diff --git a/@navikt/core/react/src/overlays/action-menu/index.ts b/@navikt/core/react/src/overlays/action-menu/index.ts index 900fd62390..9dd738e6c3 100644 --- a/@navikt/core/react/src/overlays/action-menu/index.ts +++ b/@navikt/core/react/src/overlays/action-menu/index.ts @@ -13,6 +13,7 @@ export { ActionMenuSubContent, ActionMenuSubTrigger, ActionMenuTrigger, + type ActionMenuItemProps, type ActionMenuCheckboxItemProps, type ActionMenuContentProps, type ActionMenuGroupProps,