slice-machine-ui 2.16.2-beta.1 → 2.16.2-beta.2

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 (37) hide show
  1. package/out/404.html +1 -1
  2. package/out/_next/static/chunks/397-e6c340070a3bcb41.js +1 -0
  3. package/out/_next/static/chunks/pages/{_app-4f1854df4dfc747d.js → _app-472afac7b4805ab7.js} +46 -46
  4. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-61a3846ae1654f54.js → [customTypeId]-389d1b7a492fb3e7.js} +1 -1
  5. package/out/_next/static/chunks/pages/{custom-types-093f2e2213561492.js → custom-types-2a5fd94ee42ba593.js} +1 -1
  6. package/out/_next/static/chunks/pages/{index-0e27ae9805b59004.js → index-02dd147957c8b40f.js} +1 -1
  7. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-91a4eb622fa3cb7c.js → [pageTypeId]-3589bd1f9138a97b.js} +1 -1
  8. package/out/_next/static/chunks/pages/{settings-0da3553b3a0acc99.js → settings-170379902605f38a.js} +1 -1
  9. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-c71823bf02dc292d.js → [variation]-6de02b8ed13b680d.js} +1 -1
  10. package/out/_next/static/chunks/pages/{slices-7e816c2b32cc6f19.js → slices-071bb494907adf0f.js} +1 -1
  11. package/out/_next/static/css/{f0e6d8449ce2bb46.css → 9c9a7de81f9ac811.css} +1 -1
  12. package/out/_next/static/l70e849kl17-sTQxi8gN6/_buildManifest.js +1 -0
  13. package/out/changelog.html +1 -1
  14. package/out/changes.html +1 -1
  15. package/out/custom-types/[customTypeId].html +1 -1
  16. package/out/custom-types.html +1 -1
  17. package/out/index.html +1 -1
  18. package/out/labs.html +1 -1
  19. package/out/page-types/[pageTypeId].html +1 -1
  20. package/out/settings.html +1 -1
  21. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  22. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  23. package/out/slices.html +1 -1
  24. package/package.json +3 -3
  25. package/src/legacy/components/App/index.tsx +0 -2
  26. package/src/modules/loading/types.ts +0 -1
  27. package/src/modules/useSliceMachineActions.ts +0 -23
  28. package/src/modules/userContext/index.ts +1 -33
  29. package/src/modules/userContext/types.ts +0 -13
  30. package/src/styles/modal.css +0 -22
  31. package/test/src/modules/userContext.test.ts +1 -50
  32. package/out/_next/static/9BX45OSSCQeaYmYslFbMt/_buildManifest.js +0 -1
  33. package/src/legacy/components/ReviewModal/ReviewForm.tsx +0 -169
  34. package/src/legacy/components/ReviewModal/ReviewFormSelect.tsx +0 -35
  35. package/src/legacy/components/ReviewModal/ReviewModal.tsx +0 -56
  36. package/src/legacy/components/ReviewModal/index.ts +0 -1
  37. /package/out/_next/static/{9BX45OSSCQeaYmYslFbMt → l70e849kl17-sTQxi8gN6}/_ssgManifest.js +0 -0
@@ -1,169 +0,0 @@
1
- import { Field, Form, Formik } from "formik";
2
- import { FC } from "react";
3
- import Modal from "react-modal";
4
- import { useSelector } from "react-redux";
5
- import {
6
- Box,
7
- Button,
8
- Card,
9
- Close,
10
- Flex,
11
- Heading,
12
- Text,
13
- Textarea,
14
- } from "theme-ui";
15
-
16
- import { telemetry } from "@/apiClient";
17
- import SliceMachineModal from "@/legacy/components/SliceMachineModal";
18
- import { isLoading } from "@/modules/loading";
19
- import { LoadingKeysEnum } from "@/modules/loading/types";
20
- import { isModalOpen } from "@/modules/modal";
21
- import { ModalKeysEnum } from "@/modules/modal/types";
22
- import useSliceMachineActions from "@/modules/useSliceMachineActions";
23
- import { SliceMachineStoreType } from "@/redux/type";
24
-
25
- import { ReviewFormSelect } from "./ReviewFormSelect";
26
-
27
- Modal.setAppElement("#__next");
28
-
29
- const reviewType = "onboarding";
30
-
31
- export const ReviewForm: FC = () => {
32
- const { isReviewLoading, isLoginModalOpen } = useSelector(
33
- (store: SliceMachineStoreType) => ({
34
- isReviewLoading: isLoading(store, LoadingKeysEnum.REVIEW),
35
- isLoginModalOpen: isModalOpen(store, ModalKeysEnum.LOGIN),
36
- }),
37
- );
38
- const { skipReview, sendAReview, startLoadingReview, stopLoadingReview } =
39
- useSliceMachineActions();
40
-
41
- const onSendAReview = (rating: number, comment: string): void => {
42
- startLoadingReview();
43
- void telemetry.track({
44
- event: "review",
45
- rating,
46
- comment,
47
- type: reviewType,
48
- });
49
- sendAReview(reviewType);
50
- stopLoadingReview();
51
- };
52
-
53
- const validateReview = ({ rating }: { rating: number; comment: string }) => {
54
- if (!rating) {
55
- return { id: "Please choose a rating" };
56
- }
57
- };
58
-
59
- return (
60
- <SliceMachineModal
61
- isOpen
62
- shouldCloseOnOverlayClick={false}
63
- onRequestClose={() => skipReview(reviewType)}
64
- closeTimeoutMS={500}
65
- contentLabel={"Review Modal"}
66
- portalClassName={"ReviewModal"}
67
- style={{
68
- content: {
69
- display: "flex",
70
- position: "initial",
71
- padding: "none",
72
- top: "initial",
73
- left: "initial",
74
- minHeight: "initial",
75
- },
76
- overlay: {
77
- top: "initial",
78
- left: "initial",
79
- right: 16,
80
- bottom: 16,
81
- position: "absolute",
82
- height: "fit-content",
83
- width: "fit-content",
84
- backgroundColor: "unset",
85
- },
86
- }}
87
- >
88
- <Formik
89
- validateOnMount
90
- initialValues={{
91
- rating: 0,
92
- comment: "",
93
- }}
94
- validate={validateReview}
95
- onSubmit={(values) => {
96
- onSendAReview(values.rating, values.comment);
97
- }}
98
- >
99
- {({ isValid }) => (
100
- <Form id="review-form">
101
- <Card>
102
- <Flex
103
- sx={{
104
- p: "16px",
105
- pl: 4,
106
- bg: "headSection",
107
- alignItems: "center",
108
- justifyContent: "space-between",
109
- borderRadius: "8px 8px 0px 0px",
110
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
111
- borderBottom: (t) => `1px solid ${t.colors?.borders}`,
112
- }}
113
- >
114
- <Heading sx={{ fontSize: "20px", mr: 4 }}>
115
- Share feedback
116
- </Heading>
117
- <Close type="button" onClick={() => skipReview(reviewType)} />
118
- </Flex>
119
- <Flex
120
- sx={{
121
- flexDirection: "column",
122
- padding: "16px 24px 32px",
123
- bg: "headSection",
124
- }}
125
- >
126
- <Text variant={"xs"} as={"p"} sx={{ maxWidth: 302, mb: 3 }}>
127
- Overall, how satisfied or dissatisfied are you with your Slice
128
- Machine experience so far?
129
- </Text>
130
- <Box
131
- mb={2}
132
- sx={{
133
- display: "flex",
134
- flex: 1,
135
- justifyContent: "space-between",
136
- }}
137
- >
138
- <Text variant={"xs"} as={"p"}>
139
- Very unsatisfied
140
- </Text>
141
- <Text variant={"xs"} as={"p"}>
142
- Very satisfied
143
- </Text>
144
- </Box>
145
- <Field name={"rating"} component={ReviewFormSelect} />
146
- <Field
147
- name={"comment"}
148
- type="text"
149
- placeholder="Tell us more..."
150
- as={Textarea}
151
- autoComplete="off"
152
- sx={{ height: 80, mb: 3 }}
153
- data-testid="review-form-comment"
154
- />
155
- <Button
156
- form={"review-form"}
157
- type="submit"
158
- disabled={!isValid || isReviewLoading || isLoginModalOpen}
159
- >
160
- Submit
161
- </Button>
162
- </Flex>
163
- </Card>
164
- </Form>
165
- )}
166
- </Formik>
167
- </SliceMachineModal>
168
- );
169
- };
@@ -1,35 +0,0 @@
1
- import { FieldProps } from "formik";
2
- import { FC } from "react";
3
- import { Box, Button } from "theme-ui";
4
-
5
- const ratingSelectable = [1, 2, 3, 4, 5];
6
-
7
- export const ReviewFormSelect: FC<FieldProps> = (props) => {
8
- const { field, form } = props;
9
-
10
- return (
11
- <Box sx={{ mb: 3, display: "flex", justifyContent: "space-between" }}>
12
- {ratingSelectable.map((rating, index) => (
13
- <Button
14
- variant="secondary"
15
- type="button"
16
- key={index}
17
- onClick={() => void form.setFieldValue("rating", rating)}
18
- className={field.value === rating ? "selected" : ""}
19
- sx={{
20
- "&:not(:last-of-type)": {
21
- mr: 1,
22
- },
23
- "&.selected": {
24
- backgroundColor: "code.gray",
25
- color: "white",
26
- },
27
- }}
28
- data-testid={`review-form-score-${rating}`}
29
- >
30
- {rating}
31
- </Button>
32
- ))}
33
- </Box>
34
- );
35
- };
@@ -1,56 +0,0 @@
1
- import { FC } from "react";
2
- import { useSelector } from "react-redux";
3
-
4
- import { hasLocal } from "@/legacy/lib/models/common/ModelData";
5
- import { selectAllCustomTypes } from "@/modules/availableCustomTypes";
6
- import { getLibraries } from "@/modules/slices";
7
- import { getLastSyncChange, getUserReview } from "@/modules/userContext";
8
- import { SliceMachineStoreType } from "@/redux/type";
9
-
10
- import { ReviewForm } from "./ReviewForm";
11
-
12
- export const ReviewModal: FC = () => {
13
- const { userReview, customTypes, libraries, lastSyncChange } = useSelector(
14
- (store: SliceMachineStoreType) => ({
15
- userReview: getUserReview(store),
16
- customTypes: selectAllCustomTypes(store),
17
- libraries: getLibraries(store),
18
- lastSyncChange: getLastSyncChange(store),
19
- }),
20
- );
21
-
22
- const sliceCount =
23
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
24
- libraries && libraries.length
25
- ? libraries.reduce((count, lib) => {
26
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
27
- if (!lib) return count;
28
- return count + lib.components.length;
29
- }, 0)
30
- : 0;
31
-
32
- const hasSliceWithinCustomType = customTypes.some(
33
- (customType) =>
34
- hasLocal(customType) &&
35
- customType.local.tabs.some(
36
- (tab) => tab.sliceZone && tab.sliceZone?.value.length > 0,
37
- ),
38
- );
39
-
40
- const hasPushedAnHourAgo = Boolean(
41
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
42
- lastSyncChange && Date.now() - lastSyncChange >= 3600000,
43
- );
44
-
45
- const isOnboardingDone =
46
- sliceCount >= 1 &&
47
- customTypes.length >= 1 &&
48
- hasSliceWithinCustomType &&
49
- hasPushedAnHourAgo;
50
-
51
- if (!userReview.onboarding && isOnboardingDone) {
52
- return <ReviewForm />;
53
- }
54
-
55
- return null;
56
- };
@@ -1 +0,0 @@
1
- export { ReviewModal } from "./ReviewModal";