Skip to content

Commit 0b22790

Browse files
committed
refactor(Accordion): update styling integration with tailwind-variants
1 parent 5d11aaf commit 0b22790

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

lib/Accordion/Accordion.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,3 @@
5252
}
5353
}
5454
}
55-
56-
.accordion-content {
57-
@apply p-4;
58-
}

lib/Accordion/Accordion.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22
import './Accordion.scss';
33

4+
import { tv } from 'tailwind-variants';
5+
46
interface AccordionProps {
57
title: string;
68
children: React.ReactNode;
@@ -10,15 +12,29 @@ interface AccordionGroupProps {
1012
children: React.ReactNode | React.ReactNode[];
1113
}
1214

15+
const accordionStyles = tv({
16+
slots: {
17+
accordionGroup: 'rounded-none border-b-0 gap-2 flex flex-col',
18+
accordion: 'overflow-hidden rounded-xl border border-gray-950/10 dark:border-gray-100/10',
19+
accordionSummary:
20+
'm-0 cursor-pointer select-none px-4 py-2.5 font-medium bg-gray-800/5 dark:bg-gray-300/5 before:content-[""] before:mr-2',
21+
accordionContent: 'p-4',
22+
},
23+
});
24+
1325
export const Accordion: React.FC<AccordionProps> = ({ title = '', children }) => {
26+
const { accordion, accordionSummary, accordionContent } = accordionStyles();
27+
1428
return (
15-
<details className={'accordion'}>
16-
<summary className={'accordion-summary'}>{title}</summary>
17-
<div className={'accordion-content'}>{children}</div>
29+
<details className={accordion()}>
30+
<summary className={accordionSummary()}>{title}</summary>
31+
<div className={accordionContent()}>{children}</div>
1832
</details>
1933
);
2034
};
2135

2236
export const AccordionGroup: React.FC<AccordionGroupProps> = ({ children }) => {
23-
return <div className={'accordion-group'}>{children}</div>;
37+
const { accordionGroup } = accordionStyles();
38+
39+
return <div className={accordionGroup()}>{children}</div>;
2440
};

lib/Callout/Callout.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { VariantProps } from 'tailwind-variants';
1212
const callout = tv({
1313
slots: {
1414
base: 'mt-6 overflow-hidden rounded-xl border px-5 py-4 flex items-start space-x-3',
15-
icon: 'mt-0.5 h-5 w-5',
15+
icon: 'h-5 w-5 mt-[1px]',
1616
content: 'flex-1 overflow-x-auto first:mt-0 last:mb-0',
1717
},
1818
variants: {
@@ -91,10 +91,13 @@ const Callout = ({ variant = 'info', children }: CalloutProps) => {
9191

9292
return (
9393
<div className={base()}>
94-
<Icon
95-
size={20}
96-
className={icon()}
97-
/>
94+
<div className="flex items-center justify-center">
95+
<Icon
96+
size={20}
97+
className={icon()}
98+
/>
99+
<span className="-ml-[4px]">&nbsp;</span>
100+
</div>
98101
<div className={content()}>{children}</div>
99102
</div>
100103
);

src/pages/CalloutSamples.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ export function CalloutSamples() {
44
return (
55
<>
66
<Tip>Content for the tip goes here!</Tip>
7+
<Tip>
8+
Content for the tip goes here! Content for the tip goes here!Content for the tip goes
9+
here!Content for the tip goes here!Content for the tip goes here!Content for the tip goes
10+
here!
11+
</Tip>
712
<Info>This is an info</Info>
813
<Warning>This is a warning</Warning>
914
<Success>This is a success</Success>

0 commit comments

Comments
 (0)