playroom 0.38.0 → 0.38.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 +14 -0
- package/lib/start.js +3 -0
- package/package.json +1 -1
- package/src/Playroom/FramesPanel/FramesPanel.tsx +60 -84
- package/src/Playroom/Playroom.tsx +22 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# playroom
|
|
2
2
|
|
|
3
|
+
## 0.38.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a62002d: Apply `title` from url on page load
|
|
8
|
+
|
|
9
|
+
Previously the document `title` would only update when the frames panel is open.
|
|
10
|
+
The title is now correctly reflected from the url on page load.
|
|
11
|
+
|
|
12
|
+
- cf0fa9e: start: Disable webpack error overlay
|
|
13
|
+
|
|
14
|
+
Prevent the default webpack dev server error overlay from blocking the preview frames in `start` mode.
|
|
15
|
+
Playroom handles its own errors, and this would block the preview frames and need to be dismissed manually.
|
|
16
|
+
|
|
3
17
|
## 0.38.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/lib/start.js
CHANGED
package/package.json
CHANGED
|
@@ -5,26 +5,11 @@ import { ToolbarPanel } from '../ToolbarPanel/ToolbarPanel';
|
|
|
5
5
|
import { StoreContext } from '../../StoreContext/StoreContext';
|
|
6
6
|
import { Stack } from '../Stack/Stack';
|
|
7
7
|
import { Text } from '../Text/Text';
|
|
8
|
-
import { Helmet } from 'react-helmet';
|
|
9
8
|
import { Inline } from '../Inline/Inline';
|
|
10
9
|
import { Box } from '../Box/Box';
|
|
11
10
|
|
|
12
11
|
import * as styles from './FramesPanel.css';
|
|
13
12
|
|
|
14
|
-
const getTitle = (title: string | undefined) => {
|
|
15
|
-
if (title) {
|
|
16
|
-
return `${title} | Playroom`;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const configTitle = window?.__playroomConfig__.title;
|
|
20
|
-
|
|
21
|
-
if (configTitle) {
|
|
22
|
-
return `${configTitle} | Playroom`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return 'Playroom';
|
|
26
|
-
};
|
|
27
|
-
|
|
28
13
|
interface FramesPanelProps {
|
|
29
14
|
availableWidths: number[];
|
|
30
15
|
availableThemes: string[];
|
|
@@ -104,93 +89,84 @@ export default ({ availableWidths, availableThemes }: FramesPanelProps) => {
|
|
|
104
89
|
const hasFilteredThemes =
|
|
105
90
|
visibleThemes.length > 0 && visibleThemes.length <= availableThemes.length;
|
|
106
91
|
|
|
107
|
-
const displayedTitle = getTitle(title);
|
|
108
|
-
|
|
109
92
|
return (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
<
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
93
|
+
<ToolbarPanel>
|
|
94
|
+
<Stack space="xxxlarge">
|
|
95
|
+
<label>
|
|
96
|
+
<Stack space="small">
|
|
97
|
+
<Heading level="3">Title</Heading>
|
|
98
|
+
<input
|
|
99
|
+
type="text"
|
|
100
|
+
id="playroomTitleField"
|
|
101
|
+
placeholder="Enter a title for this Playroom..."
|
|
102
|
+
className={styles.textField}
|
|
103
|
+
value={title}
|
|
104
|
+
onChange={(e) =>
|
|
105
|
+
dispatch({
|
|
106
|
+
type: 'updateTitle',
|
|
107
|
+
payload: { title: e.target.value },
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
/>
|
|
111
|
+
</Stack>
|
|
112
|
+
</label>
|
|
113
|
+
|
|
114
|
+
<Stack space="xlarge">
|
|
115
|
+
<FrameHeading
|
|
116
|
+
showReset={hasFilteredWidths}
|
|
117
|
+
onReset={() => dispatch({ type: 'resetVisibleWidths' })}
|
|
118
|
+
>
|
|
119
|
+
Widths
|
|
120
|
+
</FrameHeading>
|
|
121
|
+
{availableWidths.map((option) => (
|
|
122
|
+
<FrameOption
|
|
123
|
+
key={option}
|
|
124
|
+
option={option}
|
|
125
|
+
selected={hasFilteredWidths && visibleWidths.includes(option)}
|
|
126
|
+
visible={visibleWidths}
|
|
127
|
+
onChange={(newWidths) => {
|
|
128
|
+
if (newWidths) {
|
|
128
129
|
dispatch({
|
|
129
|
-
type: '
|
|
130
|
-
payload: {
|
|
131
|
-
})
|
|
130
|
+
type: 'updateVisibleWidths',
|
|
131
|
+
payload: { widths: newWidths },
|
|
132
|
+
});
|
|
133
|
+
} else {
|
|
134
|
+
dispatch({ type: 'resetVisibleWidths' });
|
|
132
135
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
+
}}
|
|
137
|
+
/>
|
|
138
|
+
))}
|
|
139
|
+
</Stack>
|
|
136
140
|
|
|
141
|
+
{hasThemes ? (
|
|
137
142
|
<Stack space="xlarge">
|
|
138
143
|
<FrameHeading
|
|
139
|
-
showReset={
|
|
140
|
-
onReset={() => dispatch({ type: '
|
|
144
|
+
showReset={hasFilteredThemes}
|
|
145
|
+
onReset={() => dispatch({ type: 'resetVisibleThemes' })}
|
|
141
146
|
>
|
|
142
|
-
|
|
147
|
+
Themes
|
|
143
148
|
</FrameHeading>
|
|
144
|
-
{
|
|
149
|
+
{availableThemes.map((option) => (
|
|
145
150
|
<FrameOption
|
|
146
151
|
key={option}
|
|
147
152
|
option={option}
|
|
148
|
-
selected={
|
|
149
|
-
visible={
|
|
150
|
-
onChange={(
|
|
151
|
-
if (
|
|
153
|
+
selected={hasFilteredThemes && visibleThemes.includes(option)}
|
|
154
|
+
visible={visibleThemes}
|
|
155
|
+
onChange={(newThemes) => {
|
|
156
|
+
if (newThemes) {
|
|
152
157
|
dispatch({
|
|
153
|
-
type: '
|
|
154
|
-
payload: {
|
|
158
|
+
type: 'updateVisibleThemes',
|
|
159
|
+
payload: { themes: newThemes },
|
|
155
160
|
});
|
|
156
161
|
} else {
|
|
157
|
-
dispatch({ type: '
|
|
162
|
+
dispatch({ type: 'resetVisibleThemes' });
|
|
158
163
|
}
|
|
159
164
|
}}
|
|
160
165
|
/>
|
|
161
166
|
))}
|
|
162
167
|
</Stack>
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
<FrameHeading
|
|
167
|
-
showReset={hasFilteredThemes}
|
|
168
|
-
onReset={() => dispatch({ type: 'resetVisibleThemes' })}
|
|
169
|
-
>
|
|
170
|
-
Themes
|
|
171
|
-
</FrameHeading>
|
|
172
|
-
{availableThemes.map((option) => (
|
|
173
|
-
<FrameOption
|
|
174
|
-
key={option}
|
|
175
|
-
option={option}
|
|
176
|
-
selected={hasFilteredThemes && visibleThemes.includes(option)}
|
|
177
|
-
visible={visibleThemes}
|
|
178
|
-
onChange={(newThemes) => {
|
|
179
|
-
if (newThemes) {
|
|
180
|
-
dispatch({
|
|
181
|
-
type: 'updateVisibleThemes',
|
|
182
|
-
payload: { themes: newThemes },
|
|
183
|
-
});
|
|
184
|
-
} else {
|
|
185
|
-
dispatch({ type: 'resetVisibleThemes' });
|
|
186
|
-
}
|
|
187
|
-
}}
|
|
188
|
-
/>
|
|
189
|
-
))}
|
|
190
|
-
</Stack>
|
|
191
|
-
) : null}
|
|
192
|
-
</Stack>
|
|
193
|
-
</ToolbarPanel>
|
|
194
|
-
</>
|
|
168
|
+
) : null}
|
|
169
|
+
</Stack>
|
|
170
|
+
</ToolbarPanel>
|
|
195
171
|
);
|
|
196
172
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useContext, type ComponentType, Fragment } from 'react';
|
|
2
|
+
import { Helmet } from 'react-helmet';
|
|
2
3
|
import classnames from 'classnames';
|
|
3
4
|
import { useDebouncedCallback } from 'use-debounce';
|
|
4
5
|
import { Resizable } from 're-resizable';
|
|
@@ -45,6 +46,20 @@ const resolveDirection = (
|
|
|
45
46
|
return editorHidden ? 'up' : 'down';
|
|
46
47
|
};
|
|
47
48
|
|
|
49
|
+
const getTitle = (title: string | undefined) => {
|
|
50
|
+
if (title) {
|
|
51
|
+
return `${title} | Playroom`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const configTitle = window?.__playroomConfig__.title;
|
|
55
|
+
|
|
56
|
+
if (configTitle) {
|
|
57
|
+
return `${configTitle} | Playroom`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return 'Playroom';
|
|
61
|
+
};
|
|
62
|
+
|
|
48
63
|
export interface PlayroomProps {
|
|
49
64
|
components: Record<string, ComponentType>;
|
|
50
65
|
themes: string[];
|
|
@@ -65,9 +80,11 @@ export default ({ components, themes, widths, snippets }: PlayroomProps) => {
|
|
|
65
80
|
previewRenderCode,
|
|
66
81
|
previewEditorCode,
|
|
67
82
|
ready,
|
|
83
|
+
title,
|
|
68
84
|
},
|
|
69
85
|
dispatch,
|
|
70
86
|
] = useContext(StoreContext);
|
|
87
|
+
const displayedTitle = getTitle(title);
|
|
71
88
|
|
|
72
89
|
const updateEditorSize = useDebouncedCallback(
|
|
73
90
|
({
|
|
@@ -154,6 +171,11 @@ export default ({ components, themes, widths, snippets }: PlayroomProps) => {
|
|
|
154
171
|
|
|
155
172
|
return (
|
|
156
173
|
<div className={styles.root}>
|
|
174
|
+
{title === undefined ? null : (
|
|
175
|
+
<Helmet>
|
|
176
|
+
<title>{displayedTitle}</title>
|
|
177
|
+
</Helmet>
|
|
178
|
+
)}
|
|
157
179
|
<div
|
|
158
180
|
className={styles.previewContainer}
|
|
159
181
|
style={
|