Skip to content

Commit

Permalink
Merge branch 'main' into actionmenu-docs-update-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
KenAJoh authored Oct 16, 2024
2 parents a0ae96d + 64a9762 commit a212dc3
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 62 deletions.
16 changes: 16 additions & 0 deletions @navikt/core/react/src/button/button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
};
4 changes: 2 additions & 2 deletions @navikt/core/react/src/date/datepicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ interface DatePickerComponent
* ```jsx
* <DatePicker.Standalone
* dropdownCaption
* fromDate={new Date("2020-10-01")}
* toDate={new Date("2024-10-01")}
* fromDate={new Date("2022-10-01")}
* toDate={new Date("2026-10-01")}
* />
* ```
*/
Expand Down
4 changes: 2 additions & 2 deletions @navikt/core/react/src/date/monthpicker/MonthPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ interface MonthPickerComponent
* ```jsx
* <MonthPicker.Standalone
* dropdownCaption
* fromDate={new Date("1 Oct 2020")}
* toDate={new Date("1 Oct 2024")}
* fromDate={new Date("1 Oct 2022")}
* toDate={new Date("1 Oct 2026")}
* />
* ```
*/
Expand Down
72 changes: 33 additions & 39 deletions @navikt/core/react/src/overlays/action-menu/ActionMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const ActionMenuRoot = ({
);
};

const ActionMenu = ActionMenuRoot as ActionMenuComponent;
export const ActionMenu = ActionMenuRoot as ActionMenuComponent;

/* -------------------------------------------------------------------------- */
/* ActionMenuTrigger */
Expand All @@ -284,7 +284,10 @@ interface ActionMenuTriggerProps
children: React.ReactElement;
}

const ActionMenuTrigger = forwardRef<HTMLButtonElement, ActionMenuTriggerProps>(
export const ActionMenuTrigger = forwardRef<
HTMLButtonElement,
ActionMenuTriggerProps
>(
(
{ children, onKeyDown, style, onClick, ...rest }: ActionMenuTriggerProps,
ref,
Expand Down Expand Up @@ -330,7 +333,10 @@ interface ActionMenuContentProps
children?: React.ReactNode;
}

const ActionMenuContent = forwardRef<HTMLDivElement, ActionMenuContentProps>(
export const ActionMenuContent = forwardRef<
HTMLDivElement,
ActionMenuContentProps
>(
(
{
children,
Expand Down Expand Up @@ -382,7 +388,7 @@ interface ActionMenuLabelProps extends React.HTMLAttributes<HTMLDivElement> {
children: React.ReactNode;
}

const ActionMenuLabel = forwardRef<HTMLDivElement, ActionMenuLabelProps>(
export const ActionMenuLabel = forwardRef<HTMLDivElement, ActionMenuLabelProps>(
({ children, className, ...rest }: ActionMenuLabelProps, ref) => {
return (
<div
Expand Down Expand Up @@ -427,7 +433,7 @@ type ActionMenuGroupLabelingProps =
type ActionMenuGroupProps = Omit<MenuGroupProps, "asChild"> &
ActionMenuGroupLabelingProps;

const ActionMenuGroup = forwardRef<
export const ActionMenuGroup = forwardRef<
ActionMenuGroupElement,
ActionMenuGroupProps
>(({ children, className, label, ...rest }: ActionMenuGroupProps, ref) => {
Expand Down Expand Up @@ -519,7 +525,7 @@ interface ActionMenuItemProps extends Omit<MenuItemProps, "asChild"> {
icon?: React.ReactNode;
}

const ActionMenuItem: OverridableComponent<
export const ActionMenuItem: OverridableComponent<
ActionMenuItemProps,
ActionMenuItemElement
> = forwardRef(
Expand Down Expand Up @@ -577,7 +583,7 @@ interface ActionMenuCheckboxItemProps
shortcut?: string;
}

const ActionMenuCheckboxItem = forwardRef<
export const ActionMenuCheckboxItem = forwardRef<
ActionMenuCheckboxItemElement,
ActionMenuCheckboxItemProps
>(
Expand Down Expand Up @@ -687,7 +693,7 @@ type ActionMenuRadioGroupProps = ActionMenuGroupLabelingProps &
children: React.ReactNode;
};

const ActionMenuRadioGroup = forwardRef<
export const ActionMenuRadioGroup = forwardRef<
ActionMenuRadioGroupElement,
ActionMenuRadioGroupProps
>(({ children, label, ...rest }: ActionMenuRadioGroupProps, ref) => {
Expand Down Expand Up @@ -719,7 +725,7 @@ interface ActionMenuRadioItemProps extends Omit<MenuRadioItemProps, "asChild"> {
children: React.ReactNode;
}

const ActionMenuRadioItem = forwardRef<
export const ActionMenuRadioItem = forwardRef<
ActionMenuRadioItemElement,
ActionMenuRadioItemProps
>(
Expand Down Expand Up @@ -810,7 +816,7 @@ type ActionMenuDividerElement = React.ElementRef<typeof Menu.Divider>;
type MenuDividerProps = React.ComponentPropsWithoutRef<typeof Menu.Divider>;
type ActionMenuDividerProps = Omit<MenuDividerProps, "asChild">;

const ActionMenuDivider = forwardRef<
export const ActionMenuDivider = forwardRef<
ActionMenuDividerElement,
ActionMenuDividerProps
>(({ className, ...rest }: ActionMenuDividerProps, ref) => {
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -871,7 +877,7 @@ interface ActionMenuSubTriggerProps
icon?: React.ReactNode;
}

const ActionMenuSubTrigger = forwardRef<
export const ActionMenuSubTrigger = forwardRef<
ActionMenuSubTriggerElement,
ActionMenuSubTriggerProps
>(({ children, className, icon, ...rest }: ActionMenuSubTriggerProps, ref) => {
Expand Down Expand Up @@ -910,7 +916,7 @@ interface ActionMenuSubContentProps
children: React.ReactNode;
}

const ActionMenuSubContent = forwardRef<
export const ActionMenuSubContent = forwardRef<
ActionMenuSubContentElement,
ActionMenuSubContentProps
>(
Expand Down Expand Up @@ -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,
};
1 change: 1 addition & 0 deletions @navikt/core/react/src/overlays/action-menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export {
ActionMenuSubContent,
ActionMenuSubTrigger,
ActionMenuTrigger,
type ActionMenuItemProps,
type ActionMenuCheckboxItemProps,
type ActionMenuContentProps,
type ActionMenuGroupProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const CodeSnippet = ({ node: { code, title } }: CodeSnippetProps) => {
{line.map((token, key) => (
<span key={key} {...getTokenProps({ token })} />
))}
{`\n` /* Needed for copy-pasting in some browsers */}
</span>
))}
</code>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<DatePicker.Standalone
today={new Date("Oct 9 2022")}
today={new Date("Oct 9 2024")}
disabled={disabledDays}
onSelect={console.info}
/>
Expand Down
6 changes: 4 additions & 2 deletions aksel.nav.no/website/pages/eksempler/datepicker/dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { DatePicker } from "@navikt/ds-react";
import { withDsExample } from "@/web/examples/withDsExample";

const year = new Date().getFullYear();

const Example = () => {
return (
<DatePicker.Standalone
onSelect={console.info}
dropdownCaption
fromDate={new Date("1 Oct 2020")}
toDate={new Date("1 Oct 2024")}
fromDate={new Date(`1 Oct ${year - 2}`)}
toDate={new Date(`1 Oct ${year + 2}`)}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<MonthPicker.Standalone
onMonthSelect={console.info}
dropdownCaption
fromDate={new Date("1 Oct 2020")}
toDate={new Date("1 Oct 2024")}
fromDate={new Date(`1 Oct ${year - 2}`)}
toDate={new Date(`1 Oct ${year + 2}`)}
disabled={disabledDays}
/>
);
Expand Down
6 changes: 4 additions & 2 deletions aksel.nav.no/website/pages/eksempler/monthpicker/dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { MonthPicker } from "@navikt/ds-react";
import { withDsExample } from "@/web/examples/withDsExample";

const year = new Date().getFullYear();

const Example = () => {
return (
<MonthPicker.Standalone
onMonthSelect={console.info}
dropdownCaption
fromDate={new Date("1 Oct 2020")}
toDate={new Date("1 Oct 2024")}
fromDate={new Date(`1 Oct ${year - 2}`)}
toDate={new Date(`1 Oct ${year + 2}`)}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit a212dc3

Please sign in to comment.