Skip to content

Commit 957943a

Browse files
committed
Improved styles for buttons
1 parent 766c1d0 commit 957943a

File tree

9 files changed

+50
-25
lines changed

9 files changed

+50
-25
lines changed

packages/mdx/dev/content/scrollycoding.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ npm install next react react-dom
88

99
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Praesent elementum facilisis leo vel fringilla est ullamcorper eget. At imperdiet dui accumsan sit amet nulla facilities morbi tempus. Praesent elementum facilisis leo vel fringilla. Congue mauris rhoncus aenean vel. Egestas sed tempus urna et pharetra pharetra massa massa ultricies.
1010

11+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Praesent elementum facilisis leo vel fringilla est ullamcorper eget. At imperdiet dui accumsan sit amet nulla facilities morbi tempus. Praesent elementum facilisis leo vel fringilla. Congue mauris rhoncus aenean vel. Egestas sed tempus urna et pharetra pharetra massa massa ultricies.
12+
13+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Praesent elementum facilisis leo vel fringilla est ullamcorper eget. At imperdiet dui accumsan sit amet nulla facilities morbi tempus. Praesent elementum facilisis leo vel fringilla. Congue mauris rhoncus aenean vel. Egestas sed tempus urna et pharetra pharetra massa massa ultricies.
14+
1115
<CH.Scrollycoding>
1216

1317
Create a `next.config.js` file at the root of your project.
@@ -37,6 +41,18 @@ module.exports = withMDX({
3741
})
3842
```
3943

44+
```js foo.js
45+
46+
```
47+
48+
```js barbarbar.js
49+
50+
```
51+
52+
```js bax.js
53+
54+
```
55+
4056
---
4157

4258
```css index.css

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22
overflow: hidden;
33
}
44

5-
.ch-expand-button {
6-
width: 1.5em;
7-
height: 1.5em;
8-
cursor: pointer;
9-
}
10-
115
.ch-expand-dialog {
126
height: 100vh;
137
width: 100vw;
8+
max-width: 900px;
149
border: 0;
1510
background-color: transparent;
1611
}

packages/mdx/src/mini-editor/editor-frame.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function TabsContainer({
194194
<TabTitle title={title} />
195195
</div>
196196
))}
197-
<div style={{ flex: 1 }} />
197+
<div style={{ flex: 1, minWidth: "0.8em" }} />
198198
{button}
199199
</>
200200
)

packages/mdx/src/mini-editor/editor-tween.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ function EditorTween({
100100
<>
101101
{showCopyButton ? (
102102
<CopyButton
103+
className="ch-editor-button"
103104
content={northContent}
104-
style={{ marginRight: "0.8em" }}
105105
/>
106106
) : undefined}
107107
{showExpandButton ? (
108108
<ExpandButton
109-
style={{ marginRight: "0.8em" }}
109+
className="ch-editor-button"
110110
step={next || prev}
111111
theme={codeConfig.theme}
112112
/>
@@ -116,8 +116,8 @@ function EditorTween({
116116

117117
const southCopyButton = showCopyButton ? (
118118
<CopyButton
119+
className="ch-editor-button"
119120
content={southContent}
120-
style={{ marginRight: "0.8em" }}
121121
/>
122122
) : undefined
123123

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ export function ExpandButton({
77
style,
88
step,
99
theme,
10+
className,
1011
}: {
1112
style?: React.CSSProperties
1213
step: EditorStep
1314
theme: IRawTheme
15+
className?: string
1416
}) {
1517
const [expanded, setExpanded] = React.useState(false)
1618
const ref = React.useRef<any>(null)
1719
const files = step.files
1820
return (
1921
<>
2022
<ExpandIcon
23+
className={className}
2124
style={style}
2225
onClick={() => {
2326
ref.current.showModal()
@@ -61,15 +64,17 @@ export function ExpandButton({
6164
function ExpandIcon({
6265
onClick,
6366
style,
67+
className,
6468
}: {
6569
onClick: () => void
6670
style?: React.CSSProperties
71+
className?: string
6772
}) {
6873
return (
6974
<svg
7075
style={style}
7176
onClick={onClick}
72-
className="ch-expand-button"
77+
className={className}
7378
fill="none"
7479
stroke="currentColor"
7580
viewBox="0 0 24 24"

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,12 @@
9494
font-size: 12px;
9595
margin: 0;
9696
}
97+
98+
.ch-editor-button {
99+
width: 1.5em;
100+
height: 1.5em;
101+
cursor: pointer;
102+
min-width: 1.5em;
103+
min-height: 1.5em;
104+
margin-right: 0.8em;
105+
}

packages/mdx/src/smooth-code/code-tween.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,7 @@ function AfterDimensions({
171171
/>
172172
{config.showCopyButton ? (
173173
<CopyButton
174-
style={{
175-
position: "absolute",
176-
top: 10,
177-
right: 10,
178-
width: "1.1em",
179-
height: "1.1em",
180-
}}
174+
className="ch-code-button"
181175
content={stepInfo?.code?.prev}
182176
/>
183177
) : undefined}

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,29 @@ import React from "react"
33
export function CopyButton({
44
content,
55
style,
6+
className,
67
}: {
78
content: string
89
style?: React.CSSProperties
10+
className?: string
911
}) {
1012
const [copied, setCopied] = React.useState(false)
1113

1214
return (
1315
<svg
14-
style={{
15-
width: "1.5em",
16-
height: "1.5em",
17-
cursor: "pointer",
18-
...style,
19-
}}
16+
style={style}
2017
onClick={() => {
2118
copyToClipboard(content)
2219
setCopied(true)
2320
setTimeout(() => {
2421
setCopied(false)
2522
}, 1200)
2623
}}
27-
className="ch-copy-button"
2824
fill="none"
2925
stroke="currentColor"
3026
viewBox="0 0 24 24"
3127
xmlns="http://www.w3.org/2000/svg"
28+
className={className}
3229
>
3330
<title>Copy</title>
3431

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,12 @@
2525
background-color: var(--ch-selection-background);
2626
color: inherit;
2727
}
28+
29+
.ch-code-button {
30+
position: absolute;
31+
top: 10px;
32+
right: 10px;
33+
width: 1.1em;
34+
height: 1.1em;
35+
cursor: pointer;
36+
}

0 commit comments

Comments
 (0)