Skip to content

Commit ca6f6b5

Browse files
committed
chore: ASide BEM
1 parent 28e8e13 commit ca6f6b5

File tree

8 files changed

+91
-14
lines changed

8 files changed

+91
-14
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.rp-aside__progress-circle {
2+
display: inline-flex;
3+
}

packages/theme-default/src/components/Aside/ProgressCircle.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import clsx from 'clsx';
22
import type React from 'react';
3-
import * as styles from './ProgressCircle.module.scss';
3+
import './ProgressCircle.scss';
44

55
interface CircleProgressProps {
66
percent: number;
@@ -28,7 +28,7 @@ export const ProgressCircle: React.FC<CircleProgressProps> = ({
2828
<svg
2929
width={size}
3030
height={size}
31-
className={clsx(styles.progressCircle, className)}
31+
className={clsx('rp-aside__progress-circle', className)}
3232
>
3333
<circle
3434
cx={size / 2}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.rp-aside__scroll-to-top {
2+
cursor: pointer;
3+
font-size: 0.875rem;
4+
font-style: normal;
5+
font-weight: 400;
6+
line-height: 20px;
7+
color: var(--rp-c-text-2);
8+
background: transparent;
9+
display: flex;
10+
align-items: center;
11+
gap: 8px;
12+
border: none;
13+
}

packages/theme-default/src/components/Aside/ScrollToTop.tsx

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

33
export function ScrollToTop() {
44
const scrollToTop = () => {
@@ -9,7 +9,7 @@ export function ScrollToTop() {
99
};
1010

1111
return (
12-
<button className={`${styles.scrollToTop}`} onClick={scrollToTop}>
12+
<button className="rp-aside__scroll-to-top" onClick={scrollToTop}>
1313
<svg
1414
width="16"
1515
height="16"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.rp-aside__toc-item {
2+
display: flex;
3+
line-height: 24px;
4+
justify-content: flex-start;
5+
align-items: flex-start;
6+
gap: 10px;
7+
align-self: stretch;
8+
border-radius: 6px;
9+
position: relative;
10+
color: var(--rp-c-text-2);
11+
font-weight: 400;
12+
font-size: 14px;
13+
14+
&--active {
15+
color: var(--rp-c-link);
16+
17+
&::before {
18+
content: '';
19+
display: block;
20+
height: 100%;
21+
width: 1px;
22+
background-color: var(--rp-c-brand);
23+
position: absolute;
24+
left: -20px;
25+
top: 0px;
26+
}
27+
}
28+
}

packages/theme-default/src/components/Aside/TocItem.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
renderInlineMarkdown,
66
} from '../../logic/utils';
77
import { Link } from '../Link';
8-
import * as styles from './TocItem.module.scss';
8+
import './TocItem.scss';
99

1010
export const TocItem = ({
1111
header,
@@ -21,16 +21,15 @@ export const TocItem = ({
2121
<Link
2222
href={`#${header.id}`}
2323
title={parseInlineMarkdownText(header.text)}
24-
className={clsx('aside-link', styles.tocItem, {
25-
[styles.active]: active,
26-
'aside-link-active': active,
24+
className={clsx('rp-aside__toc-item', {
25+
'rp-aside__toc-item--active': active,
2726
})}
2827
style={{
2928
paddingLeft: (header.depth - baseHeaderLevel) * 12,
3029
}}
3130
>
3231
<span
33-
className="aside-link-text"
32+
className="rp-aside__toc-text"
3433
{...renderInlineMarkdown(header.text)}
3534
></span>
3635
</Link>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.rp-aside {
2+
display: flex;
3+
flex-direction: column;
4+
border-left: 1px solid var(--rp-c-divider-light);
5+
padding-left: 20px;
6+
7+
&__title {
8+
font-size: 14px;
9+
font-weight: 700;
10+
height: 32px;
11+
line-height: 32px;
12+
font-family: Inter;
13+
font-style: normal;
14+
color: var(--rp-c-text-1);
15+
margin-bottom: 4px;
16+
display: inline-flex;
17+
align-items: center;
18+
gap: 4px;
19+
}
20+
21+
&__divider {
22+
height: 1px;
23+
background: var(--rp-c-divider-light);
24+
margin-top: 16px;
25+
margin-bottom: 16px;
26+
}
27+
28+
&__toc {
29+
display: flex;
30+
flex-direction: column;
31+
flex: 1;
32+
gap: 6px;
33+
}
34+
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useEffect, useMemo } from 'react';
33
import { scrollToTarget } from '../../logic/sideEffects';
44
import { type UISwitchResult, useUISwitch } from '../../logic/useUISwitch.js';
55

6-
import * as styles from './index.module.scss';
6+
import './index.scss';
77
import { ProgressCircle } from './ProgressCircle';
88
import { ScrollToTop } from './ScrollToTop';
99
import { TocItem } from './TocItem';
@@ -55,13 +55,13 @@ export function Aside() {
5555
}
5656

5757
return (
58-
<div className={styles.asideContainer}>
59-
<div className={styles.outlineTitle}>
58+
<div className="rp-aside">
59+
<div className="rp-aside__title">
6060
{outlineTitle}
6161
<ProgressCircle percent={readPercent} size={14} strokeWidth={2} />
6262
</div>
6363
<nav>
64-
<ul className={styles.tocContainer}>
64+
<ul className="rp-aside__toc">
6565
{headers.map((header, index) => (
6666
<TocItem
6767
key={`${header.depth}_${header.text}_${header.id}_${index}`}
@@ -74,7 +74,7 @@ export function Aside() {
7474
</nav>
7575

7676
<div style={{ display: readPercent !== 0 ? '' : 'none' }}>
77-
<div className={styles.divider} />
77+
<div className="rp-aside__divider" />
7878
<ScrollToTop />
7979
</div>
8080
</div>

0 commit comments

Comments
 (0)