Skip to content

Commit 7584c1d

Browse files
author
Tim Roes
authored
🪟 🔧 Convert Markdown.styles.scss to module (#15646)
* Convert Markdown.styles.scss to module * Split scss modules for better linting
1 parent 4b4b499 commit 7584c1d

File tree

4 files changed

+57
-52
lines changed

4 files changed

+57
-52
lines changed

airbyte-webapp/src/components/Markdown/Markdown.styles.scss renamed to airbyte-webapp/src/components/Markdown/Markdown.module.scss

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@use "../../scss/colors";
22

3-
.airbyte-markdown {
3+
.markdown {
44
* {
55
color: colors.$dark-blue;
66
line-height: 24px;
@@ -81,51 +81,4 @@
8181
img {
8282
max-width: 100%;
8383
}
84-
85-
.admonition {
86-
border-radius: 8px;
87-
border-left: 8px solid colors.$grey-300;
88-
padding: 1px 16px 1px 48px;
89-
margin: -1px 0 15px;
90-
background-color: colors.$grey-50;
91-
position: relative;
92-
93-
&::before {
94-
content: "ℹ️";
95-
position: absolute;
96-
top: 16px;
97-
left: 16px;
98-
}
99-
100-
&--caution,
101-
&--warning {
102-
background-color: colors.$yellow-50;
103-
border-left-color: colors.$yellow-300;
104-
&::before {
105-
content: "⚠️";
106-
}
107-
}
108-
109-
&--danger {
110-
background-color: colors.$red-50;
111-
border-left-color: colors.$red-300;
112-
&::before {
113-
content: "⚠️";
114-
}
115-
}
116-
117-
&--note::before {
118-
content: "📝";
119-
}
120-
121-
&--tip,
122-
&--info {
123-
background-color: colors.$blue-50;
124-
border-left-color: colors.$blue-300;
125-
}
126-
127-
&--tip::before {
128-
content: "💡";
129-
}
130-
}
13184
}

airbyte-webapp/src/components/Markdown/Markdown.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import remarkDirective from "remark-directive";
77
import remarkFrontmatter from "remark-frontmatter";
88
import remarkGfm from "remark-gfm";
99

10+
import styles from "./Markdown.module.scss";
1011
import { remarkAdmonitionsPlugin } from "./remarkAdmonitionsPlugin";
1112

12-
import "./Markdown.styles.scss";
13-
1413
interface MarkdownProps {
1514
content?: string;
1615
className?: string;
@@ -22,7 +21,7 @@ export const Markdown: React.VFC<MarkdownProps> = ({ content, className, rehypeP
2221
<ReactMarkdown
2322
// Open everything except fragment only links in a new tab
2423
linkTarget={(href) => (href.startsWith("#") ? undefined : "_blank")}
25-
className={classNames("airbyte-markdown", className)}
24+
className={classNames(styles.markdown, className)}
2625
skipHtml
2726
// @ts-expect-error remarkFrontmatter currently has type conflicts due to duplicate vfile dependencies
2827
// This is not actually causing any issues, but requires to disable TS on this for now.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@use "../../scss/colors";
2+
3+
.admonition {
4+
border-radius: 8px;
5+
border-left: 8px solid colors.$grey-300;
6+
padding: 1px 16px 1px 48px;
7+
margin: -1px 0 15px;
8+
background-color: colors.$grey-50;
9+
position: relative;
10+
11+
&::before {
12+
content: "ℹ️";
13+
position: absolute;
14+
top: 16px;
15+
left: 16px;
16+
}
17+
18+
&--caution,
19+
&--warning {
20+
background-color: colors.$yellow-50;
21+
border-left-color: colors.$yellow-300;
22+
&::before {
23+
content: "⚠️";
24+
}
25+
}
26+
27+
&--danger {
28+
background-color: colors.$red-50;
29+
border-left-color: colors.$red-300;
30+
&::before {
31+
content: "⚠️";
32+
}
33+
}
34+
35+
&--note::before {
36+
content: "📝";
37+
}
38+
39+
&--tip,
40+
&--info {
41+
background-color: colors.$blue-50;
42+
border-left-color: colors.$blue-300;
43+
}
44+
45+
&--tip::before {
46+
content: "💡";
47+
}
48+
}

airbyte-webapp/src/components/Markdown/remarkAdmonitionsPlugin.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import { Plugin } from "unified";
33
import { Node } from "unist";
44
import { visit } from "unist-util-visit";
55

6+
// Since we're dynamically accessing the admonition--{node.name} classes, the linter
7+
// can't determine that those are used, thus we need to ignore unused classes here.
8+
// eslint-disable-next-line css-modules/no-unused-class
9+
import styles from "./admonitions.module.scss";
10+
611
const SUPPORTED_ADMONITION_NAMES: Readonly<string[]> = ["note", "tip", "info", "caution", "warning", "danger"];
712
const SUPPORTED_NODE_TYPES: Readonly<string[]> = ["textDirective", "leafDirective", "containerDirective"];
813

@@ -13,7 +18,7 @@ export const remarkAdmonitionsPlugin: Plugin<[], Root> = () => (tree) => {
1318
}
1419

1520
const data = node.data ?? (node.data = {});
16-
const className = `admonition admonition--${node.name}`;
21+
const className = `${styles.admonition} ${styles[`admonition--${node.name}`]}`;
1722

1823
data.hName = "div";
1924
data.hProperties = { class: className };

0 commit comments

Comments
 (0)