Skip to content

Commit 229a178

Browse files
committed
More button styles
1 parent d249c9c commit 229a178

File tree

8 files changed

+63
-52
lines changed

8 files changed

+63
-52
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/editor-frame.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function TabsContainer({
167167
)}
168168
{showFrameButtons ? <FrameButtons /> : <div />}
169169
{tabs.map(({ title, active, style }) => (
170-
<button
170+
<div
171171
key={title}
172172
title={title}
173173
data-ch-tab={panel}
@@ -198,10 +198,9 @@ function TabsContainer({
198198
),
199199
}}
200200
onClick={onTabClick && (() => onTabClick(title))}
201-
type="button"
202201
>
203202
<TabTitle title={title} />
204-
</button>
203+
</div>
205204
))}
206205
<div style={{ flex: 1, minWidth: "0.8em" }} />
207206
{button}

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 & 16 deletions
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

@@ -24,8 +25,6 @@
2425
color: rgba(255, 255, 255, 0.5);
2526
min-width: 0;
2627
border-bottom: 1px solid;
27-
border-left: 1px solid transparent;
28-
border-top: 1px solid transparent;
2928
}
3029

3130
.ch-editor-tab-active {
@@ -98,23 +97,11 @@
9897
}
9998

10099
.ch-editor-button {
100+
@include button-reset;
101+
101102
width: 1.5em;
102103
height: 1.5em;
103-
cursor: pointer;
104104
min-width: 1.5em;
105105
min-height: 1.5em;
106106
margin-right: 0.8em;
107-
108-
&[type="button"] {
109-
background-color: transparent;
110-
border: 1px solid transparent;
111-
color: inherit;
112-
}
113-
114-
svg {
115-
width: 1.5em;
116-
height: 1.5em;
117-
min-width: 1.5em;
118-
min-height: 1.5em;
119-
}
120107
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export function CopyButton({
1414
return (
1515
<button
1616
type="button"
17+
title="Copy code"
1718
className={className}
1819
style={style}
1920
onClick={() => {
@@ -30,8 +31,6 @@ export function CopyButton({
3031
viewBox="0 0 24 24"
3132
xmlns="http://www.w3.org/2000/svg"
3233
>
33-
<title>Copy</title>
34-
3534
{copied ? (
3635
<path
3736
strokeLinecap="round"

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)