squiffy-runtime 7.0.0-beta.1 → 7.0.0-beta.3
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/dist/preview-host.d.ts +3 -2
- package/dist/preview-host.js +6 -0
- package/dist/preview-host.js.map +2 -2
- package/dist/preview-html.js +1 -1
- package/dist/preview-protocol.d.ts +4 -0
- package/dist/squiffy.page.css +120 -0
- package/dist/squiffy.preview.html +275 -93
- package/dist/squiffy.runtime.css +76 -20
- package/dist/squiffy.runtime.global.js +67 -64
- package/dist/squiffy.runtime.global.js.map +1 -1
- package/dist/squiffy.runtime.js +3250 -3157
- package/dist/squiffy.runtime.js.map +1 -1
- package/package.json +8 -6
- package/src/preview-host.test.ts +17 -0
- package/src/preview-host.ts +11 -2
- package/src/preview-protocol.ts +7 -1
- package/src/preview.test.ts +14 -1
- package/src/preview.ts +6 -0
- package/src/squiffy.page.css +120 -0
- package/src/squiffy.runtime.css +76 -20
- package/src/squiffy.runtime.test.ts +30 -0
- package/src/squiffy.runtime.ts +18 -0
- package/vite.config.ts +3 -4
- package/vite.preview.config.ts +9 -5
|
@@ -10,6 +10,7 @@ export interface PreviewAssets {
|
|
|
10
10
|
files?: Record<string, Blob | ArrayBuffer | Uint8Array>;
|
|
11
11
|
urls?: Record<string, string>;
|
|
12
12
|
}
|
|
13
|
+
export type PreviewTheme = "light" | "dark" | "system";
|
|
13
14
|
export type HostMessage = {
|
|
14
15
|
type: "load";
|
|
15
16
|
story: PreviewStory;
|
|
@@ -24,6 +25,9 @@ export type HostMessage = {
|
|
|
24
25
|
} | {
|
|
25
26
|
type: "assets";
|
|
26
27
|
assets: PreviewAssets;
|
|
28
|
+
} | {
|
|
29
|
+
type: "theme";
|
|
30
|
+
theme: PreviewTheme;
|
|
27
31
|
};
|
|
28
32
|
export type PreviewMessage = {
|
|
29
33
|
type: "ready";
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/* Page layout styles for an exported story. See https://squiffystory.com/styling/ for how to customise these. */
|
|
2
|
+
|
|
3
|
+
:root
|
|
4
|
+
{
|
|
5
|
+
/* The width of the story text */
|
|
6
|
+
--squiffy-max-width: 42rem;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* Follow the reader's light or dark system setting, or what they chose with the theme button.
|
|
10
|
+
To keep a story light (or dark) whatever the setting, set ":root { color-scheme: light; }"
|
|
11
|
+
(or dark). These rules use :where() so that a :root rule like that overrides them, and the
|
|
12
|
+
theme button is hidden. */
|
|
13
|
+
:where(:root)
|
|
14
|
+
{
|
|
15
|
+
color-scheme: light dark;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
:where(:root[data-squiffy-theme="light"])
|
|
19
|
+
{
|
|
20
|
+
color-scheme: light;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:where(:root[data-squiffy-theme="dark"])
|
|
24
|
+
{
|
|
25
|
+
color-scheme: dark;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
body
|
|
29
|
+
{
|
|
30
|
+
margin: 0;
|
|
31
|
+
background-color: var(--squiffy-background);
|
|
32
|
+
color: var(--squiffy-text);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Wraps the header and the story: sets the page width and font */
|
|
36
|
+
div#squiffy-container
|
|
37
|
+
{
|
|
38
|
+
max-width: var(--squiffy-max-width);
|
|
39
|
+
margin-left: auto;
|
|
40
|
+
margin-right: auto;
|
|
41
|
+
padding: 0 1.25rem 3rem;
|
|
42
|
+
font-family: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
|
|
43
|
+
line-height: 1.6;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* The bar above the story containing the Restart and light/dark buttons. It stays at the top of
|
|
47
|
+
the window as the story scrolls under it. */
|
|
48
|
+
div#squiffy-header
|
|
49
|
+
{
|
|
50
|
+
position: sticky;
|
|
51
|
+
top: 0;
|
|
52
|
+
z-index: 1;
|
|
53
|
+
padding: 0.5rem 0;
|
|
54
|
+
background-color: var(--squiffy-background);
|
|
55
|
+
font-size: 0.875rem;
|
|
56
|
+
text-align: right;
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* A short fade under the header, so the story scrolls under it rather than being cut off */
|
|
61
|
+
div#squiffy-header::after
|
|
62
|
+
{
|
|
63
|
+
content: "";
|
|
64
|
+
position: absolute;
|
|
65
|
+
left: 0;
|
|
66
|
+
right: 0;
|
|
67
|
+
top: 100%;
|
|
68
|
+
height: 0.75rem;
|
|
69
|
+
background: linear-gradient(var(--squiffy-background), transparent);
|
|
70
|
+
pointer-events: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* The button that switches between light and dark mode. It shows a moon in light mode and a sun
|
|
74
|
+
in dark mode. */
|
|
75
|
+
button#squiffy-theme
|
|
76
|
+
{
|
|
77
|
+
margin-left: 0.75em;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Centred on the capital letters of "Restart", rather than on the line, which looks too low */
|
|
81
|
+
button#squiffy-theme svg
|
|
82
|
+
{
|
|
83
|
+
width: 1.1em;
|
|
84
|
+
height: 1.1em;
|
|
85
|
+
vertical-align: -0.25em;
|
|
86
|
+
fill: none;
|
|
87
|
+
stroke: currentColor;
|
|
88
|
+
stroke-width: 2;
|
|
89
|
+
stroke-linecap: round;
|
|
90
|
+
stroke-linejoin: round;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
button#squiffy-theme:not([data-next="light"]) .squiffy-icon-light,
|
|
94
|
+
button#squiffy-theme[data-next="light"] .squiffy-icon-dark
|
|
95
|
+
{
|
|
96
|
+
display: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* The story text */
|
|
100
|
+
div#squiffy
|
|
101
|
+
{
|
|
102
|
+
font-size: 1.125rem;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
div#squiffy :is(h1, h2, h3, h4, h5, h6)
|
|
106
|
+
{
|
|
107
|
+
line-height: 1.25;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
div#squiffy p
|
|
111
|
+
{
|
|
112
|
+
text-wrap: pretty;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* Stop images overflowing the page */
|
|
116
|
+
div#squiffy img
|
|
117
|
+
{
|
|
118
|
+
max-width: 100%;
|
|
119
|
+
height: auto;
|
|
120
|
+
}
|