Skip to content

Commit d2c6da5

Browse files
committed
feat(components): add ContentSeparator component and register in MDX map\n\n- Labeled horizontal divider with variants and configurable spacing\n- Rectangular style aligned with code block visuals\n- Text constrained to 2/3 width; lines fill remaining space
1 parent 83d8d1f commit d2c6da5

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Component: ContentSeparator
3+
*
4+
* A labeled horizontal divider with the message centered between two lines.
5+
* Useful for visually separating groups of content within a page.
6+
*
7+
* Props overview
8+
* - message: string — text shown in the label (required)
9+
* - variant: 'neutral' | 'info' | 'warning' | 'success' | 'danger' (default 'info')
10+
* - marginTopRem, marginBottomRem: control vertical spacing (defaults 2 / 1)
11+
*
12+
* Usage
13+
* <ContentSeparator message="Advanced configuration" />
14+
*/
15+
type Props = {
16+
/** The message displayed in the center label. */
17+
message: string;
18+
/** Optional visual style; default 'info'. */
19+
variant?: 'neutral' | 'info' | 'warning' | 'success' | 'danger';
20+
/** Extra spacing above (in rem). Default: 2. */
21+
marginTopRem?: number;
22+
/** Extra spacing below (in rem). Default: 1. */
23+
marginBottomRem?: number;
24+
};
25+
26+
import styles from './style.module.scss';
27+
28+
/**
29+
* ContentSeparator
30+
*
31+
* A labeled horizontal separator that sits between content blocks.
32+
* Example:
33+
* <ContentSeparator message="Advanced configuration" />
34+
*/
35+
export function ContentSeparator({
36+
message,
37+
variant = 'info',
38+
marginTopRem = 2,
39+
marginBottomRem = 1,
40+
}: Props) {
41+
return (
42+
<section
43+
className={styles.wrapper}
44+
style={{marginTop: `${marginTopRem}rem`, marginBottom: `${marginBottomRem}rem`}}
45+
>
46+
<div className={styles.separator} role="separator" aria-label={message}>
47+
<span className={styles.line} aria-hidden="true" />
48+
<span className={`${styles.label} ${styles[`label--${variant}`]}`}>{message}</span>
49+
<span className={styles.line} aria-hidden="true" />
50+
</div>
51+
</section>
52+
);
53+
}
54+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.wrapper {}
2+
3+
.separator {
4+
display: flex;
5+
align-items: center;
6+
gap: 0.75rem;
7+
width: 100%;
8+
}
9+
10+
.line {
11+
flex: 1 1 auto;
12+
height: 1px;
13+
background: var(--gray-a5);
14+
}
15+
16+
.label {
17+
display: inline-flex;
18+
align-items: center;
19+
padding: 0.35rem 0.75rem;
20+
border-radius: 6px;
21+
font-weight: 500;
22+
font-size: 0.95rem;
23+
color: #fff;
24+
background: var(--code-background);
25+
border: 1px solid var(--accent-11);
26+
box-shadow: 0 1px 2px var(--gray-a3);
27+
max-width: 66.6667%;
28+
flex: 0 1 66.6667%;
29+
text-align: center;
30+
justify-content: center;
31+
white-space: normal;
32+
}
33+
34+
.label--neutral {}
35+
.label--info { background: var(--accent-a3, var(--gray-a3)); border-color: var(--accent-a6, var(--gray-a6)); }
36+
.label--success { background: var(--green-a3, var(--gray-a3)); border-color: var(--green-a6, var(--gray-a6)); }
37+
.label--warning { background: var(--yellow-a3, var(--gray-a3)); border-color: var(--yellow-a6, var(--gray-a6)); }
38+
.label--danger { background: var(--red-a3, var(--gray-a3)); border-color: var(--red-a6, var(--gray-a6)); }
39+
40+
.content { margin-top: 1rem; }
41+

src/mdxComponents.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {CliChecksumTable} from './components/cliChecksumTable';
66
import {CodeBlock} from './components/codeBlock';
77
import {CodeTabs} from './components/codeTabs';
88
import {CommunitySupportedPlatforms} from './components/communitySupportedPlatforms';
9+
import {ContentSeparator} from './components/contentSeparator';
910
import {ConfigKey} from './components/configKey';
1011
import {ConfigValue} from './components/configValue';
1112
import {CreateGitHubAppForm} from './components/createGitHubAppForm';
@@ -58,6 +59,7 @@ export function mdxComponents(
5859
Card,
5960
CliChecksumTable,
6061
CommunitySupportedPlatforms,
62+
ContentSeparator,
6163
DevDocsCardGrid,
6264
PlatformFilter,
6365
CodeBlock,

0 commit comments

Comments
 (0)