Skip to content

Commit 685bcdb

Browse files
committed
feat: la til story for pagination
1 parent 0e07206 commit 685bcdb

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { Meta, StoryObj } from "@storybook/react";
2+
import React, { useState } from "react";
3+
import { Pagination as PaginationComponent } from "../Pagination.js";
4+
import "../styles/_index.scss";
5+
6+
const meta: Meta = {
7+
title: "Komponenter/Pagination",
8+
component: PaginationComponent,
9+
parameters: {
10+
layout: "centered",
11+
},
12+
tags: ["autodocs"],
13+
} satisfies Meta<typeof PaginationComponent>;
14+
15+
export default meta;
16+
17+
type Story = StoryObj<typeof PaginationComponent>;
18+
19+
export const Pagination: Story = {
20+
args: {
21+
currentPage: 1,
22+
numberOfPages: 10,
23+
onPageChange: () => {},
24+
},
25+
decorators: [
26+
(Story, context) => {
27+
const [currentPage, setCurrentPage] = useState<number>(
28+
context.args.currentPage,
29+
);
30+
31+
const numberOfPages = context.args.numberOfPages;
32+
33+
const onPageChange = (newPage: number, fromPage: number) => {
34+
if (newPage > 0 && newPage <= numberOfPages) {
35+
setCurrentPage(newPage);
36+
}
37+
};
38+
39+
return (
40+
<div>
41+
<PaginationComponent
42+
currentPage={currentPage}
43+
numberOfPages={numberOfPages}
44+
onPageChange={onPageChange}
45+
/>
46+
</div>
47+
);
48+
},
49+
],
50+
};

0 commit comments

Comments
 (0)