playroom 0.27.7 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +2 -1
- package/README.md +4 -1
- package/images/logo-inverted.png +0 -0
- package/lib/getStaticTypes.js +1 -1
- package/lib/makeWebpackConfig.js +11 -17
- package/lib/start.js +3 -0
- package/package.json +8 -7
- package/src/Playroom/Button/Button.css.ts +85 -0
- package/src/Playroom/Button/Button.tsx +2 -2
- package/src/Playroom/CatchErrors/CatchErrors.css.ts +8 -0
- package/src/Playroom/CatchErrors/CatchErrors.tsx +58 -0
- package/src/Playroom/CodeEditor/CodeEditor.css.ts +223 -0
- package/src/Playroom/CodeEditor/CodeEditor.tsx +2 -3
- package/src/Playroom/Divider/Divider.css.ts +16 -0
- package/src/Playroom/Divider/Divider.tsx +1 -2
- package/src/Playroom/Frames/Frames.css.ts +83 -0
- package/src/Playroom/Frames/Frames.tsx +1 -2
- package/src/Playroom/FramesPanel/FramesPanel.css.ts +145 -0
- package/src/Playroom/FramesPanel/FramesPanel.tsx +1 -2
- package/src/Playroom/Heading/Heading.css.ts +27 -0
- package/src/Playroom/Heading/Heading.tsx +1 -2
- package/src/Playroom/Inline/Inline.css.ts +57 -0
- package/src/Playroom/Inline/Inline.tsx +10 -27
- package/src/Playroom/Playroom.css.ts +150 -0
- package/src/Playroom/Playroom.tsx +6 -29
- package/src/Playroom/Preview.css.ts +11 -0
- package/src/Playroom/Preview.tsx +1 -2
- package/src/Playroom/PreviewPanel/ThemeSelector.css.ts +62 -0
- package/src/Playroom/PreviewPanel/ThemeSelector.tsx +1 -2
- package/src/Playroom/SettingsPanel/SettingsPanel.css.ts +71 -0
- package/src/Playroom/SettingsPanel/SettingsPanel.tsx +117 -0
- package/src/Playroom/Snippets/SearchField/SearchField.css.ts +22 -0
- package/src/Playroom/Snippets/SearchField/SearchField.tsx +1 -2
- package/src/Playroom/Snippets/Snippets.css.ts +82 -0
- package/src/Playroom/Snippets/Snippets.tsx +7 -6
- package/src/Playroom/SplashScreen/SplashScreen.css.ts +58 -0
- package/src/Playroom/SplashScreen/SplashScreen.tsx +6 -8
- package/src/Playroom/Stack/Stack.css.ts +49 -0
- package/src/Playroom/Stack/Stack.tsx +18 -32
- package/src/Playroom/StatusMessage/StatusMessage.css.ts +72 -0
- package/src/Playroom/StatusMessage/StatusMessage.tsx +2 -3
- package/src/Playroom/Strong/Strong.css.ts +6 -0
- package/src/Playroom/Strong/Strong.tsx +1 -2
- package/src/Playroom/Text/Text.css.ts +44 -0
- package/src/Playroom/Text/Text.tsx +2 -9
- package/src/Playroom/Toolbar/Toolbar.css.ts +115 -0
- package/src/Playroom/Toolbar/Toolbar.tsx +20 -68
- package/src/Playroom/ToolbarItem/ToolbarItem.css.ts +145 -0
- package/src/Playroom/ToolbarItem/ToolbarItem.tsx +6 -6
- package/src/Playroom/ToolbarPanel/ToolbarPanel.css.ts +5 -0
- package/src/Playroom/ToolbarPanel/ToolbarPanel.tsx +2 -4
- package/src/Playroom/icons/ChevronIcon.css.ts +19 -0
- package/src/Playroom/icons/ChevronIcon.tsx +1 -2
- package/src/Playroom/icons/ColorModeDarkIcon.tsx +14 -0
- package/src/Playroom/icons/ColorModeLightIcon.tsx +22 -0
- package/src/Playroom/icons/ColorModeSystemIcon.tsx +14 -0
- package/src/Playroom/icons/SettingsIcon.tsx +16 -0
- package/src/Playroom/palettes.ts +162 -0
- package/src/Playroom/sprinkles.css.ts +148 -0
- package/src/StoreContext/StoreContext.tsx +49 -4
- package/src/utils/cursor.ts +1 -1
- package/src/utils/formatting.ts +1 -1
- package/src/utils/usePreviewUrl.ts +1 -1
- package/src/Playroom/Button/Button.less +0 -70
- package/src/Playroom/CatchErrors/CatchErrors.js +0 -53
- package/src/Playroom/CatchErrors/CatchErrors.less +0 -11
- package/src/Playroom/CodeEditor/CodeEditor.less +0 -187
- package/src/Playroom/Divider/Divider.less +0 -11
- package/src/Playroom/Frames/Frames.less +0 -69
- package/src/Playroom/FramesPanel/FramesPanel.less +0 -114
- package/src/Playroom/Heading/Heading.less +0 -20
- package/src/Playroom/Inline/Inline.less +0 -58
- package/src/Playroom/Playroom.less +0 -117
- package/src/Playroom/Preview.less +0 -9
- package/src/Playroom/PreviewPanel/ThemeSelector.less +0 -54
- package/src/Playroom/Snippets/SearchField/SearchField.less +0 -18
- package/src/Playroom/Snippets/Snippets.less +0 -65
- package/src/Playroom/SplashScreen/SplashScreen.less +0 -60
- package/src/Playroom/Stack/Stack.less +0 -23
- package/src/Playroom/StatusMessage/StatusMessage.less +0 -53
- package/src/Playroom/Strong/Strong.less +0 -6
- package/src/Playroom/Text/Text.less +0 -36
- package/src/Playroom/Toolbar/Toolbar.less +0 -94
- package/src/Playroom/ToolbarItem/ToolbarItem.less +0 -120
- package/src/Playroom/ToolbarPanel/ToolbarPanel.less +0 -5
- package/src/Playroom/icons/ChevronIcon.less +0 -15
- package/src/Playroom/variables.less +0 -108
package/.babelrc
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<img src="images/logo.png?raw=true" alt="Playroom" title="Playroom" width="292" height="50" />
|
|
1
|
+
<img src="images/logo.png?raw=true#gh-light-mode-only" alt="Playroom" title="Playroom" width="292" height="50" />
|
|
2
|
+
<img src="images/logo-inverted.png?raw=true#gh-dark-mode-only" alt="Playroom" title="Playroom" width="292" height="50" />
|
|
2
3
|
|
|
3
4
|
[](https://www.npmjs.com/package/playroom) [](https://github.com/seek-oss/playroom/actions?query=workflow%3AValidate+branch%3Amaster)
|
|
4
5
|
|
|
@@ -27,6 +28,8 @@ Playroom allows you to create a zero-install code-oriented design environment, b
|
|
|
27
28
|
|
|
28
29
|
[Mesh Design System](https://www.meshdesignsystem.com/playroom/) (Themed)
|
|
29
30
|
|
|
31
|
+
[Mística Design System](https://mistica-web.vercel.app/playroom) (Themed)
|
|
32
|
+
|
|
30
33
|
Send us a PR if you'd like to be in this list!
|
|
31
34
|
|
|
32
35
|
## Getting Started
|
|
Binary file
|
package/lib/getStaticTypes.js
CHANGED
|
@@ -24,7 +24,6 @@ module.exports = async (playroomConfig) => {
|
|
|
24
24
|
} = playroomConfig;
|
|
25
25
|
|
|
26
26
|
const tsConfigPath = await findUp('tsconfig.json', { cwd });
|
|
27
|
-
const basePath = path.dirname(tsConfigPath);
|
|
28
27
|
|
|
29
28
|
if (!tsConfigPath) {
|
|
30
29
|
return {};
|
|
@@ -40,6 +39,7 @@ module.exports = async (playroomConfig) => {
|
|
|
40
39
|
throw error;
|
|
41
40
|
}
|
|
42
41
|
|
|
42
|
+
const basePath = path.dirname(tsConfigPath);
|
|
43
43
|
const { options, errors } = ts.parseJsonConfigFileContent(
|
|
44
44
|
config,
|
|
45
45
|
ts.sys,
|
package/lib/makeWebpackConfig.js
CHANGED
|
@@ -5,6 +5,8 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
5
5
|
const FriendlyErrorsWebpackPlugin = require('@soda/friendly-errors-webpack-plugin');
|
|
6
6
|
const getStaticTypes = require('./getStaticTypes');
|
|
7
7
|
const makeDefaultWebpackConfig = require('./makeDefaultWebpackConfig');
|
|
8
|
+
const { VanillaExtractPlugin } = require('@vanilla-extract/webpack-plugin');
|
|
9
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
8
10
|
|
|
9
11
|
const playroomPath = path.resolve(__dirname, '..');
|
|
10
12
|
const includePaths = [
|
|
@@ -97,34 +99,24 @@ module.exports = async (playroomConfig, options) => {
|
|
|
97
99
|
],
|
|
98
100
|
},
|
|
99
101
|
{
|
|
100
|
-
test: /\.
|
|
101
|
-
include:
|
|
102
|
+
test: /\.vanilla\.css$/i,
|
|
103
|
+
include: playroomPath.includes('node_modules')
|
|
104
|
+
? /node_modules\/playroom/
|
|
105
|
+
: undefined,
|
|
102
106
|
use: [
|
|
103
|
-
|
|
107
|
+
MiniCssExtractPlugin.loader,
|
|
104
108
|
{
|
|
105
109
|
loader: require.resolve('css-loader'),
|
|
106
110
|
options: {
|
|
107
|
-
|
|
108
|
-
mode: 'local',
|
|
109
|
-
localIdentName: '[name]__[local]--[contenthash:base64:5]',
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
loader: require.resolve('postcss-loader'),
|
|
115
|
-
options: {
|
|
116
|
-
postcssOptions: {
|
|
117
|
-
plugins: [require('autoprefixer')()],
|
|
118
|
-
},
|
|
111
|
+
url: false,
|
|
119
112
|
},
|
|
120
113
|
},
|
|
121
|
-
require.resolve('less-loader'),
|
|
122
114
|
],
|
|
123
115
|
},
|
|
124
116
|
{
|
|
125
117
|
test: /\.css$/,
|
|
126
118
|
include: path.dirname(require.resolve('codemirror/package.json')),
|
|
127
|
-
use: [
|
|
119
|
+
use: [MiniCssExtractPlugin.loader, require.resolve('css-loader')],
|
|
128
120
|
},
|
|
129
121
|
],
|
|
130
122
|
},
|
|
@@ -163,6 +155,8 @@ module.exports = async (playroomConfig, options) => {
|
|
|
163
155
|
filename: 'preview/index.html',
|
|
164
156
|
publicPath: '../',
|
|
165
157
|
}),
|
|
158
|
+
new VanillaExtractPlugin(),
|
|
159
|
+
new MiniCssExtractPlugin({ ignoreOrder: true }),
|
|
166
160
|
...(options.production ? [] : [new FriendlyErrorsWebpackPlugin()]),
|
|
167
161
|
],
|
|
168
162
|
devtool: !options.production && 'eval-source-map',
|
package/lib/start.js
CHANGED
|
@@ -37,6 +37,9 @@ module.exports = async (config, callback) => {
|
|
|
37
37
|
// Added to prevent Webpack HMR from breaking when iframeSandbox option is used
|
|
38
38
|
// See: https://github.com/webpack/webpack-dev-server/issues/1604
|
|
39
39
|
allowedHosts: 'all',
|
|
40
|
+
headers: {
|
|
41
|
+
'Access-Control-Allow-Origin': '*',
|
|
42
|
+
},
|
|
40
43
|
};
|
|
41
44
|
|
|
42
45
|
const compiler = webpack(webpackConfig);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playroom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Design with code, powered by your own component library",
|
|
5
5
|
"main": "utils/index.js",
|
|
6
6
|
"types": "utils/index.d.ts",
|
|
@@ -77,7 +77,11 @@
|
|
|
77
77
|
"@types/prettier": "^2.2.3",
|
|
78
78
|
"@types/react": "^17.0.3",
|
|
79
79
|
"@types/react-dom": "^17.0.2",
|
|
80
|
-
"
|
|
80
|
+
"@vanilla-extract/babel-plugin": "^1.1.5",
|
|
81
|
+
"@vanilla-extract/css": "^1.7.0",
|
|
82
|
+
"@vanilla-extract/css-utils": "^0.1.2",
|
|
83
|
+
"@vanilla-extract/sprinkles": "^1.4.0",
|
|
84
|
+
"@vanilla-extract/webpack-plugin": "^2.1.8",
|
|
81
85
|
"babel-loader": "^8.2.2",
|
|
82
86
|
"classnames": "^2.3.1",
|
|
83
87
|
"codemirror": "^5.59.4",
|
|
@@ -93,16 +97,14 @@
|
|
|
93
97
|
"history": "^5.0.0",
|
|
94
98
|
"html-webpack-plugin": "^5.3.1",
|
|
95
99
|
"intersection-observer": "^0.12.0",
|
|
96
|
-
"less": "^4.1.1",
|
|
97
|
-
"less-loader": "^8.0.0",
|
|
98
|
-
"less-vars-loader": "^1.1.0",
|
|
99
100
|
"localforage": "^1.9.0",
|
|
100
101
|
"locate-path": "^6.0.0",
|
|
101
102
|
"lodash": "^4.17.21",
|
|
102
103
|
"lz-string": "^1.4.4",
|
|
104
|
+
"mini-css-extract-plugin": "^2.6.0",
|
|
103
105
|
"parse-prop-types": "^0.3.0",
|
|
106
|
+
"polished": "^4.1.4",
|
|
104
107
|
"portfinder": "^1.0.28",
|
|
105
|
-
"postcss-loader": "^5.2.0",
|
|
106
108
|
"prettier": "^2.2.1",
|
|
107
109
|
"prop-types": "^15.7.2",
|
|
108
110
|
"query-string": "^6.14.1",
|
|
@@ -112,7 +114,6 @@
|
|
|
112
114
|
"react-use": "^17.2.1",
|
|
113
115
|
"read-pkg-up": "^7.0.1",
|
|
114
116
|
"scope-eval": "^1.0.0",
|
|
115
|
-
"style-loader": "^3.2.1",
|
|
116
117
|
"typescript": "^4.3.2",
|
|
117
118
|
"url-join": "^4.0.1",
|
|
118
119
|
"use-debounce": "^3.3.0",
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { style, createVar } from '@vanilla-extract/css';
|
|
2
|
+
import { calc } from '@vanilla-extract/css-utils';
|
|
3
|
+
import { sprinkles, vars, colorPaletteVars } from '../sprinkles.css';
|
|
4
|
+
|
|
5
|
+
export const reset = style([
|
|
6
|
+
sprinkles({
|
|
7
|
+
boxSizing: 'border-box',
|
|
8
|
+
border: 0,
|
|
9
|
+
margin: 'none',
|
|
10
|
+
padding: 'none',
|
|
11
|
+
appearance: 'none',
|
|
12
|
+
userSelect: 'none',
|
|
13
|
+
position: 'relative',
|
|
14
|
+
cursor: 'pointer',
|
|
15
|
+
display: 'flex',
|
|
16
|
+
placeItems: 'center',
|
|
17
|
+
}),
|
|
18
|
+
{
|
|
19
|
+
background: 'transparent',
|
|
20
|
+
outline: 'none',
|
|
21
|
+
textDecoration: 'none',
|
|
22
|
+
whiteSpace: 'nowrap',
|
|
23
|
+
textOverflow: 'ellipsis',
|
|
24
|
+
height: vars.touchableSize,
|
|
25
|
+
WebkitTapHighlightColor: 'transparent',
|
|
26
|
+
},
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
const highlightColor = createVar();
|
|
30
|
+
|
|
31
|
+
export const base = style([
|
|
32
|
+
sprinkles({
|
|
33
|
+
borderRadius: 'large',
|
|
34
|
+
paddingY: 'none',
|
|
35
|
+
paddingX: 'large',
|
|
36
|
+
font: 'standard',
|
|
37
|
+
}),
|
|
38
|
+
{
|
|
39
|
+
vars: {
|
|
40
|
+
[highlightColor]: 'currentColor',
|
|
41
|
+
},
|
|
42
|
+
color: highlightColor,
|
|
43
|
+
border: `1px solid ${colorPaletteVars.foreground.neutralSoft}`,
|
|
44
|
+
height: calc(vars.grid).multiply(9).toString(),
|
|
45
|
+
':hover': {
|
|
46
|
+
vars: {
|
|
47
|
+
[highlightColor]: colorPaletteVars.foreground.accent,
|
|
48
|
+
},
|
|
49
|
+
borderColor: highlightColor,
|
|
50
|
+
},
|
|
51
|
+
':active': {
|
|
52
|
+
transform: 'scale(0.98)',
|
|
53
|
+
},
|
|
54
|
+
'::after': {
|
|
55
|
+
content: '',
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
transform: 'translateY(-50%)',
|
|
58
|
+
minHeight: vars.touchableSize,
|
|
59
|
+
minWidth: vars.touchableSize,
|
|
60
|
+
left: calc(vars.grid).multiply(2).negate().toString(),
|
|
61
|
+
right: calc(vars.grid).multiply(2).negate().toString(),
|
|
62
|
+
height: '100%',
|
|
63
|
+
top: '50%',
|
|
64
|
+
},
|
|
65
|
+
selectors: {
|
|
66
|
+
[`&:focus:not(:active):not(:hover):not([disabled])`]: {
|
|
67
|
+
boxShadow: colorPaletteVars.shadows.focus,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
]);
|
|
72
|
+
|
|
73
|
+
export const positive = style({
|
|
74
|
+
vars: {
|
|
75
|
+
[highlightColor]: `${colorPaletteVars.foreground.positive} !important`,
|
|
76
|
+
},
|
|
77
|
+
borderColor: highlightColor,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export const iconContainer = style([
|
|
81
|
+
sprinkles({ position: 'relative', paddingLeft: 'medium' }),
|
|
82
|
+
{
|
|
83
|
+
top: '1px',
|
|
84
|
+
},
|
|
85
|
+
]);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React, { ElementType, AllHTMLAttributes, ReactElement } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import styles from './Button.less';
|
|
4
|
+
import * as styles from './Button.css';
|
|
6
5
|
|
|
7
6
|
interface BaseProps {
|
|
8
7
|
as?: ElementType;
|
|
@@ -32,6 +31,7 @@ export const Button = ({
|
|
|
32
31
|
className={classnames(styles.reset, styles.base, {
|
|
33
32
|
[styles.positive]: tone === 'positive',
|
|
34
33
|
})}
|
|
34
|
+
disabled={tone === 'positive'}
|
|
35
35
|
{...props}
|
|
36
36
|
>
|
|
37
37
|
{children}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { Component, ErrorInfo, ReactNode } from 'react';
|
|
2
|
+
import { Text } from '../Text/Text';
|
|
3
|
+
import { Strong } from '../Strong/Strong';
|
|
4
|
+
|
|
5
|
+
import * as styles from './CatchErrors.css';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
code?: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
interface State {
|
|
12
|
+
invalidCode: string | null;
|
|
13
|
+
error: Error | null;
|
|
14
|
+
errorInfo: ErrorInfo | null;
|
|
15
|
+
}
|
|
16
|
+
export default class CatchErrors extends Component<Props, State> {
|
|
17
|
+
state: State = {
|
|
18
|
+
error: null,
|
|
19
|
+
invalidCode: null,
|
|
20
|
+
errorInfo: null,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
24
|
+
const { code = null } = this.props;
|
|
25
|
+
this.setState({ invalidCode: code, error, errorInfo });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
render() {
|
|
29
|
+
const { invalidCode, error, errorInfo } = this.state;
|
|
30
|
+
const { code, children } = this.props;
|
|
31
|
+
|
|
32
|
+
if (code !== invalidCode || !error) {
|
|
33
|
+
return children;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Ensure the stack only contains user-provided components
|
|
37
|
+
const componentStack = errorInfo
|
|
38
|
+
? errorInfo.componentStack
|
|
39
|
+
.split('\n')
|
|
40
|
+
.filter((line: string) => /RenderCode/.test(line))
|
|
41
|
+
.map((line: string) => line.replace(/ \(created by .*/g, ''))
|
|
42
|
+
: [];
|
|
43
|
+
|
|
44
|
+
// Ignore the RenderCode container component
|
|
45
|
+
const lines = componentStack.slice(0, componentStack.length - 1);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className={styles.root}>
|
|
49
|
+
<Text size="large" tone="critical">
|
|
50
|
+
<Strong>{error.message}</Strong>
|
|
51
|
+
{lines.map((line, i) => (
|
|
52
|
+
<span key={i}>{line}</span>
|
|
53
|
+
))}
|
|
54
|
+
</Text>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { style, globalStyle, keyframes } from '@vanilla-extract/css';
|
|
2
|
+
import { vars, colorPaletteVars, sprinkles } from '../sprinkles.css';
|
|
3
|
+
|
|
4
|
+
const minimumLineNumberWidth = '50px';
|
|
5
|
+
|
|
6
|
+
export const insertionPoint = style({
|
|
7
|
+
backgroundColor: colorPaletteVars.background.selection,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const fadeIn = keyframes({
|
|
11
|
+
'90%': {
|
|
12
|
+
opacity: 0,
|
|
13
|
+
},
|
|
14
|
+
'100%': {
|
|
15
|
+
opacity: 1,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export const errorMarker = style([
|
|
19
|
+
sprinkles({
|
|
20
|
+
borderRadius: 'large',
|
|
21
|
+
position: 'relative',
|
|
22
|
+
textAlign: 'right',
|
|
23
|
+
opacity: 0,
|
|
24
|
+
}),
|
|
25
|
+
{
|
|
26
|
+
backgroundColor: colorPaletteVars.background.critical,
|
|
27
|
+
color: colorPaletteVars.foreground.critical,
|
|
28
|
+
minWidth: minimumLineNumberWidth,
|
|
29
|
+
marginRight: '4px',
|
|
30
|
+
paddingRight: '8px',
|
|
31
|
+
animationName: fadeIn,
|
|
32
|
+
animationDuration: '1s',
|
|
33
|
+
animationTimingFunction: 'ease',
|
|
34
|
+
animationIterationCount: 1,
|
|
35
|
+
animationFillMode: 'forwards',
|
|
36
|
+
},
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
export const foldGutter = style({
|
|
40
|
+
width: '1em',
|
|
41
|
+
padding: '0 8px',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const foldOpen = style([
|
|
45
|
+
sprinkles({ cursor: 'pointer' }),
|
|
46
|
+
{
|
|
47
|
+
'::after': {
|
|
48
|
+
content: '-',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
export const foldFolded = style([
|
|
54
|
+
sprinkles({ cursor: 'pointer' }),
|
|
55
|
+
{
|
|
56
|
+
'::after': {
|
|
57
|
+
content: '+',
|
|
58
|
+
color: colorPaletteVars.foreground.accent,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
]);
|
|
62
|
+
|
|
63
|
+
globalStyle('.react-codemirror2', {
|
|
64
|
+
height: '100%',
|
|
65
|
+
backgroundColor: colorPaletteVars.background.surface,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
globalStyle('.CodeMirror', {
|
|
69
|
+
height: '100%',
|
|
70
|
+
width: '100%',
|
|
71
|
+
fontFamily: vars.font.family.code,
|
|
72
|
+
position: 'relative',
|
|
73
|
+
zIndex: 0,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
globalStyle('.CodeMirror-gutters', {
|
|
77
|
+
minWidth: vars.codeGutterSize,
|
|
78
|
+
boxSizing: 'border-box',
|
|
79
|
+
paddingLeft: '8px',
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
globalStyle('.CodeMirror pre, .CodeMirror-linenumber', {
|
|
83
|
+
fontSize: '16px',
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
globalStyle('.CodeMirror-lines', {
|
|
87
|
+
padding: '16px 0',
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
globalStyle('.CodeMirror-hints', {
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
zIndex: 10,
|
|
93
|
+
overflow: 'hidden',
|
|
94
|
+
listStyle: 'none',
|
|
95
|
+
margin: 0,
|
|
96
|
+
padding: 0,
|
|
97
|
+
boxShadow: colorPaletteVars.shadows.small,
|
|
98
|
+
borderRadius: vars.radii.medium,
|
|
99
|
+
backgroundColor: colorPaletteVars.background.surface,
|
|
100
|
+
fontSize: '90%',
|
|
101
|
+
lineHeight: '150%',
|
|
102
|
+
fontFamily: vars.font.family.code,
|
|
103
|
+
maxHeight: '20em',
|
|
104
|
+
overflowY: 'auto',
|
|
105
|
+
});
|
|
106
|
+
globalStyle('[data-playroom-dark] .CodeMirror-hints', {
|
|
107
|
+
backgroundColor: colorPaletteVars.background.neutral,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
globalStyle('.CodeMirror-hint', {
|
|
111
|
+
margin: 0,
|
|
112
|
+
padding: '4px 8px',
|
|
113
|
+
borderRadius: vars.radii.small,
|
|
114
|
+
whiteSpace: 'pre',
|
|
115
|
+
color: colorPaletteVars.code.text,
|
|
116
|
+
cursor: 'pointer',
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
globalStyle('li.CodeMirror-hint-active', {
|
|
120
|
+
backgroundColor: colorPaletteVars.background.accent,
|
|
121
|
+
color: colorPaletteVars.foreground.neutralInverted,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
globalStyle('.CodeMirror-linenumbers', {
|
|
125
|
+
minWidth: minimumLineNumberWidth,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
globalStyle('.CodeMirror-foldmarker', {
|
|
129
|
+
color: colorPaletteVars.foreground.accent,
|
|
130
|
+
fontFamily: 'arial',
|
|
131
|
+
cursor: 'pointer',
|
|
132
|
+
padding: `0 ${vars.grid}`,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
globalStyle('.cm-s-neo.CodeMirror', {
|
|
136
|
+
backgroundColor: colorPaletteVars.background.surface,
|
|
137
|
+
color: colorPaletteVars.code.text,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
globalStyle('.cm-s-neo .CodeMirror-cursor', {
|
|
141
|
+
backgroundColor: colorPaletteVars.foreground.neutral,
|
|
142
|
+
width: '2px',
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
globalStyle('.cm-s-neo .CodeMirror-gutters', {
|
|
146
|
+
backgroundColor: colorPaletteVars.background.surface,
|
|
147
|
+
border: 'none',
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
globalStyle('.cm-s-neo .CodeMirror-gutters::after', {
|
|
151
|
+
content: '""',
|
|
152
|
+
backgroundColor: colorPaletteVars.background.surface,
|
|
153
|
+
position: 'absolute',
|
|
154
|
+
right: '2px',
|
|
155
|
+
height: '100%',
|
|
156
|
+
boxShadow: `0 0 10px 5px ${colorPaletteVars.background.surface}`,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
globalStyle('.cm-s-neo .CodeMirror-selected', {
|
|
160
|
+
background: colorPaletteVars.background.selection,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
globalStyle('.cm-s-neo .CodeMirror-activeline-background', {
|
|
164
|
+
background: 'transparent',
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
globalStyle('.cm-s-neo .CodeMirror-guttermarker-subtle', {
|
|
168
|
+
display: 'flex',
|
|
169
|
+
justifyContent: 'center',
|
|
170
|
+
color: colorPaletteVars.foreground.neutral,
|
|
171
|
+
transition: vars.transition.fast,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
globalStyle(
|
|
175
|
+
`.cm-s-neo .CodeMirror-guttermarker-subtle:not(:hover):not(${foldFolded})`,
|
|
176
|
+
{
|
|
177
|
+
color: colorPaletteVars.foreground.neutralSoft,
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
globalStyle('.cm-s-neo .CodeMirror-linenumber', {
|
|
182
|
+
minWidth: minimumLineNumberWidth,
|
|
183
|
+
color: colorPaletteVars.foreground.neutral,
|
|
184
|
+
transition: vars.transition.fast,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
globalStyle(
|
|
188
|
+
'.cm-s-neo .CodeMirror-linenumber:not(:hover):not(.cm-s-neo .CodeMirror-activeline .CodeMirror-linenumber)',
|
|
189
|
+
{
|
|
190
|
+
color: colorPaletteVars.foreground.neutralSoft,
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
globalStyle('.cm-s-neo .cm-tag', {
|
|
195
|
+
color: colorPaletteVars.code.tag,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
globalStyle(
|
|
199
|
+
[
|
|
200
|
+
'.cm-s-neo .cm-attribute',
|
|
201
|
+
'.cm-s-neo .cm-keyword',
|
|
202
|
+
'.cm-s-neo .cm-property',
|
|
203
|
+
].join(','),
|
|
204
|
+
{
|
|
205
|
+
color: colorPaletteVars.code.attribute,
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
globalStyle('.cm-s-neo .cm-string', {
|
|
210
|
+
color: colorPaletteVars.code.string,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
globalStyle('.cm-s-neo .cm-atom', {
|
|
214
|
+
color: colorPaletteVars.code.atom,
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
globalStyle('.cm-s-neo .cm-variable', {
|
|
218
|
+
color: colorPaletteVars.code.variable,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
globalStyle('.cm-s-neo .cm-number', {
|
|
222
|
+
color: colorPaletteVars.code.number,
|
|
223
|
+
});
|
|
@@ -8,8 +8,7 @@ import { StoreContext, CursorPosition } from '../../StoreContext/StoreContext';
|
|
|
8
8
|
import { formatCode as format } from '../../utils/formatting';
|
|
9
9
|
import { compileJsx } from '../../utils/compileJsx';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
import styles from './CodeEditor.less';
|
|
11
|
+
import * as styles from './CodeEditor.css';
|
|
13
12
|
|
|
14
13
|
import { UnControlled as ReactCodeMirror } from 'react-codemirror2';
|
|
15
14
|
import 'codemirror/mode/jsx/jsx';
|
|
@@ -79,7 +78,7 @@ const validateCode = (editorInstance: Editor, code: string) => {
|
|
|
79
78
|
|
|
80
79
|
if (lineNumber) {
|
|
81
80
|
const marker = document.createElement('div');
|
|
82
|
-
marker.
|
|
81
|
+
marker.setAttribute('class', styles.errorMarker);
|
|
83
82
|
marker.setAttribute(
|
|
84
83
|
'title',
|
|
85
84
|
// Remove our wrapping Fragment from error message
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { style } from '@vanilla-extract/css';
|
|
2
|
+
import { sprinkles, colorPaletteVars } from '../sprinkles.css';
|
|
3
|
+
|
|
4
|
+
export const root = sprinkles({
|
|
5
|
+
position: 'relative',
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const divider = style([
|
|
9
|
+
sprinkles({
|
|
10
|
+
position: 'absolute',
|
|
11
|
+
width: 'full',
|
|
12
|
+
}),
|
|
13
|
+
{
|
|
14
|
+
borderTop: `1px solid ${colorPaletteVars.border.standard}`,
|
|
15
|
+
},
|
|
16
|
+
]);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { style } from '@vanilla-extract/css';
|
|
2
|
+
import { sprinkles } from '../sprinkles.css';
|
|
3
|
+
|
|
4
|
+
export const root = style([
|
|
5
|
+
sprinkles({
|
|
6
|
+
height: 'full',
|
|
7
|
+
width: 'full',
|
|
8
|
+
whiteSpace: 'nowrap',
|
|
9
|
+
display: 'flex',
|
|
10
|
+
boxSizing: 'border-box',
|
|
11
|
+
paddingY: 'gutter',
|
|
12
|
+
paddingLeft: 'gutter',
|
|
13
|
+
textAlign: 'center',
|
|
14
|
+
}),
|
|
15
|
+
{
|
|
16
|
+
overflowX: 'auto',
|
|
17
|
+
overflowY: 'hidden',
|
|
18
|
+
// // Simulate centering when fewer frames than viewport width.
|
|
19
|
+
'::before': {
|
|
20
|
+
content: '""',
|
|
21
|
+
flex: 1,
|
|
22
|
+
},
|
|
23
|
+
'::after': {
|
|
24
|
+
content: '""',
|
|
25
|
+
flex: 1,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
export const frameContainer = style([
|
|
31
|
+
sprinkles({
|
|
32
|
+
position: 'relative',
|
|
33
|
+
height: 'full',
|
|
34
|
+
textAlign: 'left',
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flexDirection: 'column',
|
|
37
|
+
paddingRight: 'gutter',
|
|
38
|
+
}),
|
|
39
|
+
{},
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
export const frame = style([
|
|
43
|
+
sprinkles({ position: 'relative', height: 'full', border: 0 }),
|
|
44
|
+
{
|
|
45
|
+
flexGrow: 1,
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
export const frameBorder = style([
|
|
50
|
+
sprinkles({
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
inset: 0,
|
|
53
|
+
boxShadow: 'small',
|
|
54
|
+
transition: 'medium',
|
|
55
|
+
pointerEvents: 'none',
|
|
56
|
+
}),
|
|
57
|
+
{
|
|
58
|
+
selectors: {
|
|
59
|
+
[`&:not(:hover)`]: {
|
|
60
|
+
opacity: 0.8,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
const frameNameHeight = '30px';
|
|
67
|
+
export const frameName = style([
|
|
68
|
+
sprinkles({
|
|
69
|
+
display: 'flex',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
transition: 'medium',
|
|
72
|
+
}),
|
|
73
|
+
{
|
|
74
|
+
flex: `0 0 ${frameNameHeight}`,
|
|
75
|
+
height: frameNameHeight,
|
|
76
|
+
marginBottom: '-10px',
|
|
77
|
+
selectors: {
|
|
78
|
+
[`${frameContainer}:not(:hover) &`]: {
|
|
79
|
+
opacity: 0.3,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
]);
|