@datocms/product-scenes 0.0.0-stage → 0.1.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/README.md +92 -2
- package/dist/index.d.ts +658 -0
- package/dist/index.js +23576 -0
- package/dist/product-scenes.css +6428 -0
- package/package.json +22 -4
package/README.md
CHANGED
|
@@ -1,3 +1,93 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @datocms/product-scenes
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The pictures of the DatoCMS interface on www.datocms.com, made with the real components of the product and rendered to static HTML on the server.
|
|
4
|
+
|
|
5
|
+
This package is for the DatoCMS website only. It has no support and no semver promise: any version can change the API. The licence does not let you use it in other projects.
|
|
6
|
+
|
|
7
|
+
The package is a kit of parts: the frame (`Stage`), the parts of the screens of the cms (`NavigationBar`, `ContentSidebar`, `RecordEditorLayout`, `RecordForm`, `StructuredTextInput`, `InfoAside`) and a few components of the cms (`Button`, `InfoList`, `Pill`). The website composes the scenes from the parts and gives the fake data.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @datocms/product-scenes react@19 react-dom@19
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The package has no dependencies: the build contains the components of the cms. React 19 is a peer dependency.
|
|
16
|
+
|
|
17
|
+
## The CSS and the Fonts
|
|
18
|
+
|
|
19
|
+
Import the CSS once, in the layout of the website:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import '@datocms/product-scenes/product-scenes.css';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Every rule of the file applies only inside a scene, thus the CSS of the page does not change. The file has no `@font-face` rule: the page gives the fonts that it already loads, with two custom properties on an element above the scenes.
|
|
26
|
+
|
|
27
|
+
```css
|
|
28
|
+
:root {
|
|
29
|
+
--product-scenes-font-sans: 'ABC Oracle', sans-serif;
|
|
30
|
+
--product-scenes-font-mono: 'Geist Mono', monospace;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## A Scene
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import {
|
|
38
|
+
ContentSidebar,
|
|
39
|
+
InfoAside,
|
|
40
|
+
NavigationBar,
|
|
41
|
+
RecordEditorLayout,
|
|
42
|
+
RecordForm,
|
|
43
|
+
Stage,
|
|
44
|
+
} from '@datocms/product-scenes';
|
|
45
|
+
|
|
46
|
+
export function PostEditorScene({ scheme }: { scheme: 'light' | 'dark' }) {
|
|
47
|
+
return (
|
|
48
|
+
<Stage description="The record editor of DatoCMS, with a blog post." scheme={scheme}>
|
|
49
|
+
<RecordEditorLayout
|
|
50
|
+
navigationBar={<NavigationBar user={{ name: 'Demo User' }} />}
|
|
51
|
+
sidebar={
|
|
52
|
+
<ContentSidebar
|
|
53
|
+
items={[{ kind: 'model', id: 'posts', name: '📝 Posts', active: true }]}
|
|
54
|
+
/>
|
|
55
|
+
}
|
|
56
|
+
aside={
|
|
57
|
+
<InfoAside>
|
|
58
|
+
<InfoAside.RecordInfo
|
|
59
|
+
id="Gd8Qnm7pRUKPjnCVhCYOZw"
|
|
60
|
+
status="draft"
|
|
61
|
+
createdAt="09/21/2025, 13:34"
|
|
62
|
+
updatedAt="09/21/2025, 15:39"
|
|
63
|
+
createdBy={{ name: 'Ronak Ganatra' }}
|
|
64
|
+
/>
|
|
65
|
+
</InfoAside>
|
|
66
|
+
}
|
|
67
|
+
>
|
|
68
|
+
<RecordForm title="Hello world" icon="📝">
|
|
69
|
+
<RecordForm.Field label="Title" required>
|
|
70
|
+
<RecordForm.StringInput value="Hello world" large />
|
|
71
|
+
</RecordForm.Field>
|
|
72
|
+
</RecordForm>
|
|
73
|
+
</RecordEditorLayout>
|
|
74
|
+
</Stage>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
In an Astro page, render the scene as a component, without a `client:` directive:
|
|
80
|
+
|
|
81
|
+
```astro
|
|
82
|
+
<PostEditorScene scheme="light" />
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
A model or a folder of `ContentSidebar` and the `icon` of `RecordForm` use the emoji of the model as the icon, as in the cms. A part that shows another icon takes it as a `ReactNode`.
|
|
86
|
+
|
|
87
|
+
## The Rules of a Scene
|
|
88
|
+
|
|
89
|
+
- **No `client:` directive.** A scene is static HTML. The package sends no JS to the browser, and the parts do not work in the browser.
|
|
90
|
+
- **Controlled inputs with constant values.** Give each input its value as a prop. Do not keep a state, and do not wait for a user action.
|
|
91
|
+
- **No overlays and no portals.** Do not open a dropdown, a tooltip, a modal or a popover: there is no JS to place it. Show the closed state.
|
|
92
|
+
- **Fixed dates and fixed data.** Write the dates as text. Do not read the clock and do not fetch, thus two renders give the same picture.
|
|
93
|
+
- **One `Stage` for each scene, with a `description`.** The screen is hidden from assistive technology, thus the description is the only text that a screen reader hears. Write what the picture shows. A page can show many stages.
|