Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit 5e8f58a

Browse files
authored
style(gatsby-theme-docz): improve Playground style (#1198)
1 parent 4805737 commit 5e8f58a

File tree

6 files changed

+22
-38
lines changed

6 files changed

+22
-38
lines changed

core/gatsby-theme-docz/src/components/Playground/LivePreviewWrapper.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

core/gatsby-theme-docz/src/components/Playground/index.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ import { jsx } from 'theme-ui'
33
import { useState } from 'react'
44
import { useConfig } from 'docz'
55
import { LiveProvider, LiveError, LivePreview, LiveEditor } from 'react-live'
6-
import { merge } from 'lodash/fp'
76
import { Resizable } from 're-resizable'
87
import copy from 'copy-text-to-clipboard'
98

109
import { usePrismTheme } from '~utils/theme'
11-
import { LivePreviewWrapper } from './LivePreviewWrapper'
1210
import * as styles from './styles'
1311
import * as Icons from '../Icons'
1412

@@ -35,18 +33,19 @@ export const Playground = ({
3533
return `<React.Fragment>${code}</React.Fragment>`
3634
}
3735

38-
const toggleCode = () => {
39-
setShowingCode(s => !s)
40-
}
36+
const copyCode = () => copy(code)
37+
38+
const toggleCode = () => setShowingCode(s => !s)
4139

4240
const resizableProps = {
4341
minWidth: 260,
4442
maxWidth: '100%',
4543
size: {
4644
width,
45+
height: 'auto',
4746
},
4847
style: {
49-
margin: '0 auto ',
48+
margin: '0 auto',
5049
},
5150
enable: {
5251
top: false,
@@ -70,22 +69,16 @@ export const Playground = ({
7069
scope={scope}
7170
transformCode={transformCode}
7271
language={language}
73-
theme={merge(theme, {
74-
plain: {
75-
fontFamily: 'Inconsolata',
76-
fontSize: 18,
77-
lineHeight: '1.5em',
78-
},
79-
})}
72+
theme={theme}
8073
>
8174
<div sx={styles.previewWrapper}>
82-
<LivePreviewWrapper showingCode={showingCode}>
75+
<div sx={styles.previewInner(showingCode)}>
8376
{showLivePreview && (
8477
<LivePreview sx={styles.preview} data-testid="live-preview" />
8578
)}
86-
</LivePreviewWrapper>
79+
</div>
8780
<div sx={styles.buttons}>
88-
<button sx={styles.button} onClick={() => copy(code)}>
81+
<button sx={styles.button} onClick={copyCode}>
8982
<Icons.Clipboard size={12} />
9083
</button>
9184
<button sx={styles.button} onClick={toggleCode}>

core/gatsby-theme-docz/src/components/Playground/styles.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ export const editor = theme => ({
44
p: 2,
55
border: t => `1px solid ${t.colors.border}`,
66
borderRadius: '0 0 4px 4px',
7-
overflow: 'hidden',
87
background: theme.plain.backgroundColor,
98
borderTop: 0,
109
fontFamily: 'monospace',
1110
fontSize: 18,
1211
'* > textarea:focus': {
13-
font: '400 18px Inconsolata !important',
14-
lineHeight: '1.5em !important',
1512
outline: 'none',
1613
},
1714
})
@@ -29,10 +26,19 @@ export const previewWrapper = {
2926
position: 'relative',
3027
}
3128

29+
export const previewInner = (showingCode, height = 'auto') => ({
30+
height,
31+
display: 'block',
32+
minHeight: '100%',
33+
width: 'calc(100% - 2px)',
34+
bg: 'playground.bg',
35+
border: t => `1px solid ${t.colors.playground.border}`,
36+
borderRadius: showingCode ? '4px 4px 0 0' : '4px',
37+
})
38+
3239
export const preview = {
3340
m: 0,
3441
p: '20px',
35-
bg: 'playground.bg',
3642
}
3743

3844
export const buttons = {

core/gatsby-theme-docz/src/components/Props/styles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const propName = {
4646

4747
export const propType = {
4848
...column,
49-
colors: 'props.text',
49+
color: 'props.text',
5050
}
5151

5252
export const defaultValue = {

core/gatsby-theme-docz/src/theme/prism/dark.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export default {
22
plain: {
3+
fontFamily: 'Inconsolata',
34
color: '#d6deeb',
45
backgroundColor: '#13161F',
56
},

core/gatsby-theme-docz/src/theme/prism/light.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export default {
22
plain: {
3+
fontFamily: 'Inconsolata',
34
color: '#393A34',
45
backgroundColor: '#f6f8fa',
56
},

0 commit comments

Comments
 (0)