playroom 0.44.0 → 0.44.1
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/CHANGELOG.md +48 -12
- package/dist/index.d.mts +1 -4
- package/dist/index.d.ts +1 -2
- package/lib/makeWebpackConfig.js +3 -3
- package/package.json +1 -2
- package/src/{Playroom → components}/Box/Box.tsx +1 -1
- package/src/{Playroom → components}/Button/Button.css.ts +7 -11
- package/src/{Playroom → components}/CodeEditor/CodeEditor.css.ts +32 -27
- package/src/{Playroom → components}/CodeEditor/CodeEditor.tsx +15 -20
- package/src/{Playroom → components}/Frame/Frame.tsx +3 -5
- package/src/{Playroom → components}/Frame/FrameError.css.ts +8 -8
- package/src/{Playroom → components}/Frames/Frames.css.ts +3 -3
- package/src/{Playroom → components}/Frames/Frames.tsx +10 -5
- package/src/{Playroom → components}/FramesPanel/FramesPanel.css.ts +11 -10
- package/src/{Playroom → components}/FramesPanel/FramesPanel.tsx +9 -13
- package/src/{Playroom → components}/Heading/Heading.css.ts +2 -6
- package/src/{Playroom → components}/Heading/Heading.tsx +1 -3
- package/src/{Playroom → components}/Inline/Inline.css.ts +1 -1
- package/src/components/Playroom/Playroom.css.ts +171 -0
- package/src/components/Playroom/Playroom.tsx +178 -0
- package/src/components/Playroom/ResizeHandle.css.ts +73 -0
- package/src/components/Playroom/ResizeHandle.tsx +96 -0
- package/src/{Playroom → components}/Preview/PreviewError.tsx +1 -1
- package/src/{Playroom → components}/Preview/SplashScreen/SplashScreen.css.ts +2 -2
- package/src/{Playroom → components}/PreviewPanel/PreviewPanel.tsx +11 -11
- package/src/{Playroom → components}/PreviewPanel/ThemeSelector.css.ts +2 -2
- package/src/{Playroom → components}/PreviewPanel/ThemeSelector.tsx +3 -4
- package/src/components/RenderCode/RenderCode.tsx +50 -0
- package/src/{Playroom → components}/SettingsPanel/SettingsPanel.css.ts +7 -9
- package/src/{Playroom → components}/SettingsPanel/SettingsPanel.tsx +8 -10
- package/src/{Playroom → components}/Snippets/SearchField/SearchField.css.ts +3 -3
- package/src/{Playroom → components}/Snippets/Snippets.css.ts +7 -7
- package/src/{Playroom → components}/Snippets/Snippets.tsx +5 -8
- package/src/{Playroom → components}/Stack/Stack.css.ts +1 -1
- package/src/{Playroom → components}/StatusMessage/StatusMessage.css.ts +6 -6
- package/src/{Playroom → components}/StatusMessage/StatusMessage.tsx +1 -1
- package/src/{Playroom → components}/Strong/Strong.css.ts +1 -1
- package/src/{Playroom → components}/Text/Text.css.ts +1 -1
- package/src/{Playroom → components}/Toolbar/Toolbar.css.ts +2 -2
- package/src/{Playroom → components}/Toolbar/Toolbar.tsx +7 -21
- package/src/{Playroom → components}/ToolbarItem/ToolbarItem.css.ts +2 -2
- package/src/components/ToolbarPanel/ToolbarPanel.css.ts +5 -0
- package/src/{Playroom → components}/constants.ts +1 -1
- package/src/{Playroom → components}/icons/ChevronIcon.css.ts +1 -1
- package/src/configModules/components.ts +9 -0
- package/src/{themes.ts → configModules/themes.ts} +2 -0
- package/src/configModules/useScope.ts +33 -0
- package/src/configModules/widths.ts +8 -0
- package/src/{StoreContext → contexts}/StoreContext.tsx +222 -254
- package/src/css/delimiters.ts +3 -0
- package/src/{Playroom → css}/palettes.ts +1 -1
- package/src/{Playroom → css}/sprinkles.css.ts +2 -2
- package/src/{Playroom → css}/vars.css.ts +12 -14
- package/src/entries/frame.tsx +18 -0
- package/src/entries/index.tsx +21 -0
- package/src/entries/preview.tsx +34 -0
- package/src/utils/componentsToHints.ts +47 -39
- package/src/utils/cursor.ts +1 -1
- package/src/utils/formatting.ts +1 -1
- package/src/utils/params.ts +1 -2
- package/src/utils/usePreviewUrl.ts +1 -1
- package/utils/index.ts +1 -1
- package/src/Playroom/Playroom.css.ts +0 -175
- package/src/Playroom/Playroom.tsx +0 -270
- package/src/Playroom/RenderCode/RenderCode.tsx +0 -90
- package/src/Playroom/ToolbarPanel/ToolbarPanel.css.ts +0 -5
- package/src/Playroom/WindowPortal/index.tsx +0 -113
- package/src/Playroom/icons/EditorUndockedIcon.tsx +0 -15
- package/src/components.ts +0 -4
- package/src/frame.tsx +0 -48
- package/src/index.tsx +0 -66
- package/src/preview.tsx +0 -65
- package/src/useScope.ts +0 -1
- package/src/utils/hmr.ts +0 -10
- /package/src/{Playroom → components}/Button/Button.tsx +0 -0
- /package/src/{Playroom → components}/CodeEditor/CodeMirror2.tsx +0 -0
- /package/src/{Playroom → components}/CodeEditor/keymaps/comment.ts +0 -0
- /package/src/{Playroom → components}/CodeEditor/keymaps/complete.ts +0 -0
- /package/src/{Playroom → components}/CodeEditor/keymaps/cursors.ts +0 -0
- /package/src/{Playroom → components}/CodeEditor/keymaps/lines.ts +0 -0
- /package/src/{Playroom → components}/CodeEditor/keymaps/types.ts +0 -0
- /package/src/{Playroom → components}/CodeEditor/keymaps/wrap.ts +0 -0
- /package/src/{Playroom → components}/Frame/FrameError.tsx +0 -0
- /package/src/{Playroom → components}/Frame/frameMessaging.tsx +0 -0
- /package/src/{Playroom → components}/Frames/Iframe.tsx +0 -0
- /package/src/{Playroom → components}/Frames/frameSrc.ts +0 -0
- /package/src/{Playroom → components}/FramesPanel/CheckmarkSvg.tsx +0 -0
- /package/src/{Playroom → components}/Inline/Inline.tsx +0 -0
- /package/src/{Playroom → components}/Logo/Logo.tsx +0 -0
- /package/src/{Playroom → components}/Preview/Preview.tsx +0 -0
- /package/src/{Playroom → components}/Preview/SplashScreen/SplashScreen.tsx +0 -0
- /package/src/{Playroom → components}/PreviewPanel/CopyButton.tsx +0 -0
- /package/src/{Playroom → components}/Snippets/SearchField/SearchField.tsx +0 -0
- /package/src/{Playroom → components}/Stack/Stack.tsx +0 -0
- /package/src/{Playroom → components}/Strong/Strong.tsx +0 -0
- /package/src/{Playroom → components}/Text/Text.tsx +0 -0
- /package/src/{Playroom → components}/ToolbarItem/ToolbarItem.tsx +0 -0
- /package/src/{Playroom → components}/ToolbarPanel/ToolbarPanel.tsx +0 -0
- /package/src/{Playroom → components}/icons/AddIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/ChevronIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/ColorModeDarkIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/ColorModeLightIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/ColorModeSystemIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/DismissIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/EditorBottomIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/EditorRightIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/FramesIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/PlayIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/SettingsIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/ShareIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/ThemesIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/TickIcon.tsx +0 -0
- /package/src/{Playroom → components}/icons/WidthsIcon.tsx +0 -0
- /package/src/{playroomModuleAliases.d.ts → configModules/configModules.d.ts} +0 -0
- /package/src/{frameComponent.ts → configModules/frameComponent.ts} +0 -0
- /package/src/{snippets.ts → configModules/snippets.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,57 @@
|
|
|
1
1
|
# playroom
|
|
2
2
|
|
|
3
|
+
## 0.44.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#426](https://github.com/seek-oss/playroom/pull/426) [`934992c`](https://github.com/seek-oss/playroom/commit/934992c6c9bb1b265375996e3971cc58a22ef3b3) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - refactor: Improve internal structure enable UI flexibility
|
|
8
|
+
|
|
9
|
+
- [#435](https://github.com/seek-oss/playroom/pull/435) [`f1f7869`](https://github.com/seek-oss/playroom/commit/f1f7869605640886a514f9511e10504c0ebe7a7d) Thanks [@felixhabib](https://github.com/felixhabib)! - Ensure UI size adapts to mobile browser toolbars that appear and disappear.
|
|
10
|
+
|
|
11
|
+
Use dynamic viewport units to ensure the UI remains responsive across different devices.
|
|
12
|
+
|
|
13
|
+
- [#439](https://github.com/seek-oss/playroom/pull/439) [`61654dc`](https://github.com/seek-oss/playroom/commit/61654dc133809d7b5aafebfd70479dac4d84e62f) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - Migrate top-level layout to CSS Grid
|
|
14
|
+
|
|
15
|
+
Refactor the top-level layout of Playroom to use CSS Grid in preparation for upcoming UI features.
|
|
16
|
+
|
|
17
|
+
Additionally, migrate away from `re-resizable` package for panel resizing in favour of a custom implementation to improve UI performance.
|
|
18
|
+
|
|
19
|
+
- [#438](https://github.com/seek-oss/playroom/pull/438) [`4ae409a`](https://github.com/seek-oss/playroom/commit/4ae409a96332fbbefb8fdaf89fb3760017dcc87d) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - Remove legacy undocked editor mode
|
|
20
|
+
|
|
21
|
+
An earlier version of Playroom had support for an undocked editor mode, previously hidden from the UI due to being buggy.
|
|
22
|
+
Removing this code in preparation for UI uplift work.
|
|
23
|
+
|
|
24
|
+
- [#440](https://github.com/seek-oss/playroom/pull/440) [`a3e9893`](https://github.com/seek-oss/playroom/commit/a3e9893183830f3c23e46240af89edb256a9a9b1) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - Refactor internal space and radius tokens
|
|
25
|
+
|
|
26
|
+
Evolve the internal space and radius scales to be more fit for purpose with upcoming UI work.
|
|
27
|
+
|
|
3
28
|
## 0.44.0
|
|
4
29
|
|
|
5
30
|
### Minor Changes
|
|
6
31
|
|
|
32
|
+
- [#421](https://github.com/seek-oss/playroom/pull/421) [`6fd2aab`](https://github.com/seek-oss/playroom/commit/6fd2aabd4cb910972d9280a4707af361d35926ec) Thanks [@askoufis](https://github.com/askoufis)! - Playroom's utility API is now bundled for both ESM and CJS
|
|
33
|
+
|
|
34
|
+
**BREAKING CHANGE:**
|
|
35
|
+
|
|
36
|
+
Migrating the utils entries to TypeScript has necessitated an internal build step to produce both ESM and CJS versions.
|
|
37
|
+
As a result, these APIs are now exposed as named exports at the top level of the `playroom` package.
|
|
38
|
+
|
|
39
|
+
**MIGRATION GUIDE:**
|
|
40
|
+
|
|
41
|
+
For ESM imports:
|
|
42
|
+
|
|
43
|
+
```diff
|
|
44
|
+
-import { createUrl } from 'playroom/utils';
|
|
45
|
+
+import { createUrl } from 'playroom';
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
or for CJS usage:
|
|
49
|
+
|
|
50
|
+
```diff
|
|
51
|
+
-const { createUrl } = require('playroom/utils');
|
|
52
|
+
+const { createUrl } = require('playroom');
|
|
53
|
+
```
|
|
54
|
+
|
|
7
55
|
- [#417](https://github.com/seek-oss/playroom/pull/417) [`03d145d`](https://github.com/seek-oss/playroom/commit/03d145d755d9f431df632618604a807fcf181d21) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - Improved handling of rendering errors
|
|
8
56
|
|
|
9
57
|
Errors occurring during render no longer replace the frame contents with a red error message.
|
|
@@ -24,18 +72,6 @@
|
|
|
24
72
|
|
|
25
73
|
### Patch Changes
|
|
26
74
|
|
|
27
|
-
- [#421](https://github.com/seek-oss/playroom/pull/421) [`6fd2aab`](https://github.com/seek-oss/playroom/commit/6fd2aabd4cb910972d9280a4707af361d35926ec) Thanks [@askoufis](https://github.com/askoufis)! - Playroom's utility API is now bundled for both ESM and CJS
|
|
28
|
-
|
|
29
|
-
**EXAMPLE USAGE:**
|
|
30
|
-
|
|
31
|
-
```js
|
|
32
|
-
// ESM import
|
|
33
|
-
import { createUrl } from 'playroom';
|
|
34
|
-
|
|
35
|
-
// CJS require
|
|
36
|
-
const { createUrl } = require('playroom');
|
|
37
|
-
```
|
|
38
|
-
|
|
39
75
|
- [#424](https://github.com/seek-oss/playroom/pull/424) [`8795fde`](https://github.com/seek-oss/playroom/commit/8795fdeab1383886bc1adfdf417b600391a512ba) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - Use `clsx` consistently for building class lists
|
|
40
76
|
|
|
41
77
|
Remove `classnames` in favor of `clsx` for building class lists in the Playroom codebase.
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/lib/makeWebpackConfig.js
CHANGED
|
@@ -26,9 +26,9 @@ module.exports = async (playroomConfig, options) => {
|
|
|
26
26
|
const ourConfig = {
|
|
27
27
|
mode: options.production ? 'production' : 'development',
|
|
28
28
|
entry: {
|
|
29
|
-
index: [require.resolve('../src/index.tsx')],
|
|
30
|
-
frame: [require.resolve('../src/frame.tsx')],
|
|
31
|
-
preview: [require.resolve('../src/preview.tsx')],
|
|
29
|
+
index: [require.resolve('../src/entries/index.tsx')],
|
|
30
|
+
frame: [require.resolve('../src/entries/frame.tsx')],
|
|
31
|
+
preview: [require.resolve('../src/entries/preview.tsx')],
|
|
32
32
|
},
|
|
33
33
|
output: {
|
|
34
34
|
filename: '[name].[contenthash].js',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playroom",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.1",
|
|
4
4
|
"description": "Design with code, powered by your own component library",
|
|
5
5
|
"bin": {
|
|
6
6
|
"playroom": "bin/cli.cjs"
|
|
@@ -79,7 +79,6 @@
|
|
|
79
79
|
"portfinder": "^1.0.32",
|
|
80
80
|
"prettier": "^2.8.1",
|
|
81
81
|
"prop-types": "^15.8.1",
|
|
82
|
-
"re-resizable": "^6.11.2",
|
|
83
82
|
"react-docgen-typescript": "^2.2.2",
|
|
84
83
|
"react-error-boundary": "^4.0.13",
|
|
85
84
|
"react-helmet": "^6.1.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import clsx, { type ClassValue } from 'clsx';
|
|
2
2
|
import { forwardRef, type AllHTMLAttributes, type ElementType } from 'react';
|
|
3
3
|
|
|
4
|
-
import { sprinkles, type Sprinkles } from '
|
|
4
|
+
import { sprinkles, type Sprinkles } from '../../css/sprinkles.css';
|
|
5
5
|
|
|
6
6
|
interface BoxProps
|
|
7
7
|
extends Omit<
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { style, createVar } from '@vanilla-extract/css';
|
|
2
|
-
import { calc } from '@vanilla-extract/css-utils';
|
|
3
2
|
|
|
4
|
-
import { sprinkles, colorPaletteVars } from '
|
|
5
|
-
import { vars } from '
|
|
3
|
+
import { sprinkles, colorPaletteVars } from '../../css/sprinkles.css';
|
|
4
|
+
import { vars } from '../../css/vars.css';
|
|
6
5
|
|
|
7
6
|
export const reset = style([
|
|
8
7
|
sprinkles({
|
|
@@ -23,7 +22,6 @@ export const reset = style([
|
|
|
23
22
|
textDecoration: 'none',
|
|
24
23
|
whiteSpace: 'nowrap',
|
|
25
24
|
textOverflow: 'ellipsis',
|
|
26
|
-
height: vars.touchableSize,
|
|
27
25
|
WebkitTapHighlightColor: 'transparent',
|
|
28
26
|
},
|
|
29
27
|
]);
|
|
@@ -32,9 +30,9 @@ const highlightColor = createVar();
|
|
|
32
30
|
|
|
33
31
|
export const base = style([
|
|
34
32
|
sprinkles({
|
|
35
|
-
borderRadius: '
|
|
36
|
-
paddingY: '
|
|
37
|
-
paddingX: '
|
|
33
|
+
borderRadius: 'medium',
|
|
34
|
+
paddingY: 'xsmall',
|
|
35
|
+
paddingX: 'small',
|
|
38
36
|
font: 'standard',
|
|
39
37
|
}),
|
|
40
38
|
{
|
|
@@ -43,7 +41,6 @@ export const base = style([
|
|
|
43
41
|
},
|
|
44
42
|
color: highlightColor,
|
|
45
43
|
border: `1px solid ${colorPaletteVars.foreground.neutralSoft}`,
|
|
46
|
-
height: calc(vars.grid).multiply(9).toString(),
|
|
47
44
|
':hover': {
|
|
48
45
|
vars: {
|
|
49
46
|
[highlightColor]: colorPaletteVars.foreground.accent,
|
|
@@ -59,8 +56,7 @@ export const base = style([
|
|
|
59
56
|
transform: 'translateY(-50%)',
|
|
60
57
|
minHeight: vars.touchableSize,
|
|
61
58
|
minWidth: vars.touchableSize,
|
|
62
|
-
|
|
63
|
-
right: calc(vars.grid).multiply(2).negate().toString(),
|
|
59
|
+
width: '100%',
|
|
64
60
|
height: '100%',
|
|
65
61
|
top: '50%',
|
|
66
62
|
},
|
|
@@ -80,7 +76,7 @@ export const positive = style({
|
|
|
80
76
|
});
|
|
81
77
|
|
|
82
78
|
export const iconContainer = style([
|
|
83
|
-
sprinkles({ position: 'relative', paddingLeft: '
|
|
79
|
+
sprinkles({ position: 'relative', paddingLeft: 'xxsmall' }),
|
|
84
80
|
{
|
|
85
81
|
top: '1px',
|
|
86
82
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { style, globalStyle, keyframes, createVar } from '@vanilla-extract/css';
|
|
2
2
|
|
|
3
|
+
import { colorPaletteVars, sprinkles } from '../../css/sprinkles.css';
|
|
4
|
+
import { vars } from '../../css/vars.css';
|
|
3
5
|
import { toolbarItemSize } from '../ToolbarItem/ToolbarItem.css';
|
|
4
|
-
import { colorPaletteVars, sprinkles } from '../sprinkles.css';
|
|
5
|
-
import { vars } from '../vars.css';
|
|
6
6
|
|
|
7
7
|
const minimumLineNumberWidth = '50px';
|
|
8
8
|
|
|
@@ -20,9 +20,11 @@ const fadeIn = keyframes({
|
|
|
20
20
|
});
|
|
21
21
|
export const errorMarker = style([
|
|
22
22
|
sprinkles({
|
|
23
|
-
borderRadius: '
|
|
23
|
+
borderRadius: 'medium',
|
|
24
24
|
position: 'relative',
|
|
25
25
|
textAlign: 'right',
|
|
26
|
+
marginRight: 'xxsmall',
|
|
27
|
+
paddingRight: 'xsmall',
|
|
26
28
|
opacity: 0,
|
|
27
29
|
}),
|
|
28
30
|
{
|
|
@@ -32,8 +34,6 @@ export const errorMarker = style([
|
|
|
32
34
|
backgroundColor: colorPaletteVars.background.critical,
|
|
33
35
|
color: colorPaletteVars.foreground.critical,
|
|
34
36
|
minWidth: minimumLineNumberWidth,
|
|
35
|
-
marginRight: '4px',
|
|
36
|
-
paddingRight: '8px',
|
|
37
37
|
animationName: fadeIn,
|
|
38
38
|
animationDuration: '1s',
|
|
39
39
|
animationTimingFunction: 'ease',
|
|
@@ -42,10 +42,15 @@ export const errorMarker = style([
|
|
|
42
42
|
},
|
|
43
43
|
]);
|
|
44
44
|
|
|
45
|
-
export const foldGutter = style(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
export const foldGutter = style([
|
|
46
|
+
sprinkles({
|
|
47
|
+
paddingY: 'none',
|
|
48
|
+
paddingX: 'xsmall',
|
|
49
|
+
}),
|
|
50
|
+
{
|
|
51
|
+
width: '1em',
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
49
54
|
|
|
50
55
|
export const foldOpen = style([
|
|
51
56
|
sprinkles({ cursor: 'pointer' }),
|
|
@@ -82,7 +87,7 @@ globalStyle('.CodeMirror', {
|
|
|
82
87
|
globalStyle('.CodeMirror-gutters', {
|
|
83
88
|
minWidth: vars.codeGutterSize,
|
|
84
89
|
boxSizing: 'border-box',
|
|
85
|
-
paddingLeft:
|
|
90
|
+
paddingLeft: vars.space.xsmall,
|
|
86
91
|
});
|
|
87
92
|
|
|
88
93
|
globalStyle('.CodeMirror pre, .CodeMirror-linenumber', {
|
|
@@ -90,7 +95,7 @@ globalStyle('.CodeMirror pre, .CodeMirror-linenumber', {
|
|
|
90
95
|
});
|
|
91
96
|
|
|
92
97
|
globalStyle('.CodeMirror-lines', {
|
|
93
|
-
padding:
|
|
98
|
+
padding: `${vars.space.medium} 0`,
|
|
94
99
|
});
|
|
95
100
|
|
|
96
101
|
globalStyle('.CodeMirror-hints', {
|
|
@@ -101,7 +106,7 @@ globalStyle('.CodeMirror-hints', {
|
|
|
101
106
|
margin: 0,
|
|
102
107
|
padding: 0,
|
|
103
108
|
boxShadow: colorPaletteVars.shadows.small,
|
|
104
|
-
borderRadius: vars.radii.
|
|
109
|
+
borderRadius: vars.radii.small,
|
|
105
110
|
backgroundColor: colorPaletteVars.background.surface,
|
|
106
111
|
fontSize: '90%',
|
|
107
112
|
lineHeight: '150%',
|
|
@@ -115,7 +120,7 @@ globalStyle('[data-playroom-dark] .CodeMirror-hints', {
|
|
|
115
120
|
|
|
116
121
|
globalStyle('.CodeMirror-hint', {
|
|
117
122
|
margin: 0,
|
|
118
|
-
padding:
|
|
123
|
+
padding: `${vars.space.xxsmall} ${vars.space.xsmall}`,
|
|
119
124
|
borderRadius: vars.radii.small,
|
|
120
125
|
whiteSpace: 'pre',
|
|
121
126
|
color: colorPaletteVars.code.text,
|
|
@@ -135,7 +140,7 @@ globalStyle('.CodeMirror-foldmarker', {
|
|
|
135
140
|
color: colorPaletteVars.foreground.accent,
|
|
136
141
|
fontFamily: 'arial',
|
|
137
142
|
cursor: 'pointer',
|
|
138
|
-
padding: `0 ${vars.
|
|
143
|
+
padding: `0 ${vars.space.xxsmall}`,
|
|
139
144
|
});
|
|
140
145
|
|
|
141
146
|
globalStyle('.cm-s-neo.CodeMirror', {
|
|
@@ -157,7 +162,7 @@ globalStyle('.cm-s-neo .CodeMirror-gutters::after', {
|
|
|
157
162
|
content: '""',
|
|
158
163
|
backgroundColor: colorPaletteVars.background.surface,
|
|
159
164
|
position: 'absolute',
|
|
160
|
-
right:
|
|
165
|
+
right: vars.space.xxxsmall,
|
|
161
166
|
height: '100%',
|
|
162
167
|
boxShadow: `0 0 10px 5px ${colorPaletteVars.background.surface}`,
|
|
163
168
|
});
|
|
@@ -229,8 +234,8 @@ globalStyle('.cm-s-neo .cm-number', {
|
|
|
229
234
|
});
|
|
230
235
|
|
|
231
236
|
globalStyle('.CodeMirror-dialog', {
|
|
232
|
-
paddingLeft: vars.space.
|
|
233
|
-
paddingRight: vars.space.
|
|
237
|
+
paddingLeft: vars.space.medium,
|
|
238
|
+
paddingRight: vars.space.medium,
|
|
234
239
|
minHeight: toolbarItemSize,
|
|
235
240
|
borderBottom: `1px solid ${colorPaletteVars.border.standard}`,
|
|
236
241
|
display: 'flex',
|
|
@@ -273,7 +278,7 @@ globalStyle('.CodeMirror-search-label', {
|
|
|
273
278
|
});
|
|
274
279
|
|
|
275
280
|
globalStyle('.CodeMirror-search-field', {
|
|
276
|
-
paddingLeft: vars.space.
|
|
281
|
+
paddingLeft: vars.space.medium,
|
|
277
282
|
});
|
|
278
283
|
|
|
279
284
|
globalStyle('label.CodeMirror-search-label', {
|
|
@@ -285,28 +290,28 @@ globalStyle('.dialog-opened.cm-s-neo .CodeMirror-selected', {
|
|
|
285
290
|
});
|
|
286
291
|
|
|
287
292
|
globalStyle('.cm-overlay.cm-searching', {
|
|
288
|
-
paddingTop:
|
|
289
|
-
paddingBottom:
|
|
293
|
+
paddingTop: vars.space.xxxsmall,
|
|
294
|
+
paddingBottom: vars.space.xxxsmall,
|
|
290
295
|
background: colorPaletteVars.background.selection,
|
|
291
296
|
});
|
|
292
297
|
|
|
293
298
|
globalStyle('.CodeMirror-dialog button:first-of-type', {
|
|
294
|
-
marginLeft: vars.space.
|
|
299
|
+
marginLeft: vars.space.medium,
|
|
295
300
|
});
|
|
296
301
|
|
|
297
302
|
globalStyle('.CodeMirror-dialog button', {
|
|
298
303
|
appearance: 'none',
|
|
299
304
|
font: vars.font.scale.standard,
|
|
300
305
|
fontFamily: vars.font.family.standard,
|
|
301
|
-
marginLeft: vars.space.
|
|
302
|
-
paddingTop: vars.space.
|
|
303
|
-
paddingBottom: vars.space.
|
|
304
|
-
paddingLeft: vars.space.
|
|
305
|
-
paddingRight: vars.space.
|
|
306
|
+
marginLeft: vars.space.xsmall,
|
|
307
|
+
paddingTop: vars.space.xxsmall,
|
|
308
|
+
paddingBottom: vars.space.xxsmall,
|
|
309
|
+
paddingLeft: vars.space.small,
|
|
310
|
+
paddingRight: vars.space.small,
|
|
306
311
|
alignSelf: 'center',
|
|
307
312
|
display: 'block',
|
|
308
313
|
background: 'none',
|
|
309
|
-
borderRadius: vars.radii.
|
|
314
|
+
borderRadius: vars.radii.medium,
|
|
310
315
|
cursor: 'pointer',
|
|
311
316
|
border: '1px solid currentColor',
|
|
312
317
|
});
|
|
@@ -5,11 +5,9 @@ import 'codemirror/lib/codemirror.css';
|
|
|
5
5
|
import 'codemirror/addon/dialog/dialog.css';
|
|
6
6
|
import 'codemirror/theme/neo.css';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
type CursorPosition,
|
|
10
|
-
StoreContext,
|
|
11
|
-
} from '../../StoreContext/StoreContext';
|
|
8
|
+
import { type CursorPosition, StoreContext } from '../../contexts/StoreContext';
|
|
12
9
|
import { validateCode } from '../../utils/compileJsx';
|
|
10
|
+
import { hints } from '../../utils/componentsToHints';
|
|
13
11
|
import { formatCode as format, isMac } from '../../utils/formatting';
|
|
14
12
|
|
|
15
13
|
import { UnControlled as ReactCodeMirror } from './CodeMirror2';
|
|
@@ -62,16 +60,11 @@ const validateCodeInEditor = (editorInstance: Editor, code: string) => {
|
|
|
62
60
|
}
|
|
63
61
|
};
|
|
64
62
|
|
|
65
|
-
interface Hint {
|
|
66
|
-
attrs: Record<string, any>;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
63
|
interface Props {
|
|
70
64
|
code: string;
|
|
71
65
|
onChange: (code: string) => void;
|
|
72
66
|
editorHidden: boolean;
|
|
73
67
|
previewCode?: string;
|
|
74
|
-
hints?: Record<string, Hint>;
|
|
75
68
|
}
|
|
76
69
|
|
|
77
70
|
export const CodeEditor = ({
|
|
@@ -79,8 +72,8 @@ export const CodeEditor = ({
|
|
|
79
72
|
editorHidden,
|
|
80
73
|
onChange,
|
|
81
74
|
previewCode,
|
|
82
|
-
hints,
|
|
83
75
|
}: Props) => {
|
|
76
|
+
const mounted = useRef(false);
|
|
84
77
|
const editorInstanceRef = useRef<Editor | null>(null);
|
|
85
78
|
const insertionPointRef = useRef<ReturnType<Editor['addLineClass']> | null>(
|
|
86
79
|
null
|
|
@@ -169,9 +162,10 @@ export const CodeEditor = ({
|
|
|
169
162
|
useEffect(() => {
|
|
170
163
|
if (editorInstanceRef.current) {
|
|
171
164
|
if (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
165
|
+
mounted.current &&
|
|
166
|
+
(editorInstanceRef.current.hasFocus() ||
|
|
167
|
+
code === editorInstanceRef.current.getValue() ||
|
|
168
|
+
previewCode)
|
|
175
169
|
) {
|
|
176
170
|
return;
|
|
177
171
|
}
|
|
@@ -180,14 +174,7 @@ export const CodeEditor = ({
|
|
|
180
174
|
}
|
|
181
175
|
}, [code, previewCode]);
|
|
182
176
|
|
|
183
|
-
const mounted = useRef(false);
|
|
184
|
-
|
|
185
177
|
useEffect(() => {
|
|
186
|
-
if (!mounted.current) {
|
|
187
|
-
mounted.current = true;
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
178
|
if (editorInstanceRef.current && !editorInstanceRef.current.hasFocus()) {
|
|
192
179
|
setCursorPosition(cursorPosition);
|
|
193
180
|
}
|
|
@@ -228,6 +215,14 @@ export const CodeEditor = ({
|
|
|
228
215
|
if (!editorHidden) {
|
|
229
216
|
setCursorPosition(cursorPosition);
|
|
230
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* This workaround delays the setting of the mounted flag. It allows
|
|
220
|
+
* the behaviours wired up via `useEffect` to complete without being
|
|
221
|
+
* interrupted by change or focus events.
|
|
222
|
+
*/
|
|
223
|
+
setTimeout(() => {
|
|
224
|
+
mounted.current = true;
|
|
225
|
+
}, 1);
|
|
231
226
|
}}
|
|
232
227
|
onChange={(editorInstance, data, newCode) => {
|
|
233
228
|
if (editorInstance.hasFocus() && !previewCode) {
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from 'react';
|
|
8
8
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
9
9
|
|
|
10
|
+
import FrameComponent from '../../configModules/frameComponent';
|
|
10
11
|
import RenderCode from '../RenderCode/RenderCode';
|
|
11
12
|
|
|
12
13
|
type RenderCodeProps = ComponentProps<typeof RenderCode>;
|
|
@@ -16,18 +17,15 @@ type FrameComponentProps = {
|
|
|
16
17
|
children?: ReactNode;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
interface FrameProps extends Pick<RenderCodeProps, 'code'
|
|
20
|
+
interface FrameProps extends Pick<RenderCodeProps, 'code'> {
|
|
20
21
|
themeName: FrameComponentProps['themeName'];
|
|
21
22
|
theme: FrameComponentProps['theme'];
|
|
22
|
-
FrameComponent: ComponentType<FrameComponentProps>;
|
|
23
23
|
ErrorComponent: ComponentType<{ message: string; delayVisibility?: boolean }>;
|
|
24
24
|
}
|
|
25
25
|
export default function Frame({
|
|
26
26
|
code,
|
|
27
|
-
components,
|
|
28
27
|
themeName,
|
|
29
28
|
theme,
|
|
30
|
-
FrameComponent,
|
|
31
29
|
ErrorComponent,
|
|
32
30
|
}: FrameProps) {
|
|
33
31
|
const [error, setError] = useState('');
|
|
@@ -57,7 +55,7 @@ export default function Frame({
|
|
|
57
55
|
}}
|
|
58
56
|
>
|
|
59
57
|
<FrameComponent themeName={themeName} theme={theme}>
|
|
60
|
-
<RenderCode code={code}
|
|
58
|
+
<RenderCode code={code} onError={setError} />
|
|
61
59
|
</FrameComponent>
|
|
62
60
|
</ErrorBoundary>
|
|
63
61
|
<ErrorComponent message={error} delayVisibility={delay.current} />
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { globalStyle, style } from '@vanilla-extract/css';
|
|
2
2
|
import { calc } from '@vanilla-extract/css-utils';
|
|
3
3
|
|
|
4
|
-
import { light, dark } from '
|
|
4
|
+
import { light, dark } from '../../css/palettes';
|
|
5
5
|
|
|
6
|
-
import { sprinkles } from '
|
|
7
|
-
import { vars } from '
|
|
6
|
+
import { sprinkles } from '../../css/sprinkles.css';
|
|
7
|
+
import { vars } from '../../css/vars.css';
|
|
8
8
|
|
|
9
9
|
export const show = style({});
|
|
10
10
|
|
|
11
|
-
const gutter = vars.space.
|
|
11
|
+
const gutter = vars.space.xsmall;
|
|
12
12
|
export const message = style([
|
|
13
13
|
sprinkles({
|
|
14
14
|
position: 'absolute',
|
|
@@ -48,12 +48,12 @@ export const delay = style({
|
|
|
48
48
|
export const size = {
|
|
49
49
|
small: sprinkles({
|
|
50
50
|
font: 'small',
|
|
51
|
-
padding: '
|
|
52
|
-
borderRadius: '
|
|
51
|
+
padding: 'xsmall',
|
|
52
|
+
borderRadius: 'small',
|
|
53
53
|
}),
|
|
54
54
|
large: sprinkles({
|
|
55
55
|
font: 'large',
|
|
56
|
-
padding: '
|
|
57
|
-
borderRadius: '
|
|
56
|
+
padding: 'medium',
|
|
57
|
+
borderRadius: 'medium',
|
|
58
58
|
}),
|
|
59
59
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createVar, style } from '@vanilla-extract/css';
|
|
2
2
|
|
|
3
|
-
import { sprinkles } from '
|
|
3
|
+
import { sprinkles } from '../../css/sprinkles.css';
|
|
4
4
|
|
|
5
5
|
export const root = style([
|
|
6
6
|
sprinkles({
|
|
@@ -8,8 +8,8 @@ export const root = style([
|
|
|
8
8
|
width: 'full',
|
|
9
9
|
boxSizing: 'border-box',
|
|
10
10
|
display: 'flex',
|
|
11
|
-
gap: '
|
|
12
|
-
padding: '
|
|
11
|
+
gap: 'xxxlarge',
|
|
12
|
+
padding: 'xxxlarge',
|
|
13
13
|
textAlign: 'center',
|
|
14
14
|
overflow: 'auto',
|
|
15
15
|
}),
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
|
2
|
-
import { useRef } from 'react';
|
|
2
|
+
import { useContext, useRef } from 'react';
|
|
3
3
|
|
|
4
4
|
import playroomConfig from '../../config';
|
|
5
|
+
import { themeNames as availableThemes } from '../../configModules/themes';
|
|
6
|
+
import availableWidths from '../../configModules/widths';
|
|
7
|
+
import { StoreContext } from '../../contexts/StoreContext';
|
|
5
8
|
import { compileJsx } from '../../utils/compileJsx';
|
|
6
9
|
import { Box } from '../Box/Box';
|
|
7
10
|
import { ReceiveErrorMessage } from '../Frame/frameMessaging';
|
|
8
|
-
import type { PlayroomProps } from '../Playroom';
|
|
9
11
|
import { Strong } from '../Strong/Strong';
|
|
10
12
|
import { Text } from '../Text/Text';
|
|
11
13
|
|
|
@@ -16,11 +18,14 @@ import * as styles from './Frames.css';
|
|
|
16
18
|
|
|
17
19
|
interface FramesProps {
|
|
18
20
|
code: string;
|
|
19
|
-
themes: PlayroomProps['themes'];
|
|
20
|
-
widths: PlayroomProps['widths'];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export default function Frames({ code
|
|
23
|
+
export default function Frames({ code }: FramesProps) {
|
|
24
|
+
const [{ visibleWidths, visibleThemes }] = useContext(StoreContext);
|
|
25
|
+
const themes =
|
|
26
|
+
visibleThemes && visibleThemes.length > 0 ? visibleThemes : availableThemes;
|
|
27
|
+
const widths =
|
|
28
|
+
visibleWidths && visibleWidths.length > 0 ? visibleWidths : availableWidths;
|
|
24
29
|
const scrollingPanelRef = useRef<HTMLDivElement | null>(null);
|
|
25
30
|
const renderCode = useRef<string>('');
|
|
26
31
|
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { globalStyle, style } from '@vanilla-extract/css';
|
|
2
2
|
import { calc } from '@vanilla-extract/css-utils';
|
|
3
3
|
|
|
4
|
-
import { colorPaletteVars, sprinkles } from '
|
|
5
|
-
import { vars } from '
|
|
4
|
+
import { colorPaletteVars, sprinkles } from '../../css/sprinkles.css';
|
|
5
|
+
import { vars } from '../../css/vars.css';
|
|
6
6
|
|
|
7
|
+
const padding = 'xxsmall';
|
|
7
8
|
export const reset = style([
|
|
8
9
|
sprinkles({
|
|
9
10
|
position: 'relative',
|
|
10
11
|
font: 'small',
|
|
11
12
|
border: 0,
|
|
12
|
-
padding
|
|
13
|
+
padding,
|
|
13
14
|
appearance: 'none',
|
|
14
15
|
}),
|
|
15
16
|
{
|
|
@@ -17,7 +18,7 @@ export const reset = style([
|
|
|
17
18
|
backgroundColor: 'transparent',
|
|
18
19
|
outline: 'none',
|
|
19
20
|
textDecoration: 'underline',
|
|
20
|
-
margin: calc(vars.space
|
|
21
|
+
margin: calc(vars.space[padding]).negate().toString(),
|
|
21
22
|
'::before': {
|
|
22
23
|
content: '""',
|
|
23
24
|
position: 'absolute',
|
|
@@ -25,7 +26,7 @@ export const reset = style([
|
|
|
25
26
|
bottom: 0,
|
|
26
27
|
left: 0,
|
|
27
28
|
right: 0,
|
|
28
|
-
borderRadius: vars.radii.
|
|
29
|
+
borderRadius: vars.radii.small,
|
|
29
30
|
boxShadow: colorPaletteVars.shadows.focus,
|
|
30
31
|
cursor: 'pointer',
|
|
31
32
|
opacity: 0,
|
|
@@ -60,14 +61,14 @@ export const checkbox = style([
|
|
|
60
61
|
},
|
|
61
62
|
]);
|
|
62
63
|
|
|
63
|
-
const checkboxPadding = '
|
|
64
|
+
const checkboxPadding = 'xxxsmall';
|
|
64
65
|
export const fakeCheckbox = style([
|
|
65
66
|
sprinkles({
|
|
66
67
|
display: 'flex',
|
|
67
68
|
alignItems: 'center',
|
|
68
69
|
justifyContent: 'center',
|
|
69
70
|
position: 'relative',
|
|
70
|
-
borderRadius: '
|
|
71
|
+
borderRadius: 'medium',
|
|
71
72
|
padding: checkboxPadding,
|
|
72
73
|
pointerEvents: 'none',
|
|
73
74
|
}),
|
|
@@ -87,7 +88,7 @@ export const fakeCheckbox = style([
|
|
|
87
88
|
bottom: 0,
|
|
88
89
|
left: 0,
|
|
89
90
|
right: 0,
|
|
90
|
-
borderRadius: vars.radii.
|
|
91
|
+
borderRadius: vars.radii.small,
|
|
91
92
|
boxShadow: colorPaletteVars.shadows.focus,
|
|
92
93
|
transition: vars.transition.medium,
|
|
93
94
|
opacity: 0,
|
|
@@ -100,7 +101,7 @@ export const fakeCheckbox = style([
|
|
|
100
101
|
bottom: 0,
|
|
101
102
|
left: 0,
|
|
102
103
|
right: 0,
|
|
103
|
-
borderRadius: vars.radii.
|
|
104
|
+
borderRadius: vars.radii.small,
|
|
104
105
|
boxShadow: 'inset 0 0 0px 1px currentColor',
|
|
105
106
|
background: colorPaletteVars.background.surface,
|
|
106
107
|
},
|
|
@@ -134,7 +135,7 @@ export const textField = style([
|
|
|
134
135
|
sprinkles({
|
|
135
136
|
font: 'large',
|
|
136
137
|
width: 'full',
|
|
137
|
-
paddingX: '
|
|
138
|
+
paddingX: 'small',
|
|
138
139
|
boxSizing: 'border-box',
|
|
139
140
|
borderRadius: 'medium',
|
|
140
141
|
}),
|