slice-machine-ui 1.19.2-dev-in-app-guide.4 → 1.19.2-dev-in-app-guide.6
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/components/ReviewModal/ReviewModal.tsx +1 -1
- package/out/404.html +1 -1
- package/out/_next/static/chunks/pages/{_app-9ffa8e445771129a.js → _app-4619fd37e2e28f3a.js} +2 -2
- package/out/_next/static/css/{bca8066fd65eed7f.css → 636d0d830ddba7ef.css} +1 -1
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +4 -4
- package/pages/_app.tsx +13 -11
- package/src/components/Counter/Counter.css.ts +2 -1
- package/src/components/Counter/Counter.stories.tsx +1 -8
- package/src/components/Counter/Counter.tsx +6 -8
- package/src/features/inAppGuide/InAppGuideContext.tsx +9 -11
- package/src/features/inAppGuide/InAppGuideDialog.tsx +2 -9
- package/src/features/inAppGuide/inAppGuideContent.tsx +1 -1
- package/src/hooks/usePersistedState.ts +16 -5
- package/src/icons/FlowerBackgroundIcon.tsx +2 -1
- /package/out/_next/static/{XQc09AlJRBbdJ0W94EWuw → bJi5cJQxUaWOZTJHqTARk}/_buildManifest.js +0 -0
- /package/out/_next/static/{XQc09AlJRBbdJ0W94EWuw → bJi5cJQxUaWOZTJHqTARk}/_ssgManifest.js +0 -0
package/pages/_app.tsx
CHANGED
|
@@ -35,6 +35,7 @@ import { ThemeProvider as ThemeUIThemeProvider, useThemeUI } from "theme-ui";
|
|
|
35
35
|
|
|
36
36
|
import { AppLayout, AppLayoutContent } from "@components/AppLayout";
|
|
37
37
|
import { InAppGuideProvider } from "@src/features/inAppGuide/InAppGuideContext";
|
|
38
|
+
import { InAppGuideDialog } from "@src/features/inAppGuide/InAppGuideDialog";
|
|
38
39
|
|
|
39
40
|
import SliceMachineApp from "../components/App";
|
|
40
41
|
import LoadingPage from "../components/LoadingPage";
|
|
@@ -151,17 +152,18 @@ function MyApp({
|
|
|
151
152
|
);
|
|
152
153
|
}}
|
|
153
154
|
>
|
|
154
|
-
<
|
|
155
|
-
<
|
|
156
|
-
<
|
|
157
|
-
<
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
155
|
+
<InAppGuideProvider>
|
|
156
|
+
<RouteChangeProvider>
|
|
157
|
+
<Suspense fallback={<LoadingPage />}>
|
|
158
|
+
<ComponentLayout>
|
|
159
|
+
<Component {...pageProps} />
|
|
160
|
+
</ComponentLayout>
|
|
161
|
+
</Suspense>
|
|
162
|
+
</RouteChangeProvider>
|
|
163
|
+
<Suspense>
|
|
164
|
+
<InAppGuideDialog />
|
|
165
|
+
</Suspense>
|
|
166
|
+
</InAppGuideProvider>
|
|
165
167
|
</ErrorBoundary>
|
|
166
168
|
</PersistGate>
|
|
167
169
|
</ConnectedRouter>
|
|
@@ -11,14 +11,15 @@ export const root = sprinkles({
|
|
|
11
11
|
export const count = style([
|
|
12
12
|
sprinkles({
|
|
13
13
|
all: "unset",
|
|
14
|
+
display: "revert",
|
|
14
15
|
color: colors.grey1,
|
|
16
|
+
fontFamily: "body",
|
|
15
17
|
position: "absolute",
|
|
16
18
|
}),
|
|
17
19
|
{
|
|
18
20
|
fontSize: "9px",
|
|
19
21
|
fontWeight: 500,
|
|
20
22
|
left: "50%",
|
|
21
|
-
lineHeight: "32px",
|
|
22
23
|
top: "50%",
|
|
23
24
|
transform: "translate(-50%, -50%)",
|
|
24
25
|
},
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
|
|
3
|
-
import { FlowerBackgroundIcon } from "@src/icons/FlowerBackgroundIcon";
|
|
4
|
-
|
|
5
3
|
import { Counter } from "./Counter";
|
|
6
4
|
|
|
7
5
|
type Story = StoryObj<typeof meta>;
|
|
8
6
|
|
|
9
7
|
const meta = {
|
|
10
8
|
component: Counter,
|
|
11
|
-
argTypes: {
|
|
12
|
-
backgroundIcon: { control: { disable: true } },
|
|
13
|
-
children: { control: { disable: true } },
|
|
14
|
-
},
|
|
15
9
|
} satisfies Meta<typeof Counter>;
|
|
16
10
|
|
|
17
11
|
export default meta;
|
|
18
12
|
|
|
19
13
|
export const Default = {
|
|
20
14
|
args: {
|
|
21
|
-
|
|
22
|
-
children: 1,
|
|
15
|
+
children: "1",
|
|
23
16
|
},
|
|
24
17
|
} satisfies Story;
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { FC, PropsWithChildren
|
|
1
|
+
import { FC, PropsWithChildren } from "react";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { FlowerBackgroundIcon } from "@src/icons/FlowerBackgroundIcon";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
backgroundIcon: ReactNode;
|
|
7
|
-
}>;
|
|
5
|
+
import * as styles from "./Counter.css";
|
|
8
6
|
|
|
9
|
-
export const Counter: FC<
|
|
10
|
-
const {
|
|
7
|
+
export const Counter: FC<PropsWithChildren> = (props) => {
|
|
8
|
+
const { children } = props;
|
|
11
9
|
|
|
12
10
|
return (
|
|
13
11
|
<div className={styles.root}>
|
|
14
|
-
|
|
12
|
+
<FlowerBackgroundIcon />
|
|
15
13
|
<span className={styles.count}>{children}</span>
|
|
16
14
|
</div>
|
|
17
15
|
);
|
|
@@ -5,12 +5,11 @@ import {
|
|
|
5
5
|
SetStateAction,
|
|
6
6
|
createContext,
|
|
7
7
|
useContext,
|
|
8
|
+
useMemo,
|
|
8
9
|
} from "react";
|
|
9
10
|
|
|
10
11
|
import { usePersistedState } from "@src/hooks/usePersistedState";
|
|
11
12
|
|
|
12
|
-
import { InAppGuideDialog } from "./InAppGuideDialog";
|
|
13
|
-
|
|
14
13
|
type InAppGuideContextValue = {
|
|
15
14
|
isInAppGuideOpen: boolean;
|
|
16
15
|
setIsInAppGuideOpen: Dispatch<SetStateAction<boolean>>;
|
|
@@ -23,19 +22,18 @@ export const InAppGuideContext = createContext<
|
|
|
23
22
|
export const InAppGuideProvider: FC<PropsWithChildren> = (props) => {
|
|
24
23
|
const { children } = props;
|
|
25
24
|
const [isInAppGuideOpen, setIsInAppGuideOpen] = usePersistedState(
|
|
26
|
-
true,
|
|
27
25
|
"isInAppGuideOpen",
|
|
26
|
+
true,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const memoizedValue = useMemo(
|
|
30
|
+
() => ({ isInAppGuideOpen, setIsInAppGuideOpen }),
|
|
31
|
+
[isInAppGuideOpen, setIsInAppGuideOpen],
|
|
28
32
|
);
|
|
29
33
|
|
|
30
34
|
return (
|
|
31
|
-
<InAppGuideContext.Provider
|
|
32
|
-
value={{
|
|
33
|
-
isInAppGuideOpen,
|
|
34
|
-
setIsInAppGuideOpen,
|
|
35
|
-
}}
|
|
36
|
-
>
|
|
35
|
+
<InAppGuideContext.Provider value={memoizedValue}>
|
|
37
36
|
{children}
|
|
38
|
-
<InAppGuideDialog />
|
|
39
37
|
</InAppGuideContext.Provider>
|
|
40
38
|
);
|
|
41
39
|
};
|
|
@@ -43,7 +41,7 @@ export const InAppGuideProvider: FC<PropsWithChildren> = (props) => {
|
|
|
43
41
|
export const useInAppGuide = () => {
|
|
44
42
|
const context = useContext(InAppGuideContext);
|
|
45
43
|
if (context === undefined) {
|
|
46
|
-
throw new Error("useInAppGuide must be used within
|
|
44
|
+
throw new Error("useInAppGuide must be used within an InAppGuideProvider");
|
|
47
45
|
}
|
|
48
46
|
return context;
|
|
49
47
|
};
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
} from "@prismicio/editor-ui";
|
|
13
13
|
|
|
14
14
|
import { Counter } from "@src/components/Counter";
|
|
15
|
-
import { FlowerBackgroundIcon } from "@src/icons/FlowerBackgroundIcon";
|
|
16
15
|
import { HelpIcon } from "@src/icons/HelpIcon";
|
|
17
16
|
import { useIsEmptyProject } from "@src/hooks/useIsEmptyProject";
|
|
18
17
|
|
|
@@ -78,11 +77,7 @@ export const InAppGuideDialog: FC = () => {
|
|
|
78
77
|
<DialogHeader title={inAppGuideContent.title} />
|
|
79
78
|
<DialogContent>
|
|
80
79
|
<ScrollArea>
|
|
81
|
-
<Box
|
|
82
|
-
flexDirection="column"
|
|
83
|
-
padding={{ inline: 16, block: 8 }}
|
|
84
|
-
gap={8}
|
|
85
|
-
>
|
|
80
|
+
<Box flexDirection="column" padding={{ inline: 16, block: 8 }}>
|
|
86
81
|
<Text>{inAppGuideContent.description}</Text>
|
|
87
82
|
</Box>
|
|
88
83
|
|
|
@@ -94,9 +89,7 @@ export const InAppGuideDialog: FC = () => {
|
|
|
94
89
|
<Box key={index} flexDirection="column">
|
|
95
90
|
<Box flexDirection="column" padding={16} gap={8}>
|
|
96
91
|
<Box alignItems="center" gap={8}>
|
|
97
|
-
<Counter
|
|
98
|
-
{index + 1}
|
|
99
|
-
</Counter>
|
|
92
|
+
<Counter>{index + 1}</Counter>
|
|
100
93
|
<Text component="h3" variant="bold">
|
|
101
94
|
{content.title}
|
|
102
95
|
</Text>
|
|
@@ -52,7 +52,7 @@ export function useInAppGuideContent() {
|
|
|
52
52
|
<>
|
|
53
53
|
To render the page, run your project in your terminal and open
|
|
54
54
|
localhost to the page UID.{" "}
|
|
55
|
-
<Text variant="italic" component="span"
|
|
55
|
+
<Text variant="italic" component="span">
|
|
56
56
|
Example:
|
|
57
57
|
</Text>{" "}
|
|
58
58
|
localhost:3000/my_page_uid
|
|
@@ -2,21 +2,32 @@ import { Dispatch, SetStateAction, useEffect, useState } from "react";
|
|
|
2
2
|
|
|
3
3
|
type PersistedState<T> = [T, Dispatch<SetStateAction<T>>];
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const SLICE_MACHINE_STORAGE_PREFIX = "slice-machine";
|
|
6
6
|
|
|
7
7
|
export function usePersistedState<T>(
|
|
8
|
-
defaultValue: T,
|
|
9
8
|
key: string,
|
|
9
|
+
defaultValue: T,
|
|
10
10
|
): PersistedState<T> {
|
|
11
11
|
const computedKey = `${SLICE_MACHINE_STORAGE_PREFIX}_${key}`;
|
|
12
|
+
|
|
12
13
|
const [value, setValue] = useState<T>(() => {
|
|
13
|
-
|
|
14
|
+
try {
|
|
15
|
+
const value = localStorage.getItem(computedKey);
|
|
16
|
+
|
|
17
|
+
return value !== null ? (JSON.parse(value) as T) : defaultValue;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.warn(`Error reading localStorage key “${computedKey}”:`, error);
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
return defaultValue;
|
|
22
|
+
}
|
|
16
23
|
});
|
|
17
24
|
|
|
18
25
|
useEffect(() => {
|
|
19
|
-
|
|
26
|
+
try {
|
|
27
|
+
localStorage.setItem(computedKey, JSON.stringify(value));
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.warn(`Error setting localStorage key “${computedKey}”:`, error);
|
|
30
|
+
}
|
|
20
31
|
}, [computedKey, value]);
|
|
21
32
|
|
|
22
33
|
return [value, setValue];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
|
|
3
|
-
export const FlowerBackgroundIcon: FC = () => (
|
|
3
|
+
export const FlowerBackgroundIcon: FC = (props) => (
|
|
4
4
|
<svg
|
|
5
5
|
width="16"
|
|
6
6
|
height="16"
|
|
7
7
|
viewBox="0 0 16 16"
|
|
8
8
|
fill="none"
|
|
9
9
|
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
{...props}
|
|
10
11
|
>
|
|
11
12
|
<path
|
|
12
13
|
d="M16 8C15.9847 7.44998 15.8169 6.91443 15.5147 6.45381C15.2133 5.99404 14.7893 5.62622 14.2903 5.39293C14.4802 4.87612 14.5202 4.31673 14.4095 3.77778C14.298 3.23797 14.0375 2.74074 13.6586 2.34142C13.2584 1.96254 12.762 1.70285 12.2222 1.59046C11.6833 1.47978 11.1239 1.5198 10.6071 1.70966C10.3746 1.20988 10.0077 0.785015 9.54704 0.48361C9.08642 0.182205 8.55087 0.0136228 8 0C7.44998 0.0144742 6.91613 0.181354 6.45636 0.48361C5.99659 0.785866 5.63133 1.21073 5.4006 1.70966C4.88293 1.5198 4.32184 1.47808 3.78118 1.59046C3.24053 1.70115 2.74244 1.96169 2.34227 2.34142C1.96339 2.74159 1.70456 3.23968 1.59472 3.77863C1.48404 4.31758 1.52661 4.87697 1.71733 5.39293C1.21754 5.62622 0.791826 5.99319 0.488719 6.45296C0.185611 6.91273 0.0161771 7.44913 0 8C0.0170285 8.55087 0.185611 9.08642 0.488719 9.54704C0.791826 10.0068 1.21754 10.3746 1.71733 10.6071C1.52661 11.123 1.48404 11.6824 1.59472 12.2214C1.70541 12.7612 1.96339 13.2584 2.34142 13.6586C2.74159 14.0358 3.23882 14.2946 3.77778 14.4061C4.31673 14.5185 4.87612 14.4777 5.39293 14.2903C5.62622 14.7893 5.99319 15.2133 6.45381 15.5155C6.91358 15.8169 7.44998 15.9847 8 16C8.55087 15.9864 9.08642 15.8186 9.54704 15.5172C10.0077 15.2158 10.3746 14.7901 10.6071 14.2912C11.1213 14.4947 11.685 14.5432 12.2273 14.4308C12.7688 14.3184 13.2661 14.0502 13.6577 13.6586C14.0494 13.2669 14.3184 12.7697 14.4308 12.2273C14.5432 11.685 14.4947 11.1213 14.2903 10.6071C14.7893 10.3738 15.2133 10.0068 15.5155 9.54619C15.8169 9.08642 15.9847 8.55002 16 8Z"
|
|
File without changes
|
|
File without changes
|