Skip to content

Commit

Permalink
Adjust dates in Date/MonthPicker examples (#3238)
Browse files Browse the repository at this point in the history
  • Loading branch information
HalvorHaugan authored Oct 15, 2024
1 parent cfcd78a commit 7c468b1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 22 deletions.
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
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

0 comments on commit 7c468b1

Please sign in to comment.