playroom 1.0.3 → 1.0.5
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 +14 -0
- package/package.json +2 -4
- package/src/components/Button/Button.css.ts +1 -1
- package/src/components/ButtonIcon/ButtonIcon.css.ts +2 -2
- package/src/components/ButtonIcon/ButtonIcon.tsx +1 -1
- package/src/components/CodeEditor/CodeMirror2.tsx +9 -9
- package/src/components/CodeEditor/editorCommands.ts +1 -1
- package/src/components/ContextMenu/ContextMenu.tsx +0 -4
- package/src/components/EditorActions/EditorActions.css.ts +0 -17
- package/src/components/Frame/frameMessenger.tsx +0 -19
- package/src/components/Frames/FrameActionButton.css.ts +1 -1
- package/src/components/Frames/Frames.css.ts +1 -1
- package/src/components/Menu/Menu.css.ts +1 -10
- package/src/components/Menu/Menu.tsx +0 -30
- package/src/components/Playroom/Playroom.css.ts +0 -1
- package/src/components/Snippets/Snippets.css.ts +0 -9
- package/src/components/Text/Text.tsx +1 -1
- package/src/components/Title/Title.css.ts +2 -2
- package/src/components/ZeroState/ZeroState.tsx +1 -1
- package/src/contexts/StoreContext.tsx +26 -6
- package/src/publicTypes.ts +1 -1
- package/src/utils/compileJsx.ts +2 -2
- package/src/utils/formatting.ts +4 -4
- package/src/utils/params.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# playroom
|
|
2
2
|
|
|
3
|
+
## 1.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#467](https://github.com/seek-oss/playroom/pull/467) [`fad3b7f`](https://github.com/seek-oss/playroom/commit/fad3b7fc3fb7e58ee240595ba99994bc2701d5c2) Thanks [@askoufis](https://github.com/askoufis)! - Remove unused code, remove unused deps, update `sucrase` to latest version
|
|
8
|
+
|
|
9
|
+
## 1.0.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#465](https://github.com/seek-oss/playroom/pull/465) [`63a512b`](https://github.com/seek-oss/playroom/commit/63a512bf8c33d5af15a254dba8d4efd69a886df4) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - Only show available themes and widths
|
|
14
|
+
|
|
15
|
+
Ensure that themes or widths selected via the URL or from storage are valid options.
|
|
16
|
+
|
|
3
17
|
## 1.0.3
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playroom",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Design with code, powered by your own component library",
|
|
5
5
|
"bin": {
|
|
6
6
|
"playroom": "bin/cli.cjs"
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"@capsizecss/metrics": "^3.5.0",
|
|
53
53
|
"@capsizecss/vanilla-extract": "^2.0.4",
|
|
54
54
|
"@soda/friendly-errors-webpack-plugin": "^1.8.1",
|
|
55
|
-
"@types/base64-url": "^2.2.0",
|
|
56
55
|
"@types/codemirror": "^5.60.5",
|
|
57
56
|
"@types/prettier": "^2.7.1",
|
|
58
57
|
"@types/react": "^18.0.0 || ^19.0.0",
|
|
@@ -88,7 +87,7 @@
|
|
|
88
87
|
"react-error-boundary": "^4.0.13",
|
|
89
88
|
"read-pkg-up": "^7.0.1",
|
|
90
89
|
"scope-eval": "^1.0.0",
|
|
91
|
-
"sucrase": "^3.
|
|
90
|
+
"sucrase": "^3.35.1",
|
|
92
91
|
"tinyglobby": "^0.2.12",
|
|
93
92
|
"typescript": ">=5.0.0",
|
|
94
93
|
"use-debounce": "^10.0.0",
|
|
@@ -104,7 +103,6 @@
|
|
|
104
103
|
"@testing-library/cypress": "^10.1.0",
|
|
105
104
|
"@types/jest": "^29.2.4",
|
|
106
105
|
"@types/node": "^18.11.9",
|
|
107
|
-
"@types/webpack-env": "^1.18.8",
|
|
108
106
|
"concurrently": "^9.1.2",
|
|
109
107
|
"cypress": "^15.5.0",
|
|
110
108
|
"eslint": "^9.23.0",
|
|
@@ -4,7 +4,7 @@ import { minTouchableBeforePseudo } from '../../css/shared.css';
|
|
|
4
4
|
import { sprinkles, colorPaletteVars } from '../../css/sprinkles.css';
|
|
5
5
|
import { vars } from '../../css/vars.css';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const sizeVar = createVar();
|
|
8
8
|
|
|
9
9
|
const reset = style([
|
|
10
10
|
sprinkles({
|
|
@@ -12,8 +12,8 @@ import { minTouchableBeforePseudo } from '../../css/shared.css';
|
|
|
12
12
|
import { colorPaletteVars, sprinkles } from '../../css/sprinkles.css';
|
|
13
13
|
import { vars } from '../../css/vars.css';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const sizeVar = createVar();
|
|
16
|
+
const foreground = createVar();
|
|
17
17
|
|
|
18
18
|
export const button = style([
|
|
19
19
|
sprinkles({
|
|
@@ -26,34 +26,34 @@ if (!SERVER_RENDERED) {
|
|
|
26
26
|
cm = require('codemirror');
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
interface IDefineModeOptions {
|
|
30
30
|
fn: () => codemirror.Mode<any>;
|
|
31
31
|
name: string;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
interface ISetScrollOptions {
|
|
35
35
|
x?: number | null;
|
|
36
36
|
y?: number | null;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
interface ISetSelectionOptions {
|
|
40
40
|
anchor: codemirror.Position;
|
|
41
41
|
head: codemirror.Position;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
interface DomEvent {
|
|
45
45
|
(editor: codemirror.Editor, event?: any): void;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
interface KeyHandledEvent {
|
|
49
49
|
(editor: codemirror.Editor, name: string, event: any): void;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
interface EditorChangeEvent {
|
|
53
53
|
(editor: codemirror.Editor, changeObj: codemirror.EditorChange): void;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
interface ICodeMirror {
|
|
57
57
|
autoCursor?: boolean; // default: true
|
|
58
58
|
autoScroll?: boolean; // default: false
|
|
59
59
|
className?: string;
|
|
@@ -116,7 +116,7 @@ export interface ICodeMirror {
|
|
|
116
116
|
scroll?: ISetScrollOptions;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
interface IControlledCodeMirror extends ICodeMirror {
|
|
120
120
|
onBeforeChange: (
|
|
121
121
|
editor: codemirror.Editor,
|
|
122
122
|
data: codemirror.EditorChange,
|
|
@@ -125,7 +125,7 @@ export interface IControlledCodeMirror extends ICodeMirror {
|
|
|
125
125
|
value: string;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
interface IUnControlledCodeMirror extends ICodeMirror {
|
|
129
129
|
detach?: boolean;
|
|
130
130
|
editorDidAttach?: (editor: codemirror.Editor) => void;
|
|
131
131
|
editorDidDetach?: (editor: codemirror.Editor) => void;
|
|
@@ -97,10 +97,6 @@ export const ContextMenuItemLink = ({
|
|
|
97
97
|
/>
|
|
98
98
|
);
|
|
99
99
|
|
|
100
|
-
export const ContextMenuSeparator = () => (
|
|
101
|
-
<BaseUIContextMenu.Separator className={menuStyles.separator} />
|
|
102
|
-
);
|
|
103
|
-
|
|
104
100
|
type Props = {
|
|
105
101
|
trigger: ComponentProps<typeof BaseUIContextMenu.Trigger>['render'];
|
|
106
102
|
align?: ComponentProps<typeof BaseUIContextMenu.Positioner>['align'];
|
|
@@ -20,19 +20,6 @@ export const root = style([
|
|
|
20
20
|
},
|
|
21
21
|
]);
|
|
22
22
|
|
|
23
|
-
export const syntaxErrorsContainer = style([
|
|
24
|
-
sprinkles({
|
|
25
|
-
paddingX: 'xsmall',
|
|
26
|
-
paddingY: 'xxsmall',
|
|
27
|
-
display: 'flex',
|
|
28
|
-
alignItems: 'center',
|
|
29
|
-
boxSizing: 'border-box',
|
|
30
|
-
}),
|
|
31
|
-
{
|
|
32
|
-
height: vars.buttonSizes.medium,
|
|
33
|
-
},
|
|
34
|
-
]);
|
|
35
|
-
|
|
36
23
|
export const button = style([
|
|
37
24
|
sprinkles({
|
|
38
25
|
paddingX: 'xsmall',
|
|
@@ -68,7 +55,3 @@ export const button = style([
|
|
|
68
55
|
},
|
|
69
56
|
},
|
|
70
57
|
]);
|
|
71
|
-
|
|
72
|
-
export const snippetsPopupWidth = style({
|
|
73
|
-
width: 'min(300px, 90vw)',
|
|
74
|
-
});
|
|
@@ -68,25 +68,6 @@ export const ErrorMessageReceiver = ({ size }: ReceiveErrorMessageProps) => {
|
|
|
68
68
|
*/
|
|
69
69
|
const playroomScreenshotSource = 'Playroom Frame Screenshot';
|
|
70
70
|
|
|
71
|
-
type ScreenshoMessage = {
|
|
72
|
-
messageWindow: Window;
|
|
73
|
-
} & ({ action: 'copy' } | { action: 'download'; fileName: string });
|
|
74
|
-
|
|
75
|
-
export const screenshotMessageSender = ({
|
|
76
|
-
messageWindow,
|
|
77
|
-
action,
|
|
78
|
-
...restProps
|
|
79
|
-
}: ScreenshoMessage) => {
|
|
80
|
-
messageWindow.postMessage({
|
|
81
|
-
source: playroomScreenshotSource,
|
|
82
|
-
action,
|
|
83
|
-
fileName:
|
|
84
|
-
action === 'download' && 'fileName' in restProps
|
|
85
|
-
? restProps.fileName
|
|
86
|
-
: undefined,
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
|
|
90
71
|
const renderDocumentToCanvas = async (doc: Document) => {
|
|
91
72
|
const result = await snapdom(doc.documentElement, {
|
|
92
73
|
embedFonts: true,
|
|
@@ -9,7 +9,7 @@ import { calc } from '@vanilla-extract/css-utils';
|
|
|
9
9
|
import { colorPaletteVars, sprinkles } from '../../css/sprinkles.css';
|
|
10
10
|
import { vars } from '../../css/vars.css';
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const foreground = createVar();
|
|
13
13
|
|
|
14
14
|
export const button = style([
|
|
15
15
|
sprinkles({
|
|
@@ -106,7 +106,7 @@ export const critical = style({
|
|
|
106
106
|
color: colorPaletteVars.foreground.critical,
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
const positive = style({
|
|
110
110
|
color: colorPaletteVars.foreground.positive,
|
|
111
111
|
vars: {
|
|
112
112
|
[highlightColor]: 'transparent',
|
|
@@ -227,15 +227,6 @@ export const separator = style([
|
|
|
227
227
|
},
|
|
228
228
|
]);
|
|
229
229
|
|
|
230
|
-
export const shortcut = style({
|
|
231
|
-
display: 'grid',
|
|
232
|
-
gridAutoFlow: 'column',
|
|
233
|
-
gridAutoColumns: '1fr',
|
|
234
|
-
alignItems: 'baseline',
|
|
235
|
-
justifyItems: 'center',
|
|
236
|
-
isolation: 'isolate',
|
|
237
|
-
});
|
|
238
|
-
|
|
239
230
|
const clearItemPadding = 'xsmall';
|
|
240
231
|
export const clearItem = style([
|
|
241
232
|
sprinkles({
|
|
@@ -10,13 +10,11 @@ import {
|
|
|
10
10
|
type AllHTMLAttributes,
|
|
11
11
|
type ComponentProps,
|
|
12
12
|
type ReactElement,
|
|
13
|
-
type ReactNode,
|
|
14
13
|
createContext,
|
|
15
14
|
forwardRef,
|
|
16
15
|
useContext,
|
|
17
16
|
} from 'react';
|
|
18
17
|
|
|
19
|
-
import { useCopy } from '../../utils/useCopy';
|
|
20
18
|
import {
|
|
21
19
|
KeyboardShortcut,
|
|
22
20
|
type KeyCombination,
|
|
@@ -310,34 +308,6 @@ export const Menu = forwardRef<HTMLButtonElement, Props>(
|
|
|
310
308
|
}
|
|
311
309
|
);
|
|
312
310
|
|
|
313
|
-
type MenuCopyItemProps = {
|
|
314
|
-
content: string;
|
|
315
|
-
children: ReactNode;
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
export const MenuCopyItem = ({ content, children }: MenuCopyItemProps) => {
|
|
319
|
-
const { copying, onCopyClick } = useCopy();
|
|
320
|
-
|
|
321
|
-
return (
|
|
322
|
-
<BaseUIMenu.Item
|
|
323
|
-
className={clsx({ [styles.item]: true, [styles.positive]: copying })}
|
|
324
|
-
closeOnClick={false}
|
|
325
|
-
onClick={() => onCopyClick(content)}
|
|
326
|
-
>
|
|
327
|
-
<span className={styles.itemLeft}>
|
|
328
|
-
{copying ? (
|
|
329
|
-
<>
|
|
330
|
-
<Text tone="positive">Copied</Text>
|
|
331
|
-
<Check size={menuIconSize} />
|
|
332
|
-
</>
|
|
333
|
-
) : (
|
|
334
|
-
<Text>{children}</Text>
|
|
335
|
-
)}
|
|
336
|
-
</span>
|
|
337
|
-
</BaseUIMenu.Item>
|
|
338
|
-
);
|
|
339
|
-
};
|
|
340
|
-
|
|
341
311
|
type MenuClearItemProps = Omit<
|
|
342
312
|
ComponentProps<typeof BaseUIMenu.Item>,
|
|
343
313
|
'render' | 'className'
|
|
@@ -117,15 +117,6 @@ export const snippet = style([
|
|
|
117
117
|
},
|
|
118
118
|
]);
|
|
119
119
|
|
|
120
|
-
export const snippetName = style([
|
|
121
|
-
sprinkles({
|
|
122
|
-
display: 'block',
|
|
123
|
-
}),
|
|
124
|
-
{
|
|
125
|
-
color: colorPaletteVars.foreground.secondary,
|
|
126
|
-
},
|
|
127
|
-
]);
|
|
128
|
-
|
|
129
120
|
export const groupName = style([
|
|
130
121
|
sprinkles({
|
|
131
122
|
paddingRight: 'xsmall',
|
|
@@ -11,8 +11,8 @@ export const fieldContainer = sprinkles({
|
|
|
11
11
|
alignItems: 'center',
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const titleWeight = 'strong';
|
|
15
|
+
const titleSize = 'standard';
|
|
16
16
|
|
|
17
17
|
const paddingX = 'small';
|
|
18
18
|
export const textField = style([
|
|
@@ -51,7 +51,7 @@ export const ZeroState = () => {
|
|
|
51
51
|
|
|
52
52
|
return (
|
|
53
53
|
<ScrollContainer direction="vertical">
|
|
54
|
-
<div className={styles.root}
|
|
54
|
+
<div className={styles.root}>
|
|
55
55
|
<div className={styles.maxWidth}>
|
|
56
56
|
<Stack space="xxxlarge">
|
|
57
57
|
<Text size="large">
|
|
@@ -41,8 +41,8 @@ const defaultOrientation = 'horizontal';
|
|
|
41
41
|
const defaultOpenLayout = 'grid';
|
|
42
42
|
|
|
43
43
|
export type EditorOrientation = 'horizontal' | 'vertical';
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
type ColorScheme = 'light' | 'dark' | 'system';
|
|
45
|
+
type OpenLayout = 'grid' | 'list';
|
|
46
46
|
|
|
47
47
|
const applyColorScheme = (colorScheme: Exclude<ColorScheme, 'system'>) => {
|
|
48
48
|
document.documentElement[
|
|
@@ -587,8 +587,26 @@ export const StoreProvider = ({ children }: { children: ReactNode }) => {
|
|
|
587
587
|
openLayout,
|
|
588
588
|
storedPlayrooms,
|
|
589
589
|
]) => {
|
|
590
|
-
const
|
|
591
|
-
|
|
590
|
+
const filteredUrlWidths = widthsFromUrl
|
|
591
|
+
? availableWidths.filter((w) => widthsFromUrl.includes(w))
|
|
592
|
+
: [];
|
|
593
|
+
const filteredStoredSelectedWidths = storedSelectedWidths
|
|
594
|
+
? availableWidths.filter((w) => storedSelectedWidths.includes(w))
|
|
595
|
+
: [];
|
|
596
|
+
const selectedWidths = filteredUrlWidths.length
|
|
597
|
+
? filteredUrlWidths
|
|
598
|
+
: filteredStoredSelectedWidths;
|
|
599
|
+
|
|
600
|
+
const filteredUrlThemes = themesFromUrl
|
|
601
|
+
? availableThemes.filter((t) => themesFromUrl.includes(t))
|
|
602
|
+
: [];
|
|
603
|
+
const filteredStoredSelectedThemes = storedSelectedThemes
|
|
604
|
+
? availableThemes.filter((t) => storedSelectedThemes.includes(t))
|
|
605
|
+
: [];
|
|
606
|
+
const selectedThemes = filteredUrlThemes.length
|
|
607
|
+
? filteredUrlThemes
|
|
608
|
+
: filteredStoredSelectedThemes;
|
|
609
|
+
|
|
592
610
|
const storedPlayroomValues = Object.entries(storedPlayrooms || {});
|
|
593
611
|
let id = code || title ? createPlayroomId() : '';
|
|
594
612
|
|
|
@@ -613,8 +631,10 @@ export const StoreProvider = ({ children }: { children: ReactNode }) => {
|
|
|
613
631
|
...(editorHeight ? { editorHeight } : {}),
|
|
614
632
|
...(editorWidth ? { editorWidth } : {}),
|
|
615
633
|
...(editorHidden ? { editorHidden } : {}),
|
|
616
|
-
...(themesEnabled && selectedThemes
|
|
617
|
-
|
|
634
|
+
...(themesEnabled && selectedThemes.length > 0
|
|
635
|
+
? { selectedThemes }
|
|
636
|
+
: {}),
|
|
637
|
+
...(selectedWidths.length > 0 ? { selectedWidths } : {}),
|
|
618
638
|
...(colorScheme ? { colorScheme } : {}),
|
|
619
639
|
...(openLayout ? { openLayout } : {}),
|
|
620
640
|
...(storedPlayrooms
|
package/src/publicTypes.ts
CHANGED
package/src/utils/compileJsx.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { transform } from 'sucrase';
|
|
|
5
5
|
export const ReactFragmentPragma = 'R_F';
|
|
6
6
|
export const ReactCreateElementPragma = 'R_cE';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const openFragmentTag = '<>';
|
|
9
|
+
const closeFragmentTag = '</>';
|
|
10
10
|
|
|
11
11
|
const wrapInFragment = (code: string) =>
|
|
12
12
|
`${openFragmentTag}${code}${closeFragmentTag}`;
|
package/src/utils/formatting.ts
CHANGED
|
@@ -6,14 +6,14 @@ import type { CursorPosition } from '../contexts/StoreContext';
|
|
|
6
6
|
|
|
7
7
|
import { insertAtCursor } from './cursor';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
interface CodeWithCursor {
|
|
10
10
|
code: string;
|
|
11
11
|
cursor: CursorPosition;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const isMac = () => Boolean(navigator.platform.match('Mac'));
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const runPrettier = ({
|
|
17
17
|
code,
|
|
18
18
|
cursorOffset,
|
|
19
19
|
}: {
|
|
@@ -59,10 +59,10 @@ export const cursorOffsetToPosition = (
|
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
const wrapJsx = (code: string) => `<>\n${code}\n</>`;
|
|
63
63
|
|
|
64
64
|
// Removes `<>\n` and `\n</>` and unindents the two spaces due to the wrapping
|
|
65
|
-
|
|
65
|
+
const unwrapJsx = (code: string) => {
|
|
66
66
|
if (code.startsWith('<>\n')) {
|
|
67
67
|
// Multi-line: remove indentation, then unwrap
|
|
68
68
|
return code.replace(/\n {2}/g, '\n').slice(3, -5);
|
package/src/utils/params.ts
CHANGED
|
@@ -28,7 +28,7 @@ export function updateUrlCode(code: string) {
|
|
|
28
28
|
history.replace(createUrlForData(code));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
function getParamsFromQuery(location = history.location) {
|
|
32
32
|
try {
|
|
33
33
|
// Prefer checking `hash`, fall back to `search` in case the user has configured a custom
|
|
34
34
|
// `frameSrc` function that uses search params instead of the hash
|