import { CheckmarkCircleFillIcon } from "@navikt/aksel-icons";
import { useState } from "@storybook/addons";
import { Meta } from "@storybook/react";
import * as React from "react";
import Timeline from "./Timeline";
export default {
title: "ds-react-internal/Timeline",
component: Timeline,
argTypes: {},
} as Meta;
const DummyLabel = () => {
return (
Periode: 15.07.2019 - 25.07.2019
Utbetalt: 12 345,00 kr
Dager igjen: 0
);
};
const row1 = [
{
id: "1",
start: new Date("Jan 1 2022"),
end: new Date("Jan 31 2022"),
status: "success",
icon: ,
statusLabel: "Sykemeldt",
},
{
id: "2",
start: new Date("Feb 1 2022"),
end: new Date("Mar 15 2022"),
status: "danger",
onSelectPeriod: () => console.log("PERIOD SELECTED!"),
statusLabel: "Sykemeldt",
},
{
id: "3",
start: new Date("May 2 2022"),
end: new Date("May 25 2022"),
status: "success",
icon: ,
statusLabel: "Sykemeldt",
},
{
id: "4",
start: new Date("Mar 1 2022"),
end: new Date("Mar 31 2022"),
status: "success",
onSelectPeriod: () => console.log("PERIOD SELECTED!"),
icon: ,
label: "test",
statusLabel: "Sykemeldt",
},
{
id: "5",
start: new Date("Jul 1 2022"),
end: new Date("Jul 31 2022"),
status: "warning",
icon: ,
onSelectPeriod: () => console.log("PERIOD SELECTED!"),
statusLabel: "Sykemeldt",
},
{
id: "6",
start: new Date("Aug 1 2022"),
end: new Date("Aug 30 2022"),
status: "warning",
icon: ,
statusLabel: "Sykemeldt",
},
];
const row2 = [
{
id: "7",
start: new Date("May 13 2022"),
end: new Date("May 25 2022"),
status: "warning",
onSelectPeriod: () => console.log("PERIOD SELECTED!"),
icon: ,
children: ,
},
{
id: "8",
start: new Date("Feb 1 2022"),
end: new Date("May 2 2022"),
status: "neutral",
onSelectPeriod: () => console.log("PERIOD SELECTED!"),
icon: ,
children: ,
},
];
export const Default = () => {
return (
}
>
{row1.map((p: any, i) => {
return (
);
})}
}
>
{row2.map((p: any, i) => {
return (
);
})}
);
};
export const WithPins = () => {
return (
Pin 1
Pin 2
Pin 3
}
>
{row1.map((p: any, i) => {
return (
);
})}
}
>
{row2.map((p: any, i) => {
return (
);
})}
);
};
export const WithZoom = () => {
return (
}
>
{row1.map((p: any, i) => {
return (
);
})}
}
>
{row2.map((p: any, i) => {
return (
);
})}
);
};
export const ActivePeriod = () => {
const [activePeriod, setActivePeriod] = useState(row1[0]);
return (
Pin 1
Pin 2
Pin 3
}
>
{row1.map((p: any, i) => {
return (
{
setActivePeriod(p);
p?.onSelectPeriod?.();
console.log("PERIOD SELECTED!");
}}
icon={p.icon}
isActive={activePeriod.id === p.id}
statusLabel={p.statusLabel}
>
{p.children}
);
})}
{row2.map((p: any, i) => {
return (
{
setActivePeriod(p);
p?.onSelectPeriod?.();
}}
icon={p.icon}
isActive={activePeriod.id === p.id}
statusLabel={p.statusLabel}
>
{p.children}
);
})}
}
/>
);
};
export const WithDayLabels = () => {
return (
}
>
}
>
);
};
export const WithYearLabels = () => {
return (
}
>
}
>
);
};
export const ContentDemo = () => {
const [activePeriod, setActivePeriod] = useState(undefined);
return (
Pin 1
Pin 2
Pin 3
}
>
{row1.map((p: any, i) => {
return (
{
setActivePeriod(p);
p?.onSelectPeriod?.();
console.log("PERIOD SELECTED!");
}}
icon={p.icon}
isActive={activePeriod?.id === p.id}
statusLabel={p.statusLabel}
aria-controls={
activePeriod?.id === p.id ? "timeline-data" : undefined
}
id={p.id}
>
{p.children}
);
})}
{row2.map((p: any, i) => {
return (
{
setActivePeriod(p);
p?.onSelectPeriod?.();
}}
icon={p.icon}
isActive={activePeriod?.id === p.id}
statusLabel={p.statusLabel}
aria-controls={
activePeriod?.id === p.id ? "timeline-data" : undefined
}
id={p.id}
>
{p.children}
);
})}
}
/>
{activePeriod && (
Period-data
{`Periode:${activePeriod.id}, dato:${activePeriod.start}`}
)}
);
};