Skip to content

Commit b055f9b

Browse files
authored
Merge pull request #68 from kleros/feat/add-accordion-stories
Feat: add accordion stories
2 parents 227a8b0 + c2211a3 commit b055f9b

20 files changed

+131
-478
lines changed

.storybook/preview.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

.storybook/preview.tsx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import React, { useEffect } from "react";
2+
import clsx from "clsx";
3+
4+
import type { Preview } from "@storybook/react";
5+
6+
import "../src/styles/global.css";
7+
8+
export type IPreviewArgs = {
9+
themeUI: "light" | "dark";
10+
backgroundUI: "white" | "light";
11+
};
12+
13+
const preview: Preview = {
14+
decorators: [
15+
(Story, { args }) => {
16+
const { themeUI, backgroundUI } = args;
17+
useEffect(() => {
18+
if (themeUI === "dark") document.documentElement.classList.add("dark");
19+
else document.documentElement.classList.remove("dark");
20+
}, [themeUI]);
21+
return (
22+
<div
23+
className={clsx(
24+
"p-4",
25+
backgroundUI === "white"
26+
? "bg-klerosUIComponentsWhiteBackground"
27+
: "bg-klerosUIComponentsLightBackground",
28+
)}
29+
>
30+
<Story />
31+
</div>
32+
);
33+
},
34+
],
35+
args: {
36+
themeUI: "light",
37+
backgroundUI: "white",
38+
},
39+
argTypes: {
40+
themeUI: {
41+
options: ["light", "dark"],
42+
control: { type: "radio" },
43+
},
44+
backgroundUI: {
45+
options: ["white", "light"],
46+
control: { type: "radio" },
47+
},
48+
},
49+
parameters: {
50+
layout: "centered",
51+
},
52+
};
53+
54+
export default preview;

eslint.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ export default [
6767
react: {
6868
version: "^16.12.0",
6969
},
70+
"import/resolver": {
71+
node: {
72+
extensions: [".js", ".jsx", ".ts", ".tsx"],
73+
},
74+
},
7075
},
7176

7277
rules: {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"simplebar": "^5.3.6",
9292
"simplebar-react": "^2.3.6",
9393
"smooth-scroll-into-view-if-needed": "^1.1.33",
94+
"tailwind-merge": "^3.0.2",
9495
"usehooks-ts": "^2.9.1"
9596
},
9697
"lint-staged": {

src/lib/accordion/accordion-item.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { useElementSize } from "../../hooks/useElementSize";
33
import Plus from "../../assets/svgs/accordion/plus.svg";
44
import Minus from "../../assets/svgs/accordion/minus.svg";
55

6-
import clsx from "clsx";
76
import { Button } from "react-aria-components";
7+
import { cn } from "../../utils";
88

99
interface AccordionItemProps {
1010
setExpanded: React.Dispatch<React.SetStateAction<number>>;
@@ -25,7 +25,7 @@ const AccordionItem: React.FC<AccordionItemProps> = ({
2525
return (
2626
<div className="my-2">
2727
<Button
28-
className={clsx(
28+
className={cn(
2929
"bg-klerosUIComponentsWhiteBackground border-klerosUIComponentsStroke border",
3030
"hover-medium-blue hover-short-transition hover:cursor-pointer",
3131
"rounded-[3px] px-8 py-[11.5px]",
@@ -35,18 +35,14 @@ const AccordionItem: React.FC<AccordionItemProps> = ({
3535
>
3636
{title}
3737
{expanded ? (
38-
<Minus
39-
className={clsx("fill-klerosUIComponentsPrimaryText h-4 w-4")}
40-
/>
38+
<Minus className={cn("fill-klerosUIComponentsPrimaryText h-4 w-4")} />
4139
) : (
42-
<Plus
43-
className={clsx("fill-klerosUIComponentsPrimaryText h-4 w-4")}
44-
/>
40+
<Plus className={cn("fill-klerosUIComponentsPrimaryText h-4 w-4")} />
4541
)}
4642
</Button>
4743
<div
4844
style={{ height: expanded ? `${height.toString()}px` : 0 }}
49-
className={clsx(
45+
className={cn(
5046
expanded ? `overflow-visible` : "overflow-hidden",
5147
"transition-[height] duration-(--klerosUIComponentsTransitionSpeed) ease-initial",
5248
)}

src/lib/accordion/custom.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { ReactNode, useState } from "react";
22
import AccordionItem from "./accordion-item";
3-
import clsx from "clsx";
3+
import { cn } from "../../utils";
44

55
interface AccordionItem {
66
title: ReactNode;
@@ -20,7 +20,7 @@ const CustomAccordion: React.FC<AccordionProps> = ({
2020
const [expanded, setExpanded] = useState(-1);
2121
return (
2222
<div
23-
className={clsx("box-border flex w-[1000px] flex-col", className)}
23+
className={cn("box-border flex w-[1000px] flex-col", className)}
2424
{...props}
2525
>
2626
{items.map((item, index) => (

src/lib/accordion/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { ReactNode, useState } from "react";
22
import AccordionItem from "./accordion-item";
3-
import clsx from "clsx";
3+
import { cn } from "../../utils";
44

55
interface AccordionItem {
66
title: string;
@@ -31,7 +31,7 @@ const Accordion: React.FC<AccordionProps> = ({
3131
const [expanded, setExpanded] = useState(defaultExpanded ?? -1);
3232
return (
3333
<div
34-
className={clsx("box-border flex w-[1000px] flex-col", className)}
34+
className={cn("box-border flex w-[1000px] flex-col", className)}
3535
{...props}
3636
>
3737
{items.map((item, index) => (

src/stories/Button.stories.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/stories/Button.tsx

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/stories/Header.stories.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)