Skip to content

Commit 741d356

Browse files
authored
Merge pull request #341 from mfranzke/mfranzke-patch-1
fix: use semantic elements
2 parents 20af25e + 229a178 commit 741d356

File tree

7 files changed

+87
-56
lines changed

7 files changed

+87
-56
lines changed

packages/mdx/src/mini-editor/code-browser.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "../utils/mixins.scss";
2+
13
.ch-code-browser {
24
display: flex;
35
height: 100%;
@@ -45,9 +47,10 @@
4547
}
4648

4749
.ch-code-browser-button {
50+
@include button-reset;
51+
4852
width: 1.5em;
4953
height: 1.5em;
50-
cursor: pointer;
5154
min-width: 1.5em;
5255
min-height: 1.5em;
5356
position: absolute;

packages/mdx/src/mini-editor/dialog.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "../utils/mixins.scss";
2+
13
.ch-no-scroll {
24
overflow: hidden;
35
}
@@ -15,10 +17,11 @@
1517
}
1618

1719
.ch-expand-close {
20+
@include button-reset;
21+
1822
position: absolute;
1923
top: 10px;
2024
right: 10px;
21-
cursor: pointer;
2225
color: white;
2326
width: 26px;
2427
height: 26px;

packages/mdx/src/mini-editor/expand-button.tsx

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -94,44 +94,50 @@ function ExpandIcon({
9494
className?: string
9595
}) {
9696
return (
97-
<svg
97+
<button
98+
type="button"
99+
title="Expand"
98100
style={style}
99101
onClick={onClick}
100102
className={className}
101-
fill="none"
102-
stroke="currentColor"
103-
viewBox="0 0 24 24"
104-
xmlns="http://www.w3.org/2000/svg"
105-
role="button"
106103
>
107-
<title>Expand</title>
108-
<path
109-
strokeLinecap="round"
110-
strokeLinejoin="round"
111-
strokeWidth={2}
112-
d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"
113-
/>
114-
</svg>
104+
<svg
105+
fill="none"
106+
stroke="currentColor"
107+
viewBox="0 0 24 24"
108+
xmlns="http://www.w3.org/2000/svg"
109+
>
110+
<path
111+
strokeLinecap="round"
112+
strokeLinejoin="round"
113+
strokeWidth={2}
114+
d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"
115+
/>
116+
</svg>
117+
</button>
115118
)
116119
}
117120
function CloseButton({ onClick }: { onClick: () => void }) {
118121
return (
119-
<svg
122+
<button
120123
onClick={onClick}
121124
className="ch-expand-close"
122-
fill="none"
123-
stroke="currentColor"
124-
viewBox="0 0 24 24"
125-
xmlns="http://www.w3.org/2000/svg"
126-
role="button"
125+
type="button"
126+
title="Close"
127127
>
128-
<title>Close</title>
129-
<path
130-
strokeLinecap="round"
131-
strokeLinejoin="round"
132-
strokeWidth={2}
133-
d="M6 18L18 6M6 6l12 12"
134-
/>
135-
</svg>
128+
<svg
129+
fill="none"
130+
stroke="currentColor"
131+
viewBox="0 0 24 24"
132+
xmlns="http://www.w3.org/2000/svg"
133+
>
134+
<path
135+
strokeLinecap="round"
136+
strokeLinejoin="round"
137+
strokeWidth={2}
138+
d="M6 18L18 6M6 6l12 12"
139+
/>
140+
</svg>
141+
</button>
136142
)
137143
}

packages/mdx/src/mini-editor/index.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@import "../smooth-code/index.scss";
44
@import "./dialog.scss";
55
@import "./code-browser.scss";
6+
@import "../utils/mixins.scss";
67

78
/** tabs */
89

@@ -96,9 +97,10 @@
9697
}
9798

9899
.ch-editor-button {
100+
@include button-reset;
101+
99102
width: 1.5em;
100103
height: 1.5em;
101-
cursor: pointer;
102104
min-width: 1.5em;
103105
min-height: 1.5em;
104106
margin-right: 0.8em;

packages/mdx/src/smooth-code/copy-button.tsx

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ export function CopyButton({
1212
const [copied, setCopied] = React.useState(false)
1313

1414
return (
15-
<svg
15+
<button
16+
type="button"
17+
title="Copy code"
18+
className={className}
1619
style={style}
1720
onClick={() => {
1821
copyToClipboard(content)
@@ -21,30 +24,30 @@ export function CopyButton({
2124
setCopied(false)
2225
}, 1200)
2326
}}
24-
fill="none"
25-
stroke="currentColor"
26-
viewBox="0 0 24 24"
27-
xmlns="http://www.w3.org/2000/svg"
28-
className={className}
2927
>
30-
<title>Copy</title>
31-
32-
{copied ? (
33-
<path
34-
strokeLinecap="round"
35-
strokeLinejoin="round"
36-
strokeWidth={2}
37-
d="M5 13l4 4L19 7"
38-
/>
39-
) : (
40-
<path
41-
strokeLinecap="round"
42-
strokeLinejoin="round"
43-
strokeWidth="1.6px"
44-
d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
45-
/>
46-
)}
47-
</svg>
28+
<svg
29+
fill="none"
30+
stroke="currentColor"
31+
viewBox="0 0 24 24"
32+
xmlns="http://www.w3.org/2000/svg"
33+
>
34+
{copied ? (
35+
<path
36+
strokeLinecap="round"
37+
strokeLinejoin="round"
38+
strokeWidth={2}
39+
d="M5 13l4 4L19 7"
40+
/>
41+
) : (
42+
<path
43+
strokeLinecap="round"
44+
strokeLinejoin="round"
45+
strokeWidth="1.6px"
46+
d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
47+
/>
48+
)}
49+
</svg>
50+
</button>
4851
)
4952
}
5053

packages/mdx/src/smooth-code/index.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "../utils/mixins.scss";
2+
13
.ch-code-line-number {
24
user-select: none;
35
text-align: right;
@@ -28,10 +30,11 @@
2830
}
2931

3032
.ch-code-button {
33+
@include button-reset;
34+
3135
position: absolute;
3236
top: 10px;
3337
right: 10px;
3438
width: 1.1em;
3539
height: 1.1em;
36-
cursor: pointer;
3740
}

packages/mdx/src/utils/mixins.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@mixin button-reset {
2+
-webkit-appearance: button;
3+
background-color: transparent;
4+
background-image: none;
5+
cursor: pointer;
6+
color: inherit;
7+
margin: 0;
8+
padding: 0;
9+
border: none;
10+
font-size: inherit;
11+
}

0 commit comments

Comments
 (0)