Skip to content

Commit b1d17b0

Browse files
committed
chore: BEM SwitchAppearance
1 parent 2b53b1d commit b1d17b0

File tree

4 files changed

+40
-25
lines changed

4 files changed

+40
-25
lines changed

packages/theme-default/src/components/SwitchAppearance/index.module.scss

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.rp-switch-appearance {
2+
cursor: pointer;
3+
width: 24px;
4+
height: 24px;
5+
position: relative;
6+
display: flex;
7+
justify-content: center;
8+
align-items: center;
9+
color: var(--rp-c-text-2);
10+
11+
&:hover {
12+
color: var(--rp-c-text-1);
13+
}
14+
15+
&__icon {
16+
&--sun {
17+
display: block;
18+
}
19+
20+
&--moon {
21+
display: none;
22+
}
23+
}
24+
}
25+
26+
.rp-dark .rp-switch-appearance {
27+
&__icon {
28+
&--sun {
29+
display: none;
30+
}
31+
32+
&--moon {
33+
display: block;
34+
}
35+
}
36+
}

packages/theme-default/src/components/SwitchAppearance/index.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import SunSvg from '@theme-assets/sun';
44
import { type MouseEvent, useContext } from 'react';
55
import { SvgWrapper } from '../SvgWrapper';
66
import './global.scss';
7-
import { cls } from '../../utils';
8-
import * as styles from './index.module.scss';
7+
import './index.scss';
98

109
const supportAppearanceTransition = () => {
1110
return (
@@ -87,17 +86,14 @@ export function SwitchAppearance({ onClick }: { onClick?: () => void }) {
8786
};
8887

8988
return (
90-
<div
91-
onClick={handleClick}
92-
className={cls('rspress-nav-appearance', styles.switchAppearance)}
93-
>
89+
<div onClick={handleClick} className="rp-switch-appearance">
9490
<SvgWrapper
95-
className="dark:rp-hidden"
91+
className="rp-switch-appearance__icon rp-switch-appearance__icon--sun"
9692
icon={SunSvg}
9793
fill="currentColor"
9894
/>
9995
<SvgWrapper
100-
className="rp-hidden dark:rp-block"
96+
className="rp-switch-appearance__icon rp-switch-appearance__icon--moon"
10197
icon={MoonSvg}
10298
fill="currentColor"
10399
/>

packages/theme-default/src/utils.ts

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

0 commit comments

Comments
 (0)