Skip to content

Commit 3fed47f

Browse files
committed
refactor(lib): standardize CSS class naming and streamline imports
1 parent a35fb28 commit 3fed47f

File tree

10 files changed

+47
-59
lines changed

10 files changed

+47
-59
lines changed

lib/Accordion/Accordion.module.scss renamed to lib/Accordion/Accordion.scss

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.accordionGroup {
1+
.accordion-group {
22
.accordion:first-child {
33
@apply rounded-b-none rounded-t-xl border-b-0;
44
}
@@ -13,10 +13,10 @@
1313
}
1414

1515
.accordion {
16-
@apply bg-white overflow-hidden rounded-xl border dark:border-slate-700;
16+
@apply overflow-hidden rounded-xl border border-gray-950/10 dark:border-gray-100/10;
1717

18-
.accordionSummary {
19-
@apply m-0 cursor-pointer select-none bg-slate-50 px-4 py-2.5 font-medium text-gray-900 dark:bg-gray-900 dark:text-gray-200;
18+
.accordion-summary {
19+
@apply m-0 cursor-pointer select-none px-4 py-2.5 font-medium bg-gray-800/5 dark:bg-gray-300/5;
2020

2121
display: flex;
2222

@@ -37,7 +37,7 @@
3737
}
3838

3939
&[open] {
40-
.accordionSummary::before {
40+
.accordion-summary::before {
4141
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="gray" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 15 6-6 6 6"/></svg>');
4242

4343
@media (prefers-color-scheme: dark) {
@@ -53,6 +53,6 @@
5353
}
5454
}
5555

56-
.accordionContent {
57-
@apply p-4 dark:bg-slate-900 dark:text-slate-200;
56+
.accordion-content {
57+
@apply p-4;
5858
}

lib/Accordion/Accordion.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import styles from './Accordion.module.scss';
2+
import './Accordion.scss';
33

44
interface AccordionProps {
55
title: string;
@@ -12,13 +12,13 @@ interface AccordionGroupProps {
1212

1313
export const Accordion: React.FC<AccordionProps> = ({ title = '', children }) => {
1414
return (
15-
<details className={styles['accordion']}>
16-
<summary className={styles['accordionSummary']}>{title}</summary>
17-
<div className={styles['accordionContent']}>{children}</div>
15+
<details className={'accordion'}>
16+
<summary className={'accordion-summary'}>{title}</summary>
17+
<div className={'accordion-content'}>{children}</div>
1818
</details>
1919
);
2020
};
2121

2222
export const AccordionGroup: React.FC<AccordionGroupProps> = ({ children }) => {
23-
return <div className={styles['accordionGroup']}>{children}</div>;
23+
return <div className={'accordion-group'}>{children}</div>;
2424
};
File renamed without changes.

lib/Steps/Steps.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import styles from './Steps.module.scss';
2+
import './Steps.scss';
33

44
interface StepProps {
55
number: number | string;
@@ -10,19 +10,19 @@ interface StepProps {
1010
export const Step = ({ children, number, title }: StepProps) => {
1111
return (
1212
<div
13-
className={styles['step']}
13+
className={'step'}
1414
role="listitem"
1515
>
16-
<div className={styles['stepLine']}></div>
17-
<div className={styles['stepNumber']}>{number}</div>
18-
<div className={styles['stepContainer']}>
19-
<h3 className={styles['stepTitle']}>{title}</h3>
20-
<div className={styles['stepContent']}>{children}</div>
16+
<div className={'stepLine'}></div>
17+
<div className={'stepNumber'}>{number}</div>
18+
<div className={'stepContainer'}>
19+
<h3 className={'stepTitle'}>{title}</h3>
20+
<div className={'stepContent'}>{children}</div>
2121
</div>
2222
</div>
2323
);
2424
};
2525

2626
export const Steps = ({ children }: { children: React.ReactNode }) => {
27-
return <div className={styles['steps']}>{children}</div>;
27+
return <div className={'steps'}>{children}</div>;
2828
};

lib/Tabs/Tabs.module.scss renamed to lib/Tabs/Tabs.scss

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
width: 100%;
55
}
66

7-
.tabLabel {
7+
.tab-label {
88
cursor: pointer;
9-
@apply mb-2 mr-3 rounded-md px-3 py-1.5 text-sm font-medium hover:bg-slate-800/10 dark:hover:bg-slate-800 text-slate-500;
9+
@apply mb-2 mr-3 rounded-md px-3 py-1.5 text-sm font-medium hover:bg-gray-800/10 dark:hover:bg-gray-800 dark:text-gray-300 text-gray-500;
1010
}
1111

12-
.tabRadio {
12+
.tab-radio {
1313
position: absolute;
1414
opacity: 0;
1515
top: 0;
1616
}
1717

18-
.tabRadio:checked + .tabLabel {
19-
@apply relative block text-slate-800 dark:text-slate-200;
18+
.tab-radio:checked + .tab-label {
19+
@apply relative block text-gray-800 dark:text-gray-50;
2020

2121
&:after {
2222
content: '';
@@ -27,17 +27,17 @@
2727
right: 0;
2828
bottom: -9px;
2929

30-
@apply bg-slate-700;
30+
@apply bg-gray-700 dark:bg-gray-50;
3131
}
3232

33-
+ .tabPanel {
33+
+ .tab-panel {
3434
display: block;
3535
}
3636
}
3737

38-
.tabPanel {
38+
.tab-panel {
3939
order: 99;
4040
display: none;
4141
width: 100%;
42-
@apply border-t p-4;
42+
@apply border-t p-4 border-t-gray-900/10 dark:border-t-gray-50/10;
4343
}

lib/Tabs/Tabs.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
import React, { Children, isValidElement, ReactNode } from 'react';
2-
import styles from './Tabs.module.scss';
2+
import './Tabs.scss';
33

44
interface TabsProps {
55
children: ReactNode[] | ReactNode;
66
}
77

88
const Tabs = ({ children }: TabsProps) => {
99
return (
10-
<div className={styles['tabs']}>
10+
<div className={'tabs'}>
1111
{Children.map(children, (child, index) => {
1212
if (!isValidElement(child)) return null;
1313

1414
return (
1515
<>
1616
<input
17-
className={styles['tabRadio']}
17+
className={'tab-radio'}
1818
type="radio"
1919
name="tabs"
2020
id={`tab${index}`}
2121
defaultChecked={index === 0}
2222
/>
2323
<label
24-
className={styles['tabLabel']}
24+
className={'tab-label'}
2525
htmlFor={`tab${index}`}
2626
>
2727
{
2828
// @ts-ignore
2929
child.props.title
3030
}
3131
</label>
32-
<div className={styles['tabPanel']}>
32+
<div className={'tab-panel'}>
3333
{
3434
// @ts-ignore
3535
child.props.children

lib/Typography/Typography.module.scss renamed to lib/Typography/Typography.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
}
99

1010
img {
11-
@apply rounded-xl outline outline-offset-8 outline-gray-100;
11+
@apply rounded-xl outline outline-offset-8 outline-gray-900/10 dark:outline-gray-50/10;
1212
}
1313
}

lib/Typography/Typography.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import styles from './Typography.module.scss';
1+
import './Typography.scss';
22

33
export const Typography = ({ children }: { children: React.ReactNode }) => {
4-
return <div className={styles.typography}>{children}</div>;
4+
return <div className={'typography dark:prose-invert'}>{children}</div>;
55
};

src/pages/AccordionSamples.tsx

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
1-
import { Accordion, AccordionGroup } from '../../dist/accordion';
2-
import { Typography } from '../../dist/typography';
1+
import { Accordion, AccordionGroup } from '../../lib/Accordion/Accordion';
32

43
export const AccordionSamples = () => {
54
return (
65
<>
76
<AccordionGroup>
87
<Accordion title="How does a tech-savvy person fix a broken lightbulb?">
9-
<Typography>
10-
They turn it off and on again, just like they do with routers, modems, and any other
11-
device. If that fails, they google 'why won't my lightbulb work?
12-
</Typography>
8+
They turn it off and on again, just like they do with routers, modems, and any other
9+
device. If that fails, they google 'why won't my lightbulb work?
1310
</Accordion>
1411

1512
<Accordion title="Why do bugs always show up after deadlines?">
16-
<Typography>
17-
Because bugs love to party when you're done! It's like they know when you've declared
18-
'code complete' and show up uninvited.
19-
</Typography>
13+
Because bugs love to party when you're done! It's like they know when you've declared
14+
'code complete' and show up uninvited.
2015
</Accordion>
2116

2217
<Accordion title="What happens when you fix a bug at 2 a.m.?">
23-
<Typography>
24-
You either break five other things or question if you're even awake. The real mystery:
25-
Why are you working at 2 a.m.?
26-
</Typography>
18+
You either break five other things or question if you're even awake. The real mystery: Why
19+
are you working at 2 a.m.?
2720
</Accordion>
2821

2922
<Accordion title="Why does code always break right before launch?">
30-
<Typography>
31-
Because code is like a toddler — it behaves until everyone's watching. Then it throws a
32-
tantrum right when it matters most!
33-
</Typography>
23+
Because code is like a toddler — it behaves until everyone's watching. Then it throws a
24+
tantrum right when it matters most!
3425
</Accordion>
3526
</AccordionGroup>
3627
</>

src/pages/ImageSamples.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import { ImageZoom } from '../../lib/Image/ImageZoom';
44
export const ImageSamples = () => {
55
return (
66
<Typography>
7-
<ImageZoom
8-
className="rounded-xl"
9-
src="https://i.stubby.io/zb2dzjl/c5ajqz.webp"
10-
></ImageZoom>
7+
<ImageZoom src="https://i.stubby.io/zb2dzjl/c5ajqz.webp"></ImageZoom>
118
</Typography>
129
);
1310
};

0 commit comments

Comments
 (0)