slice-machine-ui 2.9.2-beta.2 → 2.9.2-beta.4

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.
Files changed (63) hide show
  1. package/out/404.html +1 -1
  2. package/out/_next/static/chunks/150-eab557690a3d3df6.js +1 -0
  3. package/out/_next/static/chunks/372-92310a383394bd51.js +1 -0
  4. package/out/_next/static/chunks/639-424b570eee9a37fb.js +1 -0
  5. package/out/_next/static/chunks/764-af46a341da795d13.js +1 -0
  6. package/out/_next/static/chunks/{772-ed8f3990453f05fe.js → 772-936f6233f8a2b1f1.js} +1 -1
  7. package/out/_next/static/chunks/882-1fd1fbf0fe97a211.js +1 -0
  8. package/out/_next/static/chunks/pages/{_app-7003611f73120dc1.js → _app-b280f3be893de784.js} +64 -64
  9. package/out/_next/static/chunks/pages/{changelog-1087db6178013180.js → changelog-3de3687d3807f3d5.js} +1 -1
  10. package/out/_next/static/chunks/pages/changes-993e3e52efb5de1f.js +1 -0
  11. package/out/_next/static/chunks/pages/{labs-b3a8a0fa91d4b67b.js → labs-20347ab849300143.js} +1 -1
  12. package/out/_next/static/chunks/pages/{settings-3113f0d4d26dfada.js → settings-1cf976f9042cdde7.js} +1 -1
  13. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-d5df6446669f32d9.js +1 -0
  14. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-a49a9a15b7d7f2cb.js +1 -0
  15. package/out/_next/static/chunks/pages/slices-b95fc968e8f1b2d2.js +1 -0
  16. package/out/_next/static/css/dd42e99c28b686f9.css +1 -0
  17. package/out/_next/static/e1hGloQkSwlrJnoIbdTxo/_buildManifest.js +1 -0
  18. package/out/changelog.html +1 -1
  19. package/out/changes.html +1 -1
  20. package/out/custom-types/[customTypeId].html +1 -1
  21. package/out/custom-types.html +1 -1
  22. package/out/index.html +1 -1
  23. package/out/labs.html +1 -1
  24. package/out/page-types/[pageTypeId].html +1 -1
  25. package/out/settings.html +1 -1
  26. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  27. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  28. package/out/slices.html +1 -1
  29. package/package.json +6 -6
  30. package/src/features/customTypes/customTypesBuilder/PageSnippetDialog/PageSnippetDialog.tsx +3 -0
  31. package/src/features/onboarding/SliceMachineOnboardingGuide/SliceMachineOnboardingGuide.tsx +17 -3
  32. package/src/features/onboarding/useOnboarding.ts +36 -8
  33. package/src/features/onboarding/useSharedOnboardingExperiment.ts +1 -1
  34. package/src/legacy/components/AuthInstructions/index.jsx +22 -18
  35. package/src/legacy/components/Card/Default.jsx +25 -19
  36. package/src/legacy/components/Card/WithTabs/index.jsx +1 -1
  37. package/src/legacy/components/Card/index.tsx +43 -46
  38. package/src/legacy/components/ConfigErrors/index.jsx +23 -22
  39. package/src/legacy/components/DeleteCTModal/index.tsx +3 -3
  40. package/src/legacy/components/DeleteSliceModal/index.tsx +3 -3
  41. package/src/legacy/components/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +4 -0
  42. package/src/legacy/components/Forms/CreateSliceModal/CreateSliceModal.tsx +3 -0
  43. package/src/legacy/components/ModalFormCard/index.tsx +29 -20
  44. package/src/legacy/components/ScreenshotChangesModal/index.tsx +28 -19
  45. package/src/legacy/components/ScreenshotPreviewModal/index.tsx +3 -3
  46. package/src/legacy/components/SliceMachineDrawer/index.tsx +3 -3
  47. package/src/legacy/components/Warnings/index.jsx +50 -45
  48. package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/DeleteSliceZoneModal.tsx +3 -3
  49. package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +4 -0
  50. package/src/legacy/lib/builders/common/EditModal/index.jsx +24 -17
  51. package/src/pages/changes.tsx +4 -0
  52. package/out/_next/static/N4L1qG2wTelLcv7q1u6zD/_buildManifest.js +0 -1
  53. package/out/_next/static/chunks/150-50ba55dc830fed3d.js +0 -1
  54. package/out/_next/static/chunks/372-8a30b6213f74cec4.js +0 -1
  55. package/out/_next/static/chunks/639-175fa5cb82faf87c.js +0 -1
  56. package/out/_next/static/chunks/764-b227a29a47c620de.js +0 -1
  57. package/out/_next/static/chunks/882-52e400abbe47296c.js +0 -1
  58. package/out/_next/static/chunks/pages/changes-15ac7bd12a3861ec.js +0 -1
  59. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-dde04caa311e3119.js +0 -1
  60. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-5e6dbc213e2cb436.js +0 -1
  61. package/out/_next/static/chunks/pages/slices-a2bd37c062dfe13d.js +0 -1
  62. package/out/_next/static/css/6dd94025935d0fdd.css +0 -1
  63. /package/out/_next/static/{N4L1qG2wTelLcv7q1u6zD → e1hGloQkSwlrJnoIbdTxo}/_ssgManifest.js +0 -0
@@ -7,6 +7,7 @@ import { ContentTabs } from "@/components/ContentTabs";
7
7
  import { ErrorBoundary } from "@/ErrorBoundary";
8
8
  import { MarkdownRenderer } from "@/features/documentation/MarkdownRenderer";
9
9
  import { useDocumentation } from "@/features/documentation/useDocumentation";
10
+ import { useOnboarding } from "@/features/onboarding/useOnboarding";
10
11
  import { useAdapterName } from "@/hooks/useAdapterName";
11
12
 
12
13
  import styles from "./PageSnippetDialog.module.css";
@@ -19,12 +20,14 @@ const PageSnippetContent: FC<PageSnippetContentProps> = ({ model }) => {
19
20
  kind: "PageSnippet",
20
21
  data: { model },
21
22
  });
23
+ const { completeStep } = useOnboarding();
22
24
 
23
25
  if (documentation.length === 0) {
24
26
  return null;
25
27
  }
26
28
 
27
29
  const trackOpenSnippet = () => {
30
+ void completeStep("codePage");
28
31
  void telemetry.track({
29
32
  event: "page-type:open-snippet",
30
33
  framework: adapter,
@@ -6,7 +6,7 @@ import {
6
6
  Text,
7
7
  useMediaQuery,
8
8
  } from "@prismicio/editor-ui";
9
- import { useState } from "react";
9
+ import { useEffect, useRef, useState } from "react";
10
10
 
11
11
  import styles from "./OnboardingGuide.module.css";
12
12
  import { OnboardingProgressStepper } from "./OnboardingProgressStepper";
@@ -22,7 +22,7 @@ export function SliceMachineOnboardingGuide() {
22
22
  return (
23
23
  <OnboardingProvider onComplete={confetti.throwConfetti}>
24
24
  <div ref={confetti.confettiContainerRef} className={styles.container}>
25
- <OnboardingGuideCard />
25
+ <OnboardingGuideCard setVisible={setVisible} />
26
26
  <div
27
27
  ref={confetti.confettiCannonRef}
28
28
  className={styles.confettiCannon}
@@ -32,10 +32,24 @@ export function SliceMachineOnboardingGuide() {
32
32
  );
33
33
  }
34
34
 
35
- function OnboardingGuideCard() {
35
+ type OnboardingGuideCardProps = {
36
+ setVisible: (isVisible: boolean) => void;
37
+ };
38
+
39
+ function OnboardingGuideCard(props: OnboardingGuideCardProps) {
40
+ const { setVisible } = props;
36
41
  const { steps, completedStepCount, isComplete } = useOnboardingContext();
37
42
  const isVisible = useMediaQuery({ min: "medium" });
38
43
 
44
+ const isMountedRef = useRef(false);
45
+ useEffect(() => {
46
+ // quick fix to prevent having the onboarding invisible but interactive when complete
47
+ if (!isMountedRef.current) {
48
+ isMountedRef.current = true;
49
+ setVisible(false);
50
+ }
51
+ }, [isVisible, setVisible]);
52
+
39
53
  if (!isVisible) return null;
40
54
 
41
55
  return (
@@ -1,8 +1,9 @@
1
- import { OnboardingState } from "@prismicio/editor-fields";
1
+ import { OnboardingState, OnboardingStepId } from "@prismicio/editor-fields";
2
2
  import { useRefGetter } from "@prismicio/editor-support/React";
3
3
  import { updateData, useRequest } from "@prismicio/editor-support/Suspense";
4
4
  import { toast } from "react-toastify";
5
5
 
6
+ import { useSharedOnboardingExperiment } from "@/features/onboarding/useSharedOnboardingExperiment";
6
7
  import { managerClient } from "@/managerClient";
7
8
 
8
9
  const { fetchOnboarding, toggleOnboarding, toggleOnboardingStep } =
@@ -10,39 +11,49 @@ const { fetchOnboarding, toggleOnboarding, toggleOnboardingStep } =
10
11
 
11
12
  async function getOnboarding() {
12
13
  try {
13
- return fetchOnboarding();
14
+ return await fetchOnboarding();
14
15
  } catch (error) {
15
16
  console.error("Failed to fetch onboarding", error);
16
17
  return undefined;
17
18
  }
18
19
  }
19
20
 
21
+ const noop = () => Promise.resolve(undefined);
22
+
20
23
  export function useOnboarding() {
21
- const onboarding = useRequest(getOnboarding, []);
24
+ const isSharedExperimentEligible = useSharedOnboardingExperiment().eligible;
25
+ const onboarding = useRequest(
26
+ isSharedExperimentEligible ? getOnboarding : noop,
27
+ [],
28
+ );
22
29
  const getOnboardingState = useRefGetter(onboarding);
23
30
 
24
31
  function updateCache(newOnboardingState: OnboardingState) {
25
32
  updateData(getOnboarding, [], newOnboardingState);
26
33
  }
27
34
 
28
- async function toggleStep(stepId: string) {
35
+ async function toggleStep(stepId: OnboardingStepId) {
36
+ if (!isSharedExperimentEligible) return [];
37
+
29
38
  const onboardingState = getOnboardingState();
30
39
  if (!onboardingState) return [];
31
40
 
32
41
  try {
33
- const { completedSteps } = await toggleOnboardingStep(stepId);
42
+ const { completedSteps } = await toggleOnboardingStep(String(stepId));
34
43
  updateCache({ ...onboardingState, completedSteps });
35
44
 
36
45
  return completedSteps;
37
46
  } catch (error) {
38
47
  toast.error("Failed to complete/undo step");
39
- console.error("Error toggling onboarding step", error);
48
+ console.error("Failed to toggle onboarding step", error);
40
49
 
41
50
  return onboardingState.completedSteps;
42
51
  }
43
52
  }
44
53
 
45
54
  async function toggleGuide() {
55
+ if (!isSharedExperimentEligible) return;
56
+
46
57
  const onboardingState = getOnboardingState();
47
58
  if (!onboardingState) return;
48
59
 
@@ -54,9 +65,26 @@ export function useOnboarding() {
54
65
  } catch (error) {
55
66
  updateCache({ ...onboardingState, isDismissed: wasDismissed }); // rollback
56
67
  toast.error("Failed to hide/show onboarding");
57
- console.error("Error toggling onboarding", error);
68
+ console.error("Failed to toggle onboarding", error);
69
+ }
70
+ }
71
+
72
+ async function completeStep(stepId: OnboardingStepId) {
73
+ if (!isSharedExperimentEligible) return;
74
+
75
+ const onboardingState = getOnboardingState();
76
+ if (!onboardingState) return;
77
+
78
+ try {
79
+ // TODO: Refactor when the API has complete action (DT-2389)
80
+ if (!onboardingState.completedSteps.includes(String(stepId))) {
81
+ await toggleStep(stepId);
82
+ }
83
+ } catch (error) {
84
+ toast.error("Failed to complete onboarding step");
85
+ console.error("Failed to complete onboarding step", error);
58
86
  }
59
87
  }
60
88
 
61
- return { onboarding, toggleStep, toggleGuide };
89
+ return { onboarding, toggleStep, completeStep, toggleGuide };
62
90
  }
@@ -1,6 +1,6 @@
1
1
  import { useExperimentVariant } from "@/hooks/useExperimentVariant";
2
2
 
3
3
  export const useSharedOnboardingExperiment = () => {
4
- const variant = useExperimentVariant("slicemachine-shared-onboarding");
4
+ const variant = useExperimentVariant("shared-onboarding");
5
5
  return { eligible: variant?.value === "with-shared-onboarding" };
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { Flex, Heading, Text } from "theme-ui";
2
2
 
3
- import Card from "../Card";
3
+ import { Card, useCardRadius } from "../Card";
4
4
 
5
5
  const AuthInstructions = () => (
6
6
  <Card
@@ -8,23 +8,7 @@ const AuthInstructions = () => (
8
8
  bg="gray"
9
9
  bodySx={{ p: 3 }}
10
10
  sx={{ maxWidth: "480px", m: 3 }}
11
- Header={({ radius }) => (
12
- <Flex
13
- sx={{
14
- p: 3,
15
- pl: 4,
16
- bg: "headSection",
17
- alignItems: "center",
18
- justifyContent: "space-between",
19
- borderTopLeftRadius: radius,
20
- borderTopRightRadius: radius,
21
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
22
- borderBottom: (t) => `1px solid ${t.colors?.borders}`,
23
- }}
24
- >
25
- <Heading as="h3">Log in to Prismic</Heading>
26
- </Flex>
27
- )}
11
+ Header={<CardHeader />}
28
12
  >
29
13
  <Text as="p">
30
14
  In order to access your builder, you will need to be connected to Prismic.
@@ -46,4 +30,24 @@ const AuthInstructions = () => (
46
30
  </Card>
47
31
  );
48
32
 
33
+ function CardHeader() {
34
+ const radius = useCardRadius();
35
+ return (
36
+ <Flex
37
+ sx={{
38
+ p: 3,
39
+ pl: 4,
40
+ bg: "headSection",
41
+ alignItems: "center",
42
+ justifyContent: "space-between",
43
+ borderTopLeftRadius: radius,
44
+ borderTopRightRadius: radius,
45
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
46
+ borderBottom: (t) => `1px solid ${t.colors?.borders}`,
47
+ }}
48
+ >
49
+ <Heading as="h3">Log in to Prismic</Heading>
50
+ </Flex>
51
+ );
52
+ }
49
53
  export default AuthInstructions;
@@ -1,6 +1,6 @@
1
1
  import { Box, Close, Flex } from "theme-ui";
2
2
 
3
- import Card from "./";
3
+ import { Card, useCardRadius } from "./";
4
4
 
5
5
  const DefaultCard = ({
6
6
  children,
@@ -8,35 +8,21 @@ const DefaultCard = ({
8
8
  HeaderContent,
9
9
  close,
10
10
  sx = {},
11
- headerSx = {},
12
11
  }) => (
13
12
  <Card
14
13
  borderFooter
15
14
  footerSx={{ p: 0 }}
16
15
  bodySx={{ pt: 2, pb: 4, px: 4 }}
17
16
  sx={{ border: "none", ...sx }}
18
- Header={({ radius }) => (
19
- <Flex
20
- sx={{
21
- p: 3,
22
- pl: 4,
23
- bg: "headSection",
24
- alignItems: "center",
25
- justifyContent: "space-between",
26
- borderTopLeftRadius: radius,
27
- borderTopRightRadius: radius,
28
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
29
- borderBottom: (t) => `1px solid ${t.colors?.borders}`,
30
- ...headerSx,
31
- }}
32
- >
17
+ Header={
18
+ <CardHeader>
33
19
  {HeaderContent}
34
20
  {
35
21
  // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions, @typescript-eslint/no-unsafe-assignment
36
22
  close ? <Close onClick={close} type="button" /> : null
37
23
  }
38
- </Flex>
39
- )}
24
+ </CardHeader>
25
+ }
40
26
  Footer={
41
27
  // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
42
28
  FooterContent ? (
@@ -51,4 +37,24 @@ const DefaultCard = ({
51
37
  </Card>
52
38
  );
53
39
 
40
+ function CardHeader({ children }) {
41
+ const radius = useCardRadius();
42
+ return (
43
+ <Flex
44
+ sx={{
45
+ p: 3,
46
+ pl: 4,
47
+ bg: "headSection",
48
+ alignItems: "center",
49
+ justifyContent: "space-between",
50
+ borderTopLeftRadius: radius,
51
+ borderTopRightRadius: radius,
52
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
53
+ borderBottom: (t) => `1px solid ${t.colors?.borders}`,
54
+ }}
55
+ >
56
+ {children}
57
+ </Flex>
58
+ );
59
+ }
54
60
  export default DefaultCard;
@@ -2,7 +2,7 @@ import { Children, memo, useState } from "react";
2
2
  import { TabPanel, Tabs } from "react-tabs";
3
3
  import { Box } from "theme-ui";
4
4
 
5
- import Card from "../";
5
+ import { Card } from "../";
6
6
  import { CustomTab as Tab, CustomTabList as TabList } from "./components";
7
7
 
8
8
  const WithTabs = ({
@@ -1,11 +1,14 @@
1
- import React from "react";
1
+ import React, { createContext, useContext } from "react";
2
2
  import { Card as ThemeCard, ThemeUIStyleObject } from "theme-ui";
3
3
 
4
4
  import { CardBox, CardBoxProps } from "./CardBox";
5
5
 
6
+ const CardRadiusContext = createContext<string>("6px");
7
+
8
+ export const useCardRadius = () => useContext(CardRadiusContext);
6
9
  interface CardProps extends Omit<CardBoxProps, "withRadius"> {
7
- Header?: React.FC<{ radius: string }> | JSX.Element | null;
8
- SubHeader?: React.FC<{ radius: string }> | null;
10
+ Header?: JSX.Element | null;
11
+ SubHeader?: JSX.Element | null;
9
12
  Body?: React.FC | null;
10
13
  Footer?: React.FC | JSX.Element | null;
11
14
  borderFooter?: boolean;
@@ -13,7 +16,7 @@ interface CardProps extends Omit<CardBoxProps, "withRadius"> {
13
16
  footerSx?: ThemeUIStyleObject;
14
17
  }
15
18
 
16
- const Card: React.FC<CardProps> = ({
19
+ export const Card: React.FC<CardProps> = ({
17
20
  Header = null,
18
21
  SubHeader = null,
19
22
  Body = null,
@@ -28,47 +31,41 @@ const Card: React.FC<CardProps> = ({
28
31
  children,
29
32
  ...rest
30
33
  }) => (
31
- <ThemeCard
32
- sx={{
33
- border: (t) => `1px solid ${String(t.colors?.borders)}`,
34
- borderRadius: radius,
35
- ...sx,
36
- }}
37
- {...rest}
38
- >
39
- {Header ? (
40
- typeof Header === "object" ? (
41
- Header
42
- ) : (
43
- <Header radius={radius} />
44
- )
45
- ) : null}
46
- {SubHeader ? <SubHeader radius={radius} /> : null}
47
- <CardBox bg={bg} background={background} sx={bodySx} withRadius={!Footer}>
48
- {Body ? <Body /> : null}
49
- {/* eslint-disable-next-line @typescript-eslint/strict-boolean-expressions */}
50
- {children ? children : null}
51
- </CardBox>
52
- {Footer ? (
53
- <CardBox
54
- bg={bg}
55
- background={background}
56
- sx={{
57
- ...(borderFooter
58
- ? {
59
- borderTop: ({ colors }) =>
60
- `1px solid ${String(colors?.borders)}`,
61
- }
62
- : null),
63
- ...footerSx,
64
- }}
65
- radius={radius}
66
- withRadius
67
- >
68
- {typeof Footer === "object" ? Footer : <Footer />}
34
+ <CardRadiusContext.Provider value={radius}>
35
+ <ThemeCard
36
+ sx={{
37
+ border: (t) => `1px solid ${String(t.colors?.borders)}`,
38
+ borderRadius: radius,
39
+ ...sx,
40
+ }}
41
+ {...rest}
42
+ >
43
+ {Header ? Header : null}
44
+ {SubHeader ? SubHeader : null}
45
+ <CardBox bg={bg} background={background} sx={bodySx} withRadius={!Footer}>
46
+ {Body ? <Body /> : null}
47
+ {/* eslint-disable-next-line @typescript-eslint/strict-boolean-expressions */}
48
+ {children ? children : null}
69
49
  </CardBox>
70
- ) : null}
71
- </ThemeCard>
50
+ {Footer ? (
51
+ <CardBox
52
+ bg={bg}
53
+ background={background}
54
+ sx={{
55
+ ...(borderFooter
56
+ ? {
57
+ borderTop: ({ colors }) =>
58
+ `1px solid ${String(colors?.borders)}`,
59
+ }
60
+ : null),
61
+ ...footerSx,
62
+ }}
63
+ radius={radius}
64
+ withRadius
65
+ >
66
+ {typeof Footer === "object" ? Footer : <Footer />}
67
+ </CardBox>
68
+ ) : null}
69
+ </ThemeCard>
70
+ </CardRadiusContext.Provider>
72
71
  );
73
-
74
- export default Card;
@@ -1,30 +1,10 @@
1
1
  import { Box, Flex, Heading, Text } from "theme-ui";
2
2
 
3
- import Card from "@/legacy/components/Card";
3
+ import { Card, useCardRadius } from "@/legacy/components/Card";
4
4
  import Li from "@/legacy/components/Li";
5
5
 
6
6
  const ConfigErrors = ({ errors }) => (
7
- <Card
8
- bg="background"
9
- bodySx={{ p: 3 }}
10
- Header={({ radius }) => (
11
- <Flex
12
- sx={{
13
- p: 3,
14
- alignItems: "center",
15
- justifyContent: "space-between",
16
- borderTopLeftRadius: radius,
17
- borderTopRightRadius: radius,
18
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
19
- borderBottom: (t) => `1px solid ${t.colors?.borders}`,
20
- }}
21
- >
22
- <Heading as="h3">
23
- Your slicemachine.config.json file contains errors
24
- </Heading>
25
- </Flex>
26
- )}
27
- >
7
+ <Card bg="background" bodySx={{ p: 3 }} Header={<CardHeader />}>
28
8
  {
29
9
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
30
10
  Object.entries(errors).map(([key, value]) => (
@@ -65,4 +45,25 @@ const ConfigErrors = ({ errors }) => (
65
45
  </Card>
66
46
  );
67
47
 
48
+ function CardHeader() {
49
+ const radius = useCardRadius();
50
+ return (
51
+ <Flex
52
+ sx={{
53
+ p: 3,
54
+ alignItems: "center",
55
+ justifyContent: "space-between",
56
+ borderTopLeftRadius: radius,
57
+ borderTopRightRadius: radius,
58
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
59
+ borderBottom: (t) => `1px solid ${t.colors?.borders}`,
60
+ }}
61
+ >
62
+ <Heading as="h3">
63
+ Your slicemachine.config.json file contains errors
64
+ </Heading>
65
+ </Flex>
66
+ );
67
+ }
68
+
68
69
  export default ConfigErrors;
@@ -7,7 +7,7 @@ import { Close, Flex, Heading, Text, useThemeUI } from "theme-ui";
7
7
  import { deleteCustomType } from "@/features/customTypes/actions/deleteCustomType";
8
8
  import { CUSTOM_TYPES_MESSAGES } from "@/features/customTypes/customTypesMessages";
9
9
  import { Button } from "@/legacy/components/Button";
10
- import Card from "@/legacy/components/Card";
10
+ import { Card } from "@/legacy/components/Card";
11
11
  import SliceMachineModal from "@/legacy/components/SliceMachineModal";
12
12
  import useSliceMachineActions from "@/modules/useSliceMachineActions";
13
13
 
@@ -64,7 +64,7 @@ export const DeleteCustomTypeModal: React.FunctionComponent<
64
64
  }}
65
65
  sx={{ border: "none", overflow: "hidden" }}
66
66
  borderFooter
67
- Header={() => (
67
+ Header={
68
68
  <Flex
69
69
  sx={{
70
70
  position: "sticky",
@@ -88,7 +88,7 @@ export const DeleteCustomTypeModal: React.FunctionComponent<
88
88
  </Flex>
89
89
  <Close type="button" onClick={() => onClose()} />
90
90
  </Flex>
91
- )}
91
+ }
92
92
  Footer={() => (
93
93
  <Flex
94
94
  sx={{
@@ -5,7 +5,7 @@ import { Close, Flex, Heading, Paragraph, Text, useThemeUI } from "theme-ui";
5
5
  import { deleteSlice } from "@/features/slices/actions/deleteSlice";
6
6
  import { useAutoSync } from "@/features/sync/AutoSyncProvider";
7
7
  import { Button } from "@/legacy/components/Button";
8
- import Card from "@/legacy/components/Card";
8
+ import { Card } from "@/legacy/components/Card";
9
9
  import SliceMachineModal from "@/legacy/components/SliceMachineModal";
10
10
  import useSliceMachineActions from "@/modules/useSliceMachineActions";
11
11
 
@@ -68,7 +68,7 @@ export const DeleteSliceModal: React.FunctionComponent<
68
68
  }}
69
69
  sx={{ border: "none" }}
70
70
  borderFooter
71
- Header={() => (
71
+ Header={
72
72
  <Flex
73
73
  sx={{
74
74
  position: "sticky",
@@ -92,7 +92,7 @@ export const DeleteSliceModal: React.FunctionComponent<
92
92
  </Flex>
93
93
  <Close type="button" onClick={onClose} />
94
94
  </Flex>
95
- )}
95
+ }
96
96
  Footer={() => (
97
97
  <Flex
98
98
  sx={{
@@ -12,6 +12,7 @@ import {
12
12
  } from "@/features/customTypes/actions/createCustomType";
13
13
  import { CUSTOM_TYPES_CONFIG } from "@/features/customTypes/customTypesConfig";
14
14
  import { CUSTOM_TYPES_MESSAGES } from "@/features/customTypes/customTypesMessages";
15
+ import { useOnboarding } from "@/features/onboarding/useOnboarding";
15
16
  import { useAutoSync } from "@/features/sync/AutoSyncProvider";
16
17
  import ModalFormCard from "@/legacy/components/ModalFormCard";
17
18
  import { API_ID_REGEX } from "@/legacy/lib/consts";
@@ -50,6 +51,7 @@ export const CreateCustomTypeModal: React.FC<CreateCustomTypeModalProps> = ({
50
51
  onOpenChange,
51
52
  }) => {
52
53
  const { createCustomTypeSuccess } = useSliceMachineActions();
54
+ const { completeStep } = useOnboarding();
53
55
 
54
56
  const { customTypeIds, customTypeLabels } = useSelector(
55
57
  (store: SliceMachineStoreType) => ({
@@ -84,6 +86,8 @@ export const CreateCustomTypeModal: React.FC<CreateCustomTypeModalProps> = ({
84
86
  });
85
87
 
86
88
  syncChanges();
89
+
90
+ if (format === "page") void completeStep("createPageType");
87
91
  },
88
92
  });
89
93
 
@@ -4,6 +4,7 @@ import Select from "react-select";
4
4
  import { Box, Label } from "theme-ui";
5
5
 
6
6
  import { getState } from "@/apiClient";
7
+ import { useOnboarding } from "@/features/onboarding/useOnboarding";
7
8
  import { createSlice } from "@/features/slices/actions/createSlice";
8
9
  import { useAutoSync } from "@/features/sync/AutoSyncProvider";
9
10
  import ModalFormCard from "@/legacy/components/ModalFormCard";
@@ -32,6 +33,7 @@ export const CreateSliceModal: FC<CreateSliceModalProps> = ({
32
33
  const { createSliceSuccess } = useSliceMachineActions();
33
34
  const [isCreatingSlice, setIsCreatingSlice] = useState(false);
34
35
  const { syncChanges } = useAutoSync();
36
+ const { completeStep } = useOnboarding();
35
37
 
36
38
  const onSubmit = async (values: FormValues) => {
37
39
  const sliceName = values.sliceName;
@@ -49,6 +51,7 @@ export const CreateSliceModal: FC<CreateSliceModalProps> = ({
49
51
  createSliceSuccess(serverState.libraries);
50
52
  onSuccess(newSlice, libraryName);
51
53
  syncChanges();
54
+ void completeStep("createSlice");
52
55
  },
53
56
  });
54
57
  };
@@ -17,7 +17,7 @@ import { Button as ThemeButton, Close, Flex, Heading } from "theme-ui";
17
17
  import { Button } from "@/legacy/components/Button";
18
18
  import SliceMachineModal from "@/legacy/components/SliceMachineModal";
19
19
 
20
- import Card from "../Card";
20
+ import { Card, useCardRadius } from "../Card";
21
21
 
22
22
  type ModalCardProps<T extends FormikValues> = {
23
23
  children: (props: {
@@ -120,27 +120,12 @@ function ModalCard<Values extends FormikValues>({
120
120
  bodySx={{ px: 4, py: 4 }}
121
121
  sx={{ border: "none" }}
122
122
  {...cardProps}
123
- Header={({ radius }: { radius: string | number }) => (
124
- <Flex
125
- sx={{
126
- position: "sticky",
127
- top: 0,
128
- zIndex: 1,
129
- p: "16px",
130
- pl: 4,
131
- bg: "headSection",
132
- alignItems: "center",
133
- justifyContent: "space-between",
134
- borderTopLeftRadius: radius,
135
- borderTopRightRadius: radius,
136
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
137
- borderBottom: (t) => `1px solid ${t.colors?.borders}`,
138
- }}
139
- >
123
+ Header={
124
+ <CardHeader>
140
125
  <Heading sx={{ fontSize: "20px" }}>{title}</Heading>
141
126
  <Close type="button" onClick={close} />
142
- </Flex>
143
- )}
127
+ </CardHeader>
128
+ }
144
129
  Footer={
145
130
  !omitFooter ? (
146
131
  <Flex
@@ -200,4 +185,28 @@ function ModalCard<Values extends FormikValues>({
200
185
  );
201
186
  }
202
187
 
188
+ function CardHeader({ children }: { children: ReactNode }) {
189
+ const radius = useCardRadius();
190
+ return (
191
+ <Flex
192
+ sx={{
193
+ position: "sticky",
194
+ top: 0,
195
+ zIndex: 1,
196
+ p: "16px",
197
+ pl: 4,
198
+ bg: "headSection",
199
+ alignItems: "center",
200
+ justifyContent: "space-between",
201
+ borderTopLeftRadius: radius,
202
+ borderTopRightRadius: radius,
203
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
204
+ borderBottom: (t) => `1px solid ${t.colors?.borders}`,
205
+ }}
206
+ >
207
+ {children}
208
+ </Flex>
209
+ );
210
+ }
211
+
203
212
  export default ModalCard;