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.
Files changed (116) hide show
  1. package/CHANGELOG.md +48 -12
  2. package/dist/index.d.mts +1 -4
  3. package/dist/index.d.ts +1 -2
  4. package/lib/makeWebpackConfig.js +3 -3
  5. package/package.json +1 -2
  6. package/src/{Playroom → components}/Box/Box.tsx +1 -1
  7. package/src/{Playroom → components}/Button/Button.css.ts +7 -11
  8. package/src/{Playroom → components}/CodeEditor/CodeEditor.css.ts +32 -27
  9. package/src/{Playroom → components}/CodeEditor/CodeEditor.tsx +15 -20
  10. package/src/{Playroom → components}/Frame/Frame.tsx +3 -5
  11. package/src/{Playroom → components}/Frame/FrameError.css.ts +8 -8
  12. package/src/{Playroom → components}/Frames/Frames.css.ts +3 -3
  13. package/src/{Playroom → components}/Frames/Frames.tsx +10 -5
  14. package/src/{Playroom → components}/FramesPanel/FramesPanel.css.ts +11 -10
  15. package/src/{Playroom → components}/FramesPanel/FramesPanel.tsx +9 -13
  16. package/src/{Playroom → components}/Heading/Heading.css.ts +2 -6
  17. package/src/{Playroom → components}/Heading/Heading.tsx +1 -3
  18. package/src/{Playroom → components}/Inline/Inline.css.ts +1 -1
  19. package/src/components/Playroom/Playroom.css.ts +171 -0
  20. package/src/components/Playroom/Playroom.tsx +178 -0
  21. package/src/components/Playroom/ResizeHandle.css.ts +73 -0
  22. package/src/components/Playroom/ResizeHandle.tsx +96 -0
  23. package/src/{Playroom → components}/Preview/PreviewError.tsx +1 -1
  24. package/src/{Playroom → components}/Preview/SplashScreen/SplashScreen.css.ts +2 -2
  25. package/src/{Playroom → components}/PreviewPanel/PreviewPanel.tsx +11 -11
  26. package/src/{Playroom → components}/PreviewPanel/ThemeSelector.css.ts +2 -2
  27. package/src/{Playroom → components}/PreviewPanel/ThemeSelector.tsx +3 -4
  28. package/src/components/RenderCode/RenderCode.tsx +50 -0
  29. package/src/{Playroom → components}/SettingsPanel/SettingsPanel.css.ts +7 -9
  30. package/src/{Playroom → components}/SettingsPanel/SettingsPanel.tsx +8 -10
  31. package/src/{Playroom → components}/Snippets/SearchField/SearchField.css.ts +3 -3
  32. package/src/{Playroom → components}/Snippets/Snippets.css.ts +7 -7
  33. package/src/{Playroom → components}/Snippets/Snippets.tsx +5 -8
  34. package/src/{Playroom → components}/Stack/Stack.css.ts +1 -1
  35. package/src/{Playroom → components}/StatusMessage/StatusMessage.css.ts +6 -6
  36. package/src/{Playroom → components}/StatusMessage/StatusMessage.tsx +1 -1
  37. package/src/{Playroom → components}/Strong/Strong.css.ts +1 -1
  38. package/src/{Playroom → components}/Text/Text.css.ts +1 -1
  39. package/src/{Playroom → components}/Toolbar/Toolbar.css.ts +2 -2
  40. package/src/{Playroom → components}/Toolbar/Toolbar.tsx +7 -21
  41. package/src/{Playroom → components}/ToolbarItem/ToolbarItem.css.ts +2 -2
  42. package/src/components/ToolbarPanel/ToolbarPanel.css.ts +5 -0
  43. package/src/{Playroom → components}/constants.ts +1 -1
  44. package/src/{Playroom → components}/icons/ChevronIcon.css.ts +1 -1
  45. package/src/configModules/components.ts +9 -0
  46. package/src/{themes.ts → configModules/themes.ts} +2 -0
  47. package/src/configModules/useScope.ts +33 -0
  48. package/src/configModules/widths.ts +8 -0
  49. package/src/{StoreContext → contexts}/StoreContext.tsx +222 -254
  50. package/src/css/delimiters.ts +3 -0
  51. package/src/{Playroom → css}/palettes.ts +1 -1
  52. package/src/{Playroom → css}/sprinkles.css.ts +2 -2
  53. package/src/{Playroom → css}/vars.css.ts +12 -14
  54. package/src/entries/frame.tsx +18 -0
  55. package/src/entries/index.tsx +21 -0
  56. package/src/entries/preview.tsx +34 -0
  57. package/src/utils/componentsToHints.ts +47 -39
  58. package/src/utils/cursor.ts +1 -1
  59. package/src/utils/formatting.ts +1 -1
  60. package/src/utils/params.ts +1 -2
  61. package/src/utils/usePreviewUrl.ts +1 -1
  62. package/utils/index.ts +1 -1
  63. package/src/Playroom/Playroom.css.ts +0 -175
  64. package/src/Playroom/Playroom.tsx +0 -270
  65. package/src/Playroom/RenderCode/RenderCode.tsx +0 -90
  66. package/src/Playroom/ToolbarPanel/ToolbarPanel.css.ts +0 -5
  67. package/src/Playroom/WindowPortal/index.tsx +0 -113
  68. package/src/Playroom/icons/EditorUndockedIcon.tsx +0 -15
  69. package/src/components.ts +0 -4
  70. package/src/frame.tsx +0 -48
  71. package/src/index.tsx +0 -66
  72. package/src/preview.tsx +0 -65
  73. package/src/useScope.ts +0 -1
  74. package/src/utils/hmr.ts +0 -10
  75. /package/src/{Playroom → components}/Button/Button.tsx +0 -0
  76. /package/src/{Playroom → components}/CodeEditor/CodeMirror2.tsx +0 -0
  77. /package/src/{Playroom → components}/CodeEditor/keymaps/comment.ts +0 -0
  78. /package/src/{Playroom → components}/CodeEditor/keymaps/complete.ts +0 -0
  79. /package/src/{Playroom → components}/CodeEditor/keymaps/cursors.ts +0 -0
  80. /package/src/{Playroom → components}/CodeEditor/keymaps/lines.ts +0 -0
  81. /package/src/{Playroom → components}/CodeEditor/keymaps/types.ts +0 -0
  82. /package/src/{Playroom → components}/CodeEditor/keymaps/wrap.ts +0 -0
  83. /package/src/{Playroom → components}/Frame/FrameError.tsx +0 -0
  84. /package/src/{Playroom → components}/Frame/frameMessaging.tsx +0 -0
  85. /package/src/{Playroom → components}/Frames/Iframe.tsx +0 -0
  86. /package/src/{Playroom → components}/Frames/frameSrc.ts +0 -0
  87. /package/src/{Playroom → components}/FramesPanel/CheckmarkSvg.tsx +0 -0
  88. /package/src/{Playroom → components}/Inline/Inline.tsx +0 -0
  89. /package/src/{Playroom → components}/Logo/Logo.tsx +0 -0
  90. /package/src/{Playroom → components}/Preview/Preview.tsx +0 -0
  91. /package/src/{Playroom → components}/Preview/SplashScreen/SplashScreen.tsx +0 -0
  92. /package/src/{Playroom → components}/PreviewPanel/CopyButton.tsx +0 -0
  93. /package/src/{Playroom → components}/Snippets/SearchField/SearchField.tsx +0 -0
  94. /package/src/{Playroom → components}/Stack/Stack.tsx +0 -0
  95. /package/src/{Playroom → components}/Strong/Strong.tsx +0 -0
  96. /package/src/{Playroom → components}/Text/Text.tsx +0 -0
  97. /package/src/{Playroom → components}/ToolbarItem/ToolbarItem.tsx +0 -0
  98. /package/src/{Playroom → components}/ToolbarPanel/ToolbarPanel.tsx +0 -0
  99. /package/src/{Playroom → components}/icons/AddIcon.tsx +0 -0
  100. /package/src/{Playroom → components}/icons/ChevronIcon.tsx +0 -0
  101. /package/src/{Playroom → components}/icons/ColorModeDarkIcon.tsx +0 -0
  102. /package/src/{Playroom → components}/icons/ColorModeLightIcon.tsx +0 -0
  103. /package/src/{Playroom → components}/icons/ColorModeSystemIcon.tsx +0 -0
  104. /package/src/{Playroom → components}/icons/DismissIcon.tsx +0 -0
  105. /package/src/{Playroom → components}/icons/EditorBottomIcon.tsx +0 -0
  106. /package/src/{Playroom → components}/icons/EditorRightIcon.tsx +0 -0
  107. /package/src/{Playroom → components}/icons/FramesIcon.tsx +0 -0
  108. /package/src/{Playroom → components}/icons/PlayIcon.tsx +0 -0
  109. /package/src/{Playroom → components}/icons/SettingsIcon.tsx +0 -0
  110. /package/src/{Playroom → components}/icons/ShareIcon.tsx +0 -0
  111. /package/src/{Playroom → components}/icons/ThemesIcon.tsx +0 -0
  112. /package/src/{Playroom → components}/icons/TickIcon.tsx +0 -0
  113. /package/src/{Playroom → components}/icons/WidthsIcon.tsx +0 -0
  114. /package/src/{playroomModuleAliases.d.ts → configModules/configModules.d.ts} +0 -0
  115. /package/src/{frameComponent.ts → configModules/frameComponent.ts} +0 -0
  116. /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
@@ -1,7 +1,4 @@
1
- import "react/jsx-runtime";
2
- import "react";
3
-
4
- //#region src/Playroom/Playroom.d.ts
1
+ //#region src/configModules/widths.d.ts
5
2
  type Widths = Array<number | 'Fit to window'>;
6
3
  //#endregion
7
4
  //#region utils/index.d.ts
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- //#region src/Playroom/Playroom.d.ts
2
-
1
+ //#region src/configModules/widths.d.ts
3
2
  type Widths = Array<number | 'Fit to window'>;
4
3
  //#endregion
5
4
  //#region utils/index.d.ts
@@ -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.0",
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 '../sprinkles.css';
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 '../sprinkles.css';
5
- import { vars } from '../vars.css';
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: 'large',
36
- paddingY: 'none',
37
- paddingX: 'large',
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
- left: calc(vars.grid).multiply(2).negate().toString(),
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: 'small' }),
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: 'large',
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
- width: '1em',
47
- padding: '0 8px',
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: '8px',
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: '16px 0',
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.medium,
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: '4px 8px',
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.grid}`,
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: '2px',
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.xlarge,
233
- paddingRight: vars.space.xlarge,
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.xlarge,
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: 2,
289
- paddingBottom: 2,
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.xlarge,
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.small,
302
- paddingTop: vars.space.small,
303
- paddingBottom: vars.space.small,
304
- paddingLeft: vars.space.large,
305
- paddingRight: vars.space.large,
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.large,
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
- editorInstanceRef.current.hasFocus() ||
173
- code === editorInstanceRef.current.getValue() ||
174
- previewCode
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' | 'components'> {
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} components={components} onError={setError} />
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 '../palettes';
4
+ import { light, dark } from '../../css/palettes';
5
5
 
6
- import { sprinkles } from '../sprinkles.css';
7
- import { vars } from '../vars.css';
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.medium;
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: 'medium',
52
- borderRadius: 'medium',
51
+ padding: 'xsmall',
52
+ borderRadius: 'small',
53
53
  }),
54
54
  large: sprinkles({
55
55
  font: 'large',
56
- padding: 'xlarge',
57
- borderRadius: 'large',
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 '../sprinkles.css';
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: 'gutter',
12
- padding: 'gutter',
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, themes, widths }: FramesProps) {
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 '../sprinkles.css';
5
- import { vars } from '../vars.css';
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: 'small',
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.small).negate().toString(),
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.large,
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 = 'xxsmall';
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: 'large',
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.medium,
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.medium,
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: 'large',
138
+ paddingX: 'small',
138
139
  boxSizing: 'border-box',
139
140
  borderRadius: 'medium',
140
141
  }),