slice-machine-ui 2.19.2-beta.2 → 2.19.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.
- package/out/404.html +1 -1
- package/out/_next/static/LhgS5bFIDwBpgBpbMYvj5/_buildManifest.js +1 -0
- package/out/_next/static/chunks/{489-ce3053e1d81ade83.js → 489-32281540712d98bb.js} +1 -1
- package/out/_next/static/chunks/593-7ffd1197c3405ef8.js +1 -0
- package/out/_next/static/chunks/633-6ef64d197d323bf7.js +1 -0
- package/out/_next/static/chunks/882-48d61b2fabee28d8.js +1 -0
- package/out/_next/static/chunks/pages/{_app-83c4f5b209504941.js → _app-0f3a7a06eafa1943.js} +1 -1
- package/out/_next/static/chunks/pages/{changes-7f24b37f5bf872ae.js → changes-e66094f57453cf9c.js} +1 -1
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-1b47424a37b49dff.js → [customTypeId]-6d613b67e6967ae5.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-385f933c203e8b16.js → [pageTypeId]-40207b66190e3fcd.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-08cdeefc96106c0c.js → [variation]-22ffa2561ac66557.js} +1 -1
- package/out/_next/static/chunks/pages/{slices-bedcb854fbdca8cd.js → slices-a9b4d6d022cfcd88.js} +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 +3 -3
- package/src/features/customTypes/customTypesBuilder/CreateSliceFromImageModal/CreateSliceFromImageModal.tsx +525 -241
- package/src/features/customTypes/customTypesBuilder/CreateSliceFromImageModal/SliceCard.tsx +59 -15
- package/src/icons/FigmaIcon.tsx +33 -34
- package/src/icons/FigmaIconSquare.tsx +45 -0
- package/src/legacy/components/ScreenshotChangesModal/index.tsx +2 -2
- package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +1 -1
- package/out/_next/static/4ZbwQOH1s2JwSCJTqy_83/_buildManifest.js +0 -1
- package/out/_next/static/chunks/34-28725deef8b874b1.js +0 -1
- package/out/_next/static/chunks/658-8231c0b729e0124a.js +0 -1
- package/out/_next/static/chunks/907-bf4215e6fc238ea0.js +0 -1
- /package/out/_next/static/{4ZbwQOH1s2JwSCJTqy_83 → LhgS5bFIDwBpgBpbMYvj5}/_ssgManifest.js +0 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Button } from "@prismicio/editor-ui";
|
|
1
|
+
import { Button, Tooltip } from "@prismicio/editor-ui";
|
|
2
2
|
import { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
|
|
3
|
+
import { ReactNode } from "react";
|
|
3
4
|
|
|
4
5
|
import { Card, CardFooter, CardMedia } from "@/components/Card";
|
|
6
|
+
import { FigmaIconSquare } from "@/icons/FigmaIconSquare";
|
|
5
7
|
|
|
6
8
|
interface SliceCardProps {
|
|
7
9
|
slice: Slice;
|
|
@@ -13,12 +15,31 @@ export function SliceCard(props: SliceCardProps) {
|
|
|
13
15
|
const loading = slice.status === "uploading" || slice.status === "generating";
|
|
14
16
|
|
|
15
17
|
const error =
|
|
16
|
-
slice.status === "uploadError" ||
|
|
18
|
+
slice.status === "uploadError" ||
|
|
19
|
+
slice.status === "generateError" ||
|
|
20
|
+
slice.status === "cancelled";
|
|
17
21
|
|
|
18
22
|
const hasThumbnail =
|
|
23
|
+
slice.status === "pending" ||
|
|
19
24
|
slice.status === "generateError" ||
|
|
20
25
|
slice.status === "generating" ||
|
|
21
|
-
slice.status === "success"
|
|
26
|
+
slice.status === "success" ||
|
|
27
|
+
slice.status === "cancelled";
|
|
28
|
+
|
|
29
|
+
let action: ReactNode | undefined;
|
|
30
|
+
if (error) {
|
|
31
|
+
action = (
|
|
32
|
+
<Button startIcon="refresh" color="grey" onClick={slice.onRetry}>
|
|
33
|
+
Retry
|
|
34
|
+
</Button>
|
|
35
|
+
);
|
|
36
|
+
} else if (slice.source === "figma") {
|
|
37
|
+
action = (
|
|
38
|
+
<Tooltip content="Pasted from Figma">
|
|
39
|
+
<FigmaIconSquare />
|
|
40
|
+
</Tooltip>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
22
43
|
|
|
23
44
|
return (
|
|
24
45
|
<Card disabled={loading}>
|
|
@@ -30,16 +51,10 @@ export function SliceCard(props: SliceCardProps) {
|
|
|
30
51
|
<CardFooter
|
|
31
52
|
loading={loading}
|
|
32
53
|
startIcon={getStartIcon(slice.status)}
|
|
33
|
-
title={slice
|
|
34
|
-
subtitle={getSubtitle(slice
|
|
54
|
+
title={getTitle(slice)}
|
|
55
|
+
subtitle={getSubtitle(slice)}
|
|
35
56
|
error={error}
|
|
36
|
-
action={
|
|
37
|
-
error ? (
|
|
38
|
-
<Button startIcon="refresh" color="grey" onClick={slice.onRetry}>
|
|
39
|
-
Retry
|
|
40
|
-
</Button>
|
|
41
|
-
) : undefined
|
|
42
|
-
}
|
|
57
|
+
action={action}
|
|
43
58
|
/>
|
|
44
59
|
</Card>
|
|
45
60
|
);
|
|
@@ -48,8 +63,10 @@ export function SliceCard(props: SliceCardProps) {
|
|
|
48
63
|
export type Slice = { image: File; source: "upload" | "figma" } & (
|
|
49
64
|
| { status: "uploading" }
|
|
50
65
|
| { status: "uploadError"; onRetry: () => void }
|
|
51
|
-
| { status: "
|
|
66
|
+
| { status: "pending"; thumbnailUrl: string }
|
|
67
|
+
| { status: "generating"; thumbnailUrl: string; requestId: string }
|
|
52
68
|
| { status: "generateError"; thumbnailUrl: string; onRetry: () => void }
|
|
69
|
+
| { status: "cancelled"; thumbnailUrl: string; onRetry: () => void }
|
|
53
70
|
| {
|
|
54
71
|
status: "success";
|
|
55
72
|
thumbnailUrl: string;
|
|
@@ -58,11 +75,24 @@ export type Slice = { image: File; source: "upload" | "figma" } & (
|
|
|
58
75
|
}
|
|
59
76
|
);
|
|
60
77
|
|
|
78
|
+
function getTitle(slice: Slice) {
|
|
79
|
+
if (slice.status === "success") {
|
|
80
|
+
return slice.model.name;
|
|
81
|
+
}
|
|
82
|
+
if (slice.source === "figma") {
|
|
83
|
+
return slice.image.name.split(".")[0];
|
|
84
|
+
}
|
|
85
|
+
return slice.image.name;
|
|
86
|
+
}
|
|
87
|
+
|
|
61
88
|
function getStartIcon(status: Slice["status"]) {
|
|
62
89
|
switch (status) {
|
|
63
90
|
case "uploadError":
|
|
64
91
|
case "generateError":
|
|
92
|
+
case "cancelled":
|
|
65
93
|
return "close";
|
|
94
|
+
case "pending":
|
|
95
|
+
return "image";
|
|
66
96
|
case "success":
|
|
67
97
|
return "check";
|
|
68
98
|
default:
|
|
@@ -70,16 +100,30 @@ function getStartIcon(status: Slice["status"]) {
|
|
|
70
100
|
}
|
|
71
101
|
}
|
|
72
102
|
|
|
73
|
-
function
|
|
74
|
-
|
|
103
|
+
function formatFileSize(bytes: number): string {
|
|
104
|
+
if (bytes < 1024) {
|
|
105
|
+
return `${bytes} B`;
|
|
106
|
+
}
|
|
107
|
+
if (bytes < 1024 * 1024) {
|
|
108
|
+
return `${(bytes / 1024).toFixed(1)} kB`;
|
|
109
|
+
}
|
|
110
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function getSubtitle(slice: Slice) {
|
|
114
|
+
switch (slice.status) {
|
|
75
115
|
case "uploading":
|
|
76
116
|
return "Uploading...";
|
|
117
|
+
case "pending":
|
|
118
|
+
return formatFileSize(slice.image.size);
|
|
77
119
|
case "uploadError":
|
|
78
120
|
return "Unable to upload image";
|
|
79
121
|
case "generating":
|
|
80
122
|
return "Generating...";
|
|
81
123
|
case "generateError":
|
|
82
124
|
return "Something went wrong";
|
|
125
|
+
case "cancelled":
|
|
126
|
+
return "Cancelled";
|
|
83
127
|
case "success":
|
|
84
128
|
return "Generated";
|
|
85
129
|
}
|
package/src/icons/FigmaIcon.tsx
CHANGED
|
@@ -1,45 +1,44 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentPropsWithoutRef, ElementRef, forwardRef } from "react";
|
|
2
2
|
|
|
3
|
-
export const FigmaIcon
|
|
4
|
-
<svg
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
export const FigmaIcon = forwardRef<
|
|
4
|
+
ElementRef<"svg">,
|
|
5
|
+
ComponentPropsWithoutRef<"svg">
|
|
6
|
+
>((props, ref) => {
|
|
7
|
+
let { width, height } = props;
|
|
8
|
+
if (width === undefined && height === undefined) {
|
|
9
|
+
width = 10;
|
|
10
|
+
height = 16;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<svg
|
|
15
|
+
ref={ref}
|
|
16
|
+
viewBox="0 0 10 16"
|
|
17
|
+
fill="none"
|
|
18
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
19
|
+
height={height}
|
|
20
|
+
width={width}
|
|
21
|
+
>
|
|
13
22
|
<path
|
|
14
|
-
d="
|
|
15
|
-
fill="#
|
|
23
|
+
d="M5 7.83323C5 6.45253 6.11928 5.33325 7.49997 5.33325C8.8807 5.33325 10 6.45255 10 7.83328V8.16656C10 9.54728 8.8807 10.6666 7.49997 10.6666C6.11928 10.6666 5 9.54731 5 8.16661V7.83323Z"
|
|
24
|
+
fill="#1ABCFE"
|
|
16
25
|
/>
|
|
17
26
|
<path
|
|
18
|
-
d="
|
|
19
|
-
fill="#
|
|
27
|
+
d="M0 13.3334C0 11.8607 1.19391 10.6667 2.66667 10.6667H5V13.5001C5 14.8808 3.88071 16.0001 2.5 16.0001C1.11929 16.0001 0 14.8808 0 13.5001L0 13.3334Z"
|
|
28
|
+
fill="#0ACF83"
|
|
20
29
|
/>
|
|
21
30
|
<path
|
|
22
|
-
d="
|
|
23
|
-
fill="#
|
|
31
|
+
d="M5 0V5.33333H7.33333C8.80609 5.33333 10 4.13943 10 2.66667C10 1.19391 8.80609 0 7.33333 0L5 0Z"
|
|
32
|
+
fill="#FF7262"
|
|
24
33
|
/>
|
|
25
34
|
<path
|
|
26
|
-
d="
|
|
27
|
-
fill="#
|
|
35
|
+
d="M0 2.66659C0 4.13934 1.19391 5.33325 2.66667 5.33325L5 5.33325L5 -8.15392e-05L2.66667 -8.15392e-05C1.19391 -8.15392e-05 0 1.19383 0 2.66659Z"
|
|
36
|
+
fill="#F24E1E"
|
|
28
37
|
/>
|
|
29
38
|
<path
|
|
30
|
-
d="
|
|
31
|
-
fill="#
|
|
39
|
+
d="M0 8.00008C0 9.47284 1.19391 10.6667 2.66667 10.6667H5L5 5.33341L2.66667 5.33341C1.19391 5.33341 0 6.52732 0 8.00008Z"
|
|
40
|
+
fill="#A259FF"
|
|
32
41
|
/>
|
|
33
|
-
</
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<rect
|
|
37
|
-
width="10.6688"
|
|
38
|
-
height="16"
|
|
39
|
-
fill="white"
|
|
40
|
-
transform="translate(7 4)"
|
|
41
|
-
/>
|
|
42
|
-
</clipPath>
|
|
43
|
-
</defs>
|
|
44
|
-
</svg>
|
|
45
|
-
);
|
|
42
|
+
</svg>
|
|
43
|
+
);
|
|
44
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { FC, SVGProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const FigmaIconSquare: FC<SVGProps<SVGSVGElement>> = (props) => (
|
|
4
|
+
<svg
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
{...props}
|
|
11
|
+
>
|
|
12
|
+
<g clipPath="url(#clip0_5065_192538)">
|
|
13
|
+
<path
|
|
14
|
+
d="M9.66862 19.9993C11.1406 19.9993 12.3353 18.8047 12.3353 17.3327V14.666H9.66862C8.19662 14.666 7.00195 15.8607 7.00195 17.3327C7.00195 18.8047 8.19662 19.9993 9.66862 19.9993Z"
|
|
15
|
+
fill="#0ACF83"
|
|
16
|
+
/>
|
|
17
|
+
<path
|
|
18
|
+
d="M7.00195 12.0007C7.00195 10.5287 8.19662 9.33398 9.66862 9.33398H12.3353V14.6673H9.66862C8.19662 14.6673 7.00195 13.4727 7.00195 12.0007Z"
|
|
19
|
+
fill="#A259FF"
|
|
20
|
+
/>
|
|
21
|
+
<path
|
|
22
|
+
d="M7.00195 6.66667C7.00195 5.19467 8.19662 4 9.66862 4H12.3353V9.33333H9.66862C8.19662 9.33333 7.00195 8.13867 7.00195 6.66667Z"
|
|
23
|
+
fill="#F24E1E"
|
|
24
|
+
/>
|
|
25
|
+
<path
|
|
26
|
+
d="M12.334 4H15.0007C16.4727 4 17.6673 5.19467 17.6673 6.66667C17.6673 8.13867 16.4727 9.33333 15.0007 9.33333H12.334V4Z"
|
|
27
|
+
fill="#FF7262"
|
|
28
|
+
/>
|
|
29
|
+
<path
|
|
30
|
+
d="M17.6673 12.0007C17.6673 13.4727 16.4727 14.6673 15.0007 14.6673C13.5287 14.6673 12.334 13.4727 12.334 12.0007C12.334 10.5287 13.5287 9.33398 15.0007 9.33398C16.4727 9.33398 17.6673 10.5287 17.6673 12.0007Z"
|
|
31
|
+
fill="#1ABCFE"
|
|
32
|
+
/>
|
|
33
|
+
</g>
|
|
34
|
+
<defs>
|
|
35
|
+
<clipPath id="clip0_5065_192538">
|
|
36
|
+
<rect
|
|
37
|
+
width="10.6688"
|
|
38
|
+
height="16"
|
|
39
|
+
fill="white"
|
|
40
|
+
transform="translate(7 4)"
|
|
41
|
+
/>
|
|
42
|
+
</clipPath>
|
|
43
|
+
</defs>
|
|
44
|
+
</svg>
|
|
45
|
+
);
|
|
@@ -5,7 +5,7 @@ import { useSelector } from "react-redux";
|
|
|
5
5
|
import { Box, Close, Flex, Heading, Text } from "theme-ui";
|
|
6
6
|
|
|
7
7
|
import { Kbd } from "@/components/Kbd";
|
|
8
|
-
import {
|
|
8
|
+
import { FigmaIconSquare } from "@/icons/FigmaIconSquare";
|
|
9
9
|
import { Card, useCardRadius } from "@/legacy/components/Card";
|
|
10
10
|
import SliceMachineModal from "@/legacy/components/SliceMachineModal";
|
|
11
11
|
import { ComponentUI } from "@/legacy/lib/models/common/ComponentUI";
|
|
@@ -52,7 +52,7 @@ const FigmaTip = () => {
|
|
|
52
52
|
minHeight: "40px",
|
|
53
53
|
}}
|
|
54
54
|
>
|
|
55
|
-
<
|
|
55
|
+
<FigmaIconSquare />
|
|
56
56
|
<div>
|
|
57
57
|
Use {keys} to copy any frame as .png, then just paste it here
|
|
58
58
|
</div>
|
|
@@ -427,7 +427,7 @@ const SliceZone: React.FC<SliceZoneProps> = ({
|
|
|
427
427
|
const newCustomType = addSlicesToSliceZone({
|
|
428
428
|
customType,
|
|
429
429
|
tabId,
|
|
430
|
-
slices
|
|
430
|
+
slices,
|
|
431
431
|
});
|
|
432
432
|
setCustomType({
|
|
433
433
|
customType: CustomTypes.fromSM(newCustomType),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
self.__BUILD_MANIFEST=function(s,c,a,e,t,i,b,d,n,u,f,h,k,j,l,p,g,o,r,m,_,y,I){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[s,t,g,o,"static/chunks/pages/index-0d8cb369de720a35.js"],"/_error":["static/chunks/pages/_error-fedd2c6ebd3d27b9.js"],"/changelog":[c,i,"static/chunks/870-a72b74312773efea.js","static/chunks/pages/changelog-8514e0696e90a1b2.js"],"/changes":[c,b,"static/chunks/8eec4907-b712959d9f984b68.js",a,"static/chunks/125-00b909bdbab2ca15.js",e,n,"static/css/d98ebc475f8423a3.css","static/chunks/pages/changes-7f24b37f5bf872ae.js"],"/custom-types":[s,t,g,o,"static/chunks/pages/custom-types-5acd56959b60346f.js"],"/custom-types/[customTypeId]":[c,u,f,h,k,s,a,i,d,j,r,e,t,l,p,m,_,"static/chunks/pages/custom-types/[customTypeId]-1b47424a37b49dff.js"],"/labs":["static/chunks/pages/labs-56fd818a63553497.js"],"/page-types/[pageTypeId]":[c,u,f,h,k,s,a,i,d,j,r,e,t,l,p,m,_,"static/chunks/pages/page-types/[pageTypeId]-385f933c203e8b16.js"],"/slices":[c,b,y,s,a,d,I,e,p,n,"static/css/efa5152b7c0f35c0.css","static/chunks/pages/slices-bedcb854fbdca8cd.js"],"/slices/[lib]/[sliceName]/[variation]":[c,b,u,f,h,k,y,s,a,i,d,j,I,"static/chunks/484-3e011e79c41f0342.js",e,l,n,"static/css/e8e03c0d4003d1eb.css","static/chunks/pages/slices/[lib]/[sliceName]/[variation]-08cdeefc96106c0c.js"],"/slices/[lib]/[sliceName]/[variation]/simulator":[b,"static/chunks/72585f70-28b4d7d5384b3703.js","static/chunks/429-aab52070cad2884b.js","static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-faeb6d2f77d97096.js"],sortedPages:["/","/_app","/_error","/changelog","/changes","/custom-types","/custom-types/[customTypeId]","/labs","/page-types/[pageTypeId]","/slices","/slices/[lib]/[sliceName]/[variation]","/slices/[lib]/[sliceName]/[variation]/simulator"]}}("static/chunks/397-e6c340070a3bcb41.js","static/chunks/59b4e022-ef680789f7cc9b11.js","static/chunks/66-d9d3bcb5d041cb6d.js","static/chunks/34-28725deef8b874b1.js","static/chunks/647-aa094286bc248d52.js","static/chunks/183-4ea255b867ff171b.js","static/chunks/c8eae200-966ce352f7b5d2b9.js","static/chunks/344-b64f09e670634ed1.js","static/chunks/658-8231c0b729e0124a.js","static/chunks/f36c6662-1f3a854183168b10.js","static/chunks/4c744e84-480e426e4b1cfef3.js","static/chunks/065a3ddb-9a38ca0d60f0bf2f.js","static/chunks/1cc2734a-09fb3b997ad1eb70.js","static/chunks/256-07f768a2b19b0a0e.js","static/chunks/630-2bf927bca082a191.js","static/chunks/907-bf4215e6fc238ea0.js","static/chunks/248-84a5987f0499b074.js","static/css/4e475d945cf8a890.css","static/chunks/422-c9192a1dbdd2ae0e.js","static/chunks/489-ce3053e1d81ade83.js","static/css/56f2a6684a524374.css","static/chunks/52d4c156-89c6ec6efca0a0bb.js","static/chunks/444-d39213143f782fec.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[34],{62434:function(e,t,n){"use strict";n.d(t,{Zb:function(){return c},T$:function(){return m},eW:function(){return _},ZB:function(){return u},Lm:function(){return C}});var o=n(52322),r=n(50002),i=n(11699),a=n(6277),l=n(2784),d=n(67968),s=n.n(d);let c=e=>{let{checked:t=!1,size:n="medium",variant:i="solid",interactive:d,disabled:c,onClick:u,href:m,component:_="a",replace:C,...h}=e,x={...h,className:(0,a.W)(s().root,s()["size-".concat(n)],s()[i],{[s().interactive]:e.interactive}),"data-state":!0===t?"checked":void 0,"data-disabled":!0===e.disabled?"":void 0};return!0===e.interactive&&void 0===e.href?(0,o.jsx)("div",{...x,onClick:t=>{if(!0===e.disabled||void 0===e.onClick)return;let n=t.target;(0,r.JY)(n)===t.currentTarget&&e.onClick(t)},tabIndex:!0===e.disabled?void 0:0}):!0===e.interactive?(0,l.createElement)(_,{...x,href:e.href,onClick:e=>{let t=e.target;(0,r.JY)(t)!==e.currentTarget&&e.preventDefault()},..."a"===_?{}:{replace:e.replace}}):(0,o.jsx)("div",{...x})},u=e=>{let{className:t,component:n="img",overlay:r,...i}=e;return(0,o.jsxs)("div",{className:s().media,children:[(0,l.createElement)(n,{...i,className:(0,a.W)(s()["mediaComponent-".concat(n)],t)}),r?(0,o.jsx)("div",{className:s().mediaOverlay,children:r}):void 0]})},m=e=>(0,o.jsx)("div",{...e,className:s().actions}),_=e=>{let{action:t,loading:n=!1,startIcon:r,subtitle:a,title:l,error:d=!1,...c}=e,u=d?"tomato11":"grey11";return(0,o.jsxs)("div",{...c,className:s().footer,children:[(r||n)&&(0,o.jsxs)("div",{className:s().startIconBox,children:[n&&(0,o.jsx)(i.bg,{color:"grey11"}),!n&&r&&(0,o.jsx)(i.aX,{name:r,size:"small",color:u})]}),(0,o.jsxs)("div",{className:s().footerTexts,children:[(0,o.jsx)(i.bL,{component:"span",noWrap:!0,variant:"bold",children:l}),(0,o.jsx)(i.bL,{color:u,component:"span",noWrap:!0,variant:"small",children:a})]}),t]})},C=e=>{let{children:t,...n}=e;return(0,o.jsx)("div",{...n,className:s().status,children:(0,o.jsx)(i.bL,{align:"center",color:"inherit",component:"span",noWrap:!0,variant:"smallBold",children:t})})}},99195:function(e,t,n){"use strict";n.d(t,{O:function(){return l}});var o=n(52322),r=n(11699),i=n(56448),a=n(93671);let l=e=>{let{badgeColor:t,badgeTitle:n,tooltipContent:l}=function(e){let t=d[e.modelType];switch(e.modelStatus){case i.GJ.New:return{badgeColor:"green",badgeTitle:"New",tooltipContent:"This ".concat(t," exists only locally. Upon sync, it will be pushed to your remote repository.")};case i.GJ.Modified:return{badgeColor:"amber",badgeTitle:"Modified",tooltipContent:"This ".concat(t," has been modified locally. Upon sync, changes will be pushed to your remote repository.")};case i.GJ.Synced:return{badgeColor:"purple",badgeTitle:"Synced",tooltipContent:"This ".concat(t," is in sync with the remote repository.")};case i.GJ.Deleted:return{badgeColor:"tomato",badgeTitle:"Deleted",tooltipContent:"This ".concat(t," has been deleted locally.")};case i.GJ.Unknown:if(!e.isOnline)return{badgeColor:"grey",badgeTitle:"Unknown",tooltipContent:"Data from the remote repository could not be fetched (no internet connection)."};if(e.authStatus===a.t.UNAUTHENTICATED)return{badgeColor:"grey",badgeTitle:"Unknown",tooltipContent:"Data from the remote repository could not be fetched (not connected to Prismic)."};default:return{badgeColor:"grey",badgeTitle:"Unknown",tooltipContent:"Data from the remote repository could not be fetched (unknown error)."}}}(e);return(0,o.jsx)(r.c3,{content:l,side:"bottom",children:(0,o.jsx)(r.m,{color:t,title:n})})},d={CustomType:"type",Slice:"slice"}},51507:function(e,t,n){"use strict";n.d(t,{b:function(){return h}});var o=n(52322),r=n(11699),i=n(39097),a=n.n(i),l=n(62434),d=n(63908),s=n(99195),c=n(27763);let u=e=>(0,o.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,o.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 5.5C4 4.67157 4.67157 4 5.5 4H18.5C19.3284 4 20 4.67157 20 5.5V12.4413C20 12.4512 19.9997 12.461 19.9991 12.4707C20.0072 12.6083 19.9586 12.7485 19.8536 12.8536C19.6583 13.0488 19.3417 13.0488 19.1464 12.8536L16.3536 10.0607C16.1583 9.8654 15.8417 9.8654 15.6464 10.0607L11.8536 13.8536C11.6583 14.0488 11.3417 14.0488 11.1464 13.8536L9.35355 12.0607C9.15829 11.8654 8.84171 11.8654 8.64645 12.0607L5 15.7071V18.5C5 18.7761 5.22386 19 5.5 19H12.5C12.7761 19 13 19.2239 13 19.5C13 19.7761 12.7761 20 12.5 20H5.5C4.67157 20 4 19.3284 4 18.5V15.5003V15.4997V5.5ZM11.5 12.7929L14.9393 9.35355C15.5251 8.76777 16.4749 8.76777 17.0607 9.35355L19 11.2929V5.5C19 5.22386 18.7761 5 18.5 5H5.5C5.22386 5 5 5.22386 5 5.5V14.2929L7.93934 11.3536C8.52513 10.7678 9.47487 10.7678 10.0607 11.3536L11.5 12.7929ZM16.5 13C16.7761 13 17 13.2239 17 13.5V16H19.5C19.7761 16 20 16.2239 20 16.5C20 16.7761 19.7761 17 19.5 17H17V19.5C17 19.7761 16.7761 20 16.5 20C16.2239 20 16 19.7761 16 19.5V17H13.5C13.2239 17 13 16.7761 13 16.5C13 16.2239 13.2239 16 13.5 16H16V13.5C16 13.2239 16.2239 13 16.5 13Z",fill:"currentColor"})}),m=e=>({hash:e.hash}),_=e=>e?Object.entries(e).reduce((e,t)=>{let[n,o]=t;return o.hash?{...e,[n]:{...o,...m(o)}}:e},{}):{},C={build:e=>({...e,screenshots:_(e.screenshots)}),variation(e,t){if(e.model.variations.length)return t?e.model.variations.find(e=>e.id===t):e.model.variations[0]}},h=e=>{let t;let{action:n,isDeleted:i=!1,onUpdateScreenshot:m,selected:_=!1,slice:h,variant:p,variationId:b}=e,f=C.variation(h,b);if(!f)return null;let g=(0,d.d7)(h,f),j=!i&&!!m,y="outlined"===p,k=void 0!==b;return t="selection"===e.mode?{disabled:i,interactive:!0,onClick:()=>{e.onSelectedChange(!_)}}:i?{interactive:!1}:{component:a(),href:c.Y.getBuilderPagePathname({libraryName:h.href,sliceName:h.model.name,variationId:f.id}),interactive:!0,replace:e.replace},(0,o.jsxs)(l.Zb,{"aria-label":"".concat(h.model.name," ").concat(f.name," slice card"),checked:_,"data-testid":"shared-slice-card",...t,..."outlined"===p?{size:"small",variant:"outlined"}:{},children:[void 0!==g?(0,o.jsx)(l.ZB,{alt:"Preview image",overlay:j&&!y?(0,o.jsx)(r.D,{alignItems:"center",justifyContent:"center",children:(0,o.jsx)(x,{onClick:m})}):void 0,src:g}):(0,o.jsx)(l.ZB,{component:"div",children:(0,o.jsxs)(r.D,{alignItems:"center",flexDirection:"column",gap:8,justifyContent:"center",children:[(0,o.jsx)(r.bL,{color:"grey11",component:"span",children:"No screenshot available"}),j&&!y?(0,o.jsx)(x,{onClick:m}):void 0]})}),(0,o.jsx)(l.eW,{action:"checkbox"===n.type&&"selection"===e.mode?(0,o.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,o.jsx)(r.U,{checked:_,disabled:i,onCheckedChange:e.onSelectedChange})}):"menu"===n.type?(0,o.jsxs)(r.ar,{modal:!0,children:[(0,o.jsx)(r.av,{disabled:i,children:(0,o.jsx)(r.aZ,{hiddenLabel:"Slice actions",icon:"moreVert"})}),(0,o.jsxs)(r.as,{align:"end","data-testid":"slice-action-icon-dropdown",children:[j&&y?(0,o.jsx)(r.at,{onSelect:m,startIcon:(0,o.jsx)(u,{}),children:"Update screenshot"}):void 0,(0,o.jsx)(r.at,{onSelect:n.onRename,startIcon:(0,o.jsx)(r.aX,{name:"edit"}),children:"Rename"}),!0===n.removeDisabled&&k?(0,o.jsx)(r.c3,{content:"The slice needs to have at least one variation.",side:"bottom",stableMount:!0,children:(0,o.jsx)(v,{disabled:!0,onSelect:n.onRemove})}):(0,o.jsx)(v,{disabled:!0===n.removeDisabled,onSelect:n.onRemove})]})]}):"remove"===n.type?(0,o.jsx)(r.aZ,{icon:"close",onClick:()=>!i&&n.onRemove(),hiddenLabel:"Remove slice"}):"status"===n.type?(0,o.jsx)(s.O,{authStatus:n.authStatus,isOnline:n.isOnline,modelStatus:n.modelStatus,modelType:"Slice"}):void 0,subtitle:(0,o.jsx)(o.Fragment,{children:k?f.id:"".concat(h.model.variations.length," variation").concat(h.model.variations.length>1?"s":"")}),title:k?f.name:h.model.name}),j&&!k&&(0,d.cx)(h)>0?(0,o.jsx)(l.Lm,{children:"Missing screenshot"}):void 0]})},x=e=>(0,o.jsx)(r.E,{onClick:e.onClick,renderStartIcon:()=>(0,o.jsx)(u,{color:r.t.color.grey11}),color:"grey",children:"Update screenshot"}),v=e=>(0,o.jsx)(r.at,{...e,color:"tomato",startIcon:(0,o.jsx)(r.aX,{name:"delete"}),children:"Delete"})},27763:function(e,t,n){"use strict";n.d(t,{Y:function(){return o}});let o={getBuilderPagePathname:e=>"/slices/".concat(e.libraryName.replaceAll("/","--"),"/").concat(e.sliceName,"/").concat(e.variationId)}},30527:function(e,t,n){"use strict";n.d(t,{Z:function(){return s},W:function(){return d}});var o=n(52322),r=n(2784),i=n(75289);let a=e=>{let{bg:t,background:n,sx:r,withRadius:a,radius:l,children:d}=e;return(0,o.jsx)(i.xu,{sx:{p:4,bg:t||n,...a?{borderBottomLeftRadius:l,borderBottomRightRadius:l}:null,...r},children:d})},l=(0,r.createContext)("6px"),d=()=>(0,r.useContext)(l),s=e=>{let{Header:t=null,SubHeader:n=null,Body:r=null,Footer:d=null,borderFooter:s=!1,radius:c="6px",bodySx:u={},footerSx:m={},sx:_=null,bg:C,background:h,children:x,...v}=e;return(0,o.jsx)(l.Provider,{value:c,children:(0,o.jsxs)(i.Zb,{sx:{border:e=>{var t;return"1px solid ".concat(String(null===(t=e.colors)||void 0===t?void 0:t.borders))},borderRadius:c,..._},...v,children:[t||null,n||null,(0,o.jsxs)(a,{bg:C,background:h,sx:u,withRadius:!d,children:[r?(0,o.jsx)(r,{}):null,x||null]}),d?(0,o.jsx)(a,{bg:C,background:h,sx:{...s?{borderTop:e=>{let{colors:t}=e;return"1px solid ".concat(String(null==t?void 0:t.borders))}}:null,...m},radius:c,withRadius:!0,children:"object"==typeof d?d:(0,o.jsx)(d,{})}):null]})})}},7974:function(e,t,n){"use strict";n.d(t,{Sn:function(){return l},lS:function(){return o},nG:function(){return r},pq:function(){return d},rd:function(){return a},xo:function(){return i}});let o=["components","update","insert"],r=["png","jpg","jpeg"],i=/^[A-Za-z0-9]+(?:_[A-Za-z0-9]+)*$/,a="placeholders/What_are_Slices_mrvome",l="SM_HELP_VIDEOS/mock_data",d="slice-machine-simulator"},67968:function(e){e.exports={flex:"Card_flex__opby1",grid:"Card_grid__VAvIS",column:"Card_column__W4ACG Card_flex__opby1",root:"Card_root__YVuvU Card_column__W4ACG Card_flex__opby1","size-small":"Card_size-small__aIlxd","size-medium":"Card_size-medium__xegz0",solid:"Card_solid__GNGar",outlined:"Card_outlined__W_dxI",interactive:"Card_interactive__rXw5L",media:"Card_media__l0kHL Card_column__W4ACG Card_flex__opby1","mediaComponent-div":"Card_mediaComponent-div__Y2_PZ Card_grid__VAvIS","mediaComponent-img":"Card_mediaComponent-img__ezOTu",mediaOverlay:"Card_mediaOverlay__Aa__Q Card_grid__VAvIS",nonMedia:"Card_nonMedia__Fv3Mz Card_flex__opby1",actions:"Card_actions__XdhOt Card_nonMedia__Fv3Mz Card_flex__opby1",footer:"Card_footer__U0HS1 Card_nonMedia__Fv3Mz Card_flex__opby1",footerTexts:"Card_footerTexts__rTXup Card_column__W4ACG Card_flex__opby1",status:"Card_status__PNN2a Card_column__W4ACG Card_flex__opby1",startIconBox:"Card_startIconBox__1_L4u"}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[658],{21442:function(e,i,t){"use strict";t.d(i,{H:function(){return s}});var r=t(2784),n=t(54597);let s=()=>{let{openScreenshotsModal:e}=(0,n.Z)(),[i,t]=(0,r.useState)({sliceFilterFn:e=>e});return{modalPayload:i,onOpenModal:i=>{t(i),e()}}}},68105:function(e,i,t){"use strict";t.d(i,{Z:function(){return O}});var r,n,s=t(52322),l=t(2784),o=t(951),a=t(75100),d=t(56580),c=t(75289),x=t(68238),u=t.n(x);let p=e=>{let{children:i}=e;return(0,s.jsx)("kbd",{className:u().root,children:i})},h=e=>(0,s.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,s.jsxs)("g",{clipPath:"url(#clip0_5065_192538)",children:[(0,s.jsx)("path",{d:"M9.66862 19.9993C11.1406 19.9993 12.3353 18.8047 12.3353 17.3327V14.666H9.66862C8.19662 14.666 7.00195 15.8607 7.00195 17.3327C7.00195 18.8047 8.19662 19.9993 9.66862 19.9993Z",fill:"#0ACF83"}),(0,s.jsx)("path",{d:"M7.00195 12.0007C7.00195 10.5287 8.19662 9.33398 9.66862 9.33398H12.3353V14.6673H9.66862C8.19662 14.6673 7.00195 13.4727 7.00195 12.0007Z",fill:"#A259FF"}),(0,s.jsx)("path",{d:"M7.00195 6.66667C7.00195 5.19467 8.19662 4 9.66862 4H12.3353V9.33333H9.66862C8.19662 9.33333 7.00195 8.13867 7.00195 6.66667Z",fill:"#F24E1E"}),(0,s.jsx)("path",{d:"M12.334 4H15.0007C16.4727 4 17.6673 5.19467 17.6673 6.66667C17.6673 8.13867 16.4727 9.33333 15.0007 9.33333H12.334V4Z",fill:"#FF7262"}),(0,s.jsx)("path",{d:"M17.6673 12.0007C17.6673 13.4727 16.4727 14.6673 15.0007 14.6673C13.5287 14.6673 12.334 13.4727 12.334 12.0007C12.334 10.5287 13.5287 9.33398 15.0007 9.33398C16.4727 9.33398 17.6673 10.5287 17.6673 12.0007Z",fill:"#1ABCFE"})]}),(0,s.jsx)("defs",{children:(0,s.jsx)("clipPath",{id:"clip0_5065_192538",children:(0,s.jsx)("rect",{width:"10.6688",height:"16",fill:"white",transform:"translate(7 4)"})})})]});var f=t(30527),v=t(55862),j=t(75966),m=t(34830),g=t(54597);(r=n||(n={})).Mac="Mac",r.Linux="Linux",r.Windows="Windows";let b=()=>{let{userAgent:e}=navigator,i="Linux";return Object.values(n).forEach(t=>{e.includes(t)&&(i=t)}),i};var C=t(76473),y=t(88932),w=t(94160);async function F(e){let{variationId:i,slice:t,file:r,method:n}=e;try{let e=new FormData;e.append("file",r),e.append("libraryName",t.from),e.append("sliceName",t.model.name),e.append("variationId",i);let{errors:s,url:l}=await (0,w.XQ)({libraryName:t.from,sliceId:t.model.id,variationId:i,file:r});if(s.length>0)throw s;return w.Xe.track({event:"screenshot-taken",type:"custom",method:n}),{...t,screenshots:{...t.screenshots,[i]:{url:l}}}}catch(i){let e="Screenshot not saved";console.error(e,i),y.Am.error(e)}}var E=t(77823),k=t(7974);let D=e=>{let{inputFile:i,handleFile:t,children:r,isDragActive:n}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c.__,{htmlFor:"input-file",variant:"buttons.white",sx:{p:2,px:0,display:"flex",justifyContent:"center",width:200,alignItems:"center",flex:1},children:r||"Select file"}),(0,s.jsx)("input",{id:"input-file",type:"file",ref:i,style:{display:"none"},accept:k.nG.map(e=>"image/".concat(e)).join(","),onChange:e=>{var i;t(null===(i=e.target.files)||void 0===i?void 0:i[0],n)}})]})},I=()=>(0,s.jsx)(c.kC,{variant:"boxes.centered",sx:{p:2,position:"absolute",height:"100%",width:"100%",background:"rgba(249, 248, 249, 0.7)",backdropFilter:"blur(5px)",zIndex:"1",pointerEvents:"none"},children:(0,s.jsxs)(c.kC,{variant:"boxes.centered",sx:{border:"1px dashed #6E56CF",height:"100%",width:"100%",borderRadius:"4px"},children:[(0,s.jsx)(S,{isActive:!0}),(0,s.jsx)(c.xv,{sx:{my:2},children:"Drop file here"}),(0,s.jsx)(c.xv,{variant:"secondary",children:"Maximum upload size file: 128Mb"})]})}),S=e=>{let{isActive:i}=e;return(0,s.jsx)(c.kC,{sx:{p:1,borderRadius:"50%",bg:i?"#F1EEFE":"#EDECEE",alignItems:"center",justifyContent:"center",width:"48px",height:"48px"},children:(0,s.jsx)(o.IEK,{style:{color:i?"#6E56CF":"#6F6E77",fontSize:"34px"}})})};var R=e=>{let{variationID:i,slice:t,imageTypes:r=k.nG,onUploadSuccess:n}=e,o=t.screenshots[i],{saveSliceCustomScreenshotSuccess:a}=(0,g.Z)(),[d,x]=(0,l.useState)(!1),[u,p]=(0,l.useState)(!1),[h,f]=(0,l.useState)(!1);(0,C.y1)(["meta+v","ctrl+v"],()=>void w(),[i,t]);let{FileInputRenderer:v,fileInputProps:j}=function(e){let{onHandleFile:i}=e,t=(0,l.useRef)(null),r=async(e,r)=>{e&&(await i(e,r),(null==t?void 0:t.current)&&(t.current.value=""))};return{handleFile:r,inputFile:t,FileInputRenderer:D,fileInputProps:{inputFile:t,handleFile:r}}}({onHandleFile:async(e,r)=>{f(!0);let s=await F({slice:t,file:e,method:r?"dragAndDrop":"upload",variationId:i});p(!1);let l=null==s?void 0:s.screenshots[i];l&&(a(i,l,s),n&&n(s)),f(!1)}}),m=async e=>{if(e.size>128e6)return y.Am.error("File is too big. Max file size: 128Mb.");f(!0);let r=await F({slice:t,file:e,method:"dragAndDrop",variationId:i}),s=null==r?void 0:r.screenshots[i];s&&(a(i,s,r),n&&n(r)),f(!1)},b="function"==typeof navigator.clipboard.read,w=async()=>{if(b)try{let e=await navigator.clipboard.read();if(void 0!==e[0]){let i=e[0].types.find(e=>r.map(e=>"image/".concat(e)).includes(e));if(void 0!==i){let t=await e[0].getType(i),r=new File([t],"file");return m(r)}}}catch(e){console.error("Could not paste file",e)}},R=e=>i=>{i.preventDefault(),x(e)},H=e=>i=>{i.preventDefault(),p(e)};return(0,s.jsxs)(c.kC,{as:"form",variant:"boxes.centered",sx:{bg:"#F9F8F9",position:"relative",borderRadius:"6px",height:"320px"},onDragEnter:R(!0),onDragLeave:R(!1),onDragOver:R(!0),onMouseEnter:H(!0),onMouseLeave:H(!1),onSubmit:e=>e.preventDefault(),onDrop:e=>{var i;e.preventDefault(),x(!1);let t=null===(i=e.dataTransfer.files)||void 0===i?void 0:i[0];if(void 0!==t)return r.some(e=>"image/".concat(e)===t.type)?void m(t):y.Am.error("Only files of type ".concat(r.join(", ")," are accepted."))},children:[h?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c.$j,{}),(0,s.jsx)(c.xv,{sx:{my:2},children:"Uploading file ..."})]}):null,h||void 0===o?null:(0,s.jsx)(E.q,{src:o.url,sx:{width:"100%",height:"100%",maxHeight:"100%",backdropFilter:"blur(5px)"}}),h?null:(0,s.jsx)(c.kC,{sx:{p:2,position:"absolute",width:"100%",height:"100%",borderRadius:"6px",background:"#F9F8F9B2",justifyContent:"center",alignItems:"center",visibility:u||void 0===o?"visible":"hidden"},children:(0,s.jsx)(c.kC,{variant:"boxes.centered",sx:{border:"1px dashed #6E56CF",height:"100%",width:"100%",borderRadius:"4px"},children:(0,s.jsxs)(c.kC,{sx:{width:"100%",justifyContent:"center",alignItems:"center",flexDirection:"column"},children:[(0,s.jsx)(S,{isActive:d}),(0,s.jsx)(c.xv,{sx:{my:2},children:b?"Paste, drop or ...":"Drop or ..."}),(0,s.jsx)(v,{...j,isDragActive:d}),(0,s.jsx)(c.xv,{sx:{color:"greyIcon",mt:1},children:"Maximum file size: 128Mb"})]})})}),d?(0,s.jsx)(I,{}):null]})};let H=()=>{let e=b(),i=[n.Windows,n.Linux].includes(e)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(p,{children:"ctrl"})," + ",(0,s.jsx)(p,{children:"shift"})," + ",(0,s.jsx)(p,{children:"c"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(p,{children:"cmd"})," + ",(0,s.jsx)(p,{children:"shift"})," + ",(0,s.jsx)(p,{children:"c"})]});return(0,s.jsxs)(c.kC,{sx:{pl:"4px",alignItems:"center",color:"#000",borderRadius:"6px",fontSize:"12px",lineHeight:"24px",border:"1px solid #E4E2E4",boxShadow:"0px 1px 0px 0px rgba(0, 0, 0, 0.04)",width:"100%",minHeight:"40px"},children:[(0,s.jsx)(h,{}),(0,s.jsxs)("div",{children:["Use\xa0",i," to copy any frame as .png, then just paste it here"]})]})},M=e=>{let{isValid:i}=e;return(0,s.jsx)(c.kC,{sx:{p:2,border:"1px solid #E4E2E4",borderRadius:"6px",bg:"#FFF"},children:i?(0,s.jsx)(o.Ypm,{style:{fontSize:"16px"}}):(0,s.jsx)(a.j6O,{style:{fontSize:"16px",color:"#ED811C"}})})},_=e=>{let{slice:i,onSelectVariation:t,variationSelector:r}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c.X6,{as:"h4",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.model.name}),(0,s.jsx)(c.xu,{children:(0,s.jsx)(c.xu,{as:"ul",sx:{pl:0,my:3},children:i.model.variations.map(e=>{let{sliceID:n,variationID:l}=r,o=n===i.model.id&&l===e.id;return(0,s.jsx)(c.xu,{as:"li",sx:{listStyle:"none",my:2,p:2,cursor:"pointer",borderRadius:"4px",...o&&{bg:"#EDECEE",fontWeight:"500"},":hover":{bg:"#EDECEE"}},onClick:()=>t({sliceID:i.model.id,variationID:e.id}),children:(0,s.jsxs)(c.kC,{sx:{alignItems:"center"},children:[(0,s.jsx)(M,{isValid:!!i.screenshots[e.id]}),(0,s.jsx)(c.xv,{sx:{ml:2},children:e.name})]})},"".concat(i.model.id,"-").concat(e.id))})})})]})},z=(e,i)=>e||(i.length?{sliceID:i[0].model.id,variationID:i[0].model.variations[0].id}:void 0);function A(e){let{children:i}=e,t=(0,f.W)();return(0,s.jsx)(c.kC,{sx:{position:"sticky",top:0,zIndex:1,background:"gray",p:"16px",alignItems:"center",justifyContent:"space-between",borderTopLeftRadius:t,borderTopRightRadius:t,borderBottom:e=>{var i;return"1px solid ".concat(String(null===(i=e.colors)||void 0===i?void 0:i.borders))}},children:i})}var O=e=>{let{slices:i,defaultVariationSelector:t,onUploadSuccess:r}=e,{closeModals:n}=(0,g.Z)(),{isOpen:o}=(0,d.v9)(e=>({isOpen:(0,j.gP)(e,m.q.SCREENSHOTS)})),[a,x]=(0,l.useState)(z(t,i));if((0,l.useEffect)(()=>{x(z(t,i))},[null==t?void 0:t.sliceID,null==t?void 0:t.variationID,o]),0===i.length||!a)return null;let u="function"==typeof navigator.clipboard.read;return(0,s.jsx)(v.Z,{isOpen:o,shouldCloseOnOverlayClick:!0,onRequestClose:()=>n(),children:(0,s.jsx)(f.Z,{radius:"0px",bodySx:{p:0,bg:"#FFF",position:"relative"},sx:{border:"none"},Header:(0,s.jsxs)(A,{children:[(0,s.jsx)(c.X6,{sx:{fontSize:"20px"},children:"Slice screenshots"}),(0,s.jsx)(c.x8,{type:"button",onClick:()=>n()})]}),Footer:null,children:(0,s.jsxs)(c.xu,{sx:{display:"flex",flexWrap:"wrap",height:"100%"},children:[(0,s.jsx)(c.xu,{sx:{p:3,bg:"grey07",flexGrow:1,overflow:"auto",maxHeight:"100%",flexBasis:"sidebar"},children:i.map((e,i)=>(0,s.jsx)(_,{slice:e,variationSelector:a,onSelectVariation:x},"".concat(e.model.id,"-").concat(i)))}),(0,s.jsxs)(c.kC,{as:"main",sx:{p:3,flexGrow:99999,flexBasis:0,flexDirection:"column",minWidth:320,gap:"8px"},children:[u?(0,s.jsx)(H,{}):void 0,(()=>{let e=i.find(e=>e.model.id===a.sliceID);return e?(0,s.jsx)(R,{variationID:a.variationID,slice:e,onUploadSuccess:r}):null})()]})]})})})}},77823:function(e,i,t){"use strict";t.d(i,{q:function(){return a}});var r=t(52322),n=t(2784),s=t(65186),l=t(75289);let o=(0,n.memo)(e=>{let{src:i}=e;return(0,r.jsx)(l.Ee,{src:i,alt:"Preview image",sx:{maxHeight:"100%"}})}),a=e=>{let{src:i,sx:t}=e;return(0,r.jsx)(l.kC,{sx:{position:"relative",alignItems:"center",justifyContent:"center",overflow:"hidden",backgroundImage:"url(/pattern.png)",backgroundColor:"headSection",backgroundRepeat:"repeat",backgroundSize:"20px",borderRadius:"4px",...t},children:void 0!==i?(0,r.jsx)(o,{src:i}):(0,r.jsxs)(l.xv,{sx:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,r.jsx)(s.eJU,{}),"You have no screenshot yet."]})})}},68238:function(e){e.exports={root:"Kbd_root__LRA1F"}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[907],{91589:function(e,t,a){a.d(t,{S:function(){return b}});var r=a(52322),i=a(11699),n=a(2784),l=a(76473),s=a(88932),o=a(30195),c=a(94160),d=a(34166),u=a(98250),m=a(68968),p=a(96317),g=a(80148),f=a(54597),h=a(62434);function y(e){let{slice:t}=e,a="uploading"===t.status||"generating"===t.status,n="uploadError"===t.status||"generateError"===t.status,l="generateError"===t.status||"generating"===t.status||"success"===t.status;return(0,r.jsxs)(h.Zb,{disabled:a,children:[l?(0,r.jsx)(h.ZB,{src:t.thumbnailUrl}):(0,r.jsx)(h.ZB,{component:"div"}),(0,r.jsx)(h.eW,{loading:a,startIcon:function(e){switch(e){case"uploadError":case"generateError":return"close";case"success":return"check";default:return}}(t.status),title:"success"===t.status?t.model.name:t.image.name,subtitle:function(e){switch(e){case"uploading":return"Uploading...";case"uploadError":return"Unable to upload image";case"generating":return"Generating...";case"generateError":return"Something went wrong";case"success":return"Generated"}}(t.status),error:n,action:n?(0,r.jsx)(i.E,{startIcon:"refresh",color:"grey",onClick:t.onRetry,children:"Retry"}):void 0})]})}let x=o.z.object({__type:o.z.literal("figma-to-prismic/clipboard-data"),name:o.z.string(),image:o.z.string().startsWith("data:image/")});function b(e){let{open:t,location:a,onSuccess:o,onClose:h}=e,[b,C]=(0,n.useState)([]),[A,I]=(0,n.useState)(!1),{syncChanges:k}=(0,m.g)(),{createSliceSuccess:N}=(0,f.Z)(),{completeStep:E}=(0,u.k)(),F=function(){let e=(0,p.L)("llm-proxy-access");return(null==e?void 0:e.value)==="on"}(),U=(0,n.useRef)(crypto.randomUUID());(0,l.y1)(["meta+v","ctrl+v"],e=>{e.preventDefault(),_()},{enabled:t&&F});let L=e=>{let{index:t,slice:a}=e;C(e=>e.map((e,r)=>r===t?a(e):e))},D=e=>{if(e.length>10){s.Am.error("You can only upload ".concat(10," images at a time."));return}C(e.map(e=>({source:"upload",status:"uploading",image:e}))),e.forEach((e,t)=>z({index:t,image:e,source:"upload"}))},z=e=>{let{index:t,image:a,source:r}=e,i=U.current;L({index:t,slice:e=>({...e,status:"uploading",source:r})}),v({image:a}).then(e=>{i===U.current&&B({index:t,imageUrl:e,source:r})},()=>{i===U.current&&L({index:t,slice:e=>({...e,status:"uploadError",onRetry:()=>z({index:t,image:a,source:r})})})})},P=function(e){let{open:t}=e,a=(0,n.useRef)([]);return(0,n.useEffect)(()=>{t&&(a.current=[],g.managerClient.slices.readAllSlices().then(e=>{a.current=e.models.map(e=>{let{model:t}=e;return t})}).catch(()=>null))},[t]),a}({open:t}),B=async e=>{let{index:t,imageUrl:a,source:r}=e,i=U.current,n=await g.managerClient.project.getSliceMachineConfig().then(e=>{var t;let a=null==e?void 0:null===(t=e.libraries)||void 0===t?void 0:t[0];if(void 0===a)throw Error("No library found in the config.");return a});L({index:t,slice:e=>({...e,status:"generating",thumbnailUrl:a})});try{let e=await g.managerClient.customTypes.inferSlice({imageUrl:a,source:r,libraryID:n});if(i!==U.current)return;let l=function(e){let{existingSlices:t,newSlices:a,slice:r}=e,i=new Set,n=new Set;for(let{id:e,name:a}of t)i.add(e),n.add(a.toLowerCase());for(let e of a)"success"===e.status&&(i.add(e.model.id),n.add(e.model.name.toLowerCase()));let l=r.id,s=2;for(;i.has(l);)l="".concat(r.id,"_").concat(s),s++;let o=r.name;for(s=2;n.has(o.toLowerCase());)o="".concat(r.name).concat(s),s++;return{...r,id:l,name:o}}({existingSlices:P.current,newSlices:b,slice:e.slice});C(r=>r.map((r,i)=>i===t?{...r,status:"success",thumbnailUrl:a,langSmithUrl:e.langSmithUrl,model:l}:r))}catch(e){if(i!==U.current)return;L({index:t,slice:e=>({...e,status:"generateError",thumbnailUrl:a,onRetry:()=>void B({index:t,imageUrl:a,source:r})})})}},_=async()=>{var e;if(!(!t||!F||b.some(e=>"figma"===e.source)||b.some(e=>"uploading"===e.status||"generating"===e.status))){if("function"!=typeof(null===(e=navigator.clipboard)||void 0===e?void 0:e.read)){s.Am.error("Clipboard paste is not supported in this browser.");return}try{let e=await navigator.clipboard.read();if(0===e.length){s.Am.error("No data found in clipboard.");return}let t="pasted-image.png",a=null,r=!1;for(let t of e){let e=t.types.find(e=>e.startsWith("image/"));if(void 0!==e){a=await t.getType(e);break}}for(let i of e)if(i.types.includes("text/plain"))try{let e=await i.getType("text/plain"),n=await e.text(),l=x.safeParse(JSON.parse(n));if(l.success){r=!0;let e=l.data;if(t="".concat(e.name,".png"),!a){let t=await fetch(e.image);a=await t.blob()}}else console.warn("Clipboard data validation failed:",l.error)}catch(e){console.warn("Failed to parse JSON from clipboard:",e)}if(!a){r?s.Am.error("Could not extract Figma data from clipboard. Please try copying again using the Prismic Figma plugin."):s.Am.error("No Figma data found in clipboard. Make sure you've copied a design using the Prismic Figma plugin.");return}let i=b.length;if(i>=10){s.Am.error("You can only upload ".concat(10," images at a time."));return}let n=new File([a],t,{type:a.type});C(e=>[...e,{source:"figma",status:"uploading",image:n}]),z({index:i,image:n,source:"figma"}),s.Am.success("Pasted ".concat(t).concat(r?" from Figma":""))}catch(e){console.error("Failed to paste from clipboard:",e),s.Am.error("Failed to paste from clipboard. Please check browser permissions and try again.")}}},T=b.some(e=>"uploading"===e.status||"generating"===e.status),R=b.filter(e=>"success"===e.status),Z=R.length>0;return(0,r.jsxs)(i.ae,{open:t,onOpenChange:e=>{e||A||(h(),U.current=crypto.randomUUID(),C([]))},children:[(0,r.jsx)(i.al,{title:"Generate from image"}),(0,r.jsxs)(i.aj,{gap:0,children:[(0,r.jsx)(i.ak,{hidden:!0,children:"Upload images to generate slices with AI"}),0===b.length?(0,r.jsx)(i.D,{padding:16,height:"100%",children:(0,r.jsx)(i.aF,{onFilesSelected:D,assetType:"image",maxFiles:10,overlay:(0,r.jsx)(w,{onFilesSelected:D,droppingFiles:!0}),children:(0,r.jsx)(w,{onFilesSelected:D})})}):(0,r.jsx)(i.bn,{stableScrollbar:!1,children:(0,r.jsx)(i.D,{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:16,children:b.map((e,t)=>(0,r.jsx)(y,{slice:e},"slice-".concat(t)))})}),(0,r.jsxs)(i.ah,{children:[(0,r.jsx)(i.ai,{disabled:A}),(0,r.jsxs)(i.af,{disabled:!Z||T,loading:A,onClick:()=>{let e=b.reduce((e,t)=>("success"===t.status&&"upload"===t.source&&e.push(t),e),[]);if(!e.length)return;let t=U.current;I(!0),S(e).then(async e=>{let{slices:r,library:i}=e;if(t===U.current)for(let{model:e,langSmithUrl:t}of(N((await (0,c.y0)()).libraries),k(),o({slices:r,library:i}),I(!1),U.current=crypto.randomUUID(),C([]),E("createSlice"),r))c.Xe.track({event:"slice:created",id:e.id,name:e.name,library:i,location:a,mode:"ai",langSmithUrl:t}),(0,d.nZ)({type:"model",library:i,sliceId:e.id,variationId:e.variations[0].id,langSmithUrl:t})}).catch(()=>{t===U.current&&(I(!1),s.Am.error("An unexpected error happened while adding slices."))})},children:[j(a)," (",R.length,")"]})]})]})]})}function w(e){let{droppingFiles:t=!1,onFilesSelected:a}=e;return(0,r.jsx)(i.D,{justifyContent:"center",flexDirection:"column",height:"100%",backgroundColor:t?"purple2":"grey2",border:!0,borderStyle:"dashed",borderColor:t?"purple9":"grey6",children:(0,r.jsxs)(i.s,{children:[(0,r.jsx)(i.x,{lineColor:"purple11",backgroundColor:"purple5",name:"cloudUpload",size:"large"}),(0,r.jsx)(i.z,{children:"Upload your design images."}),(0,r.jsx)(i.w,{children:"Once uploaded, you can generate slices automatically using AI."}),(0,r.jsx)(i.v,{children:(0,r.jsx)(i.aG,{startIcon:"attachFile",onFilesSelected:a,color:"grey",children:"Add images"})})]})})}async function v(e){let{image:t}=e,a=[await g.managerClient.project.getResolvedRepositoryName(),"shared-slices","prismic-inferred-slices",crypto.randomUUID()].join("/");await g.managerClient.screenshots.initS3ACL();let{url:r}=await g.managerClient.screenshots.uploadScreenshot({keyPrefix:a,data:t});return r}async function S(e){let{libraries:t=[]}=await g.managerClient.project.getSliceMachineConfig(),a=t[0];if(!a)throw Error("No library found in the config.");for(let{model:t}of e){let{errors:e}=await g.managerClient.slices.createSlice({libraryID:a,model:t});if(e.length)throw Error("Failed to create slice ".concat(t.id,"."))}let r=await Promise.all(e.map(async e=>{let{model:t,image:r,langSmithUrl:i}=e;return await g.managerClient.slices.updateSliceScreenshot({libraryID:a,sliceID:t.id,variationID:t.variations[0].id,data:r}),{model:t,langSmithUrl:i}}));return{library:a,slices:r}}let j=e=>{switch(e){case"custom_type":return"Add to type";case"page_type":return"Add to page";case"slices":return"Add to slices"}}},27213:function(e,t,a){a.d(t,{F:function(){return n}});var r=a(52322),i=a(11699);let n=e=>{let{menuType:t}=e;return{fromImage:{BackgroundIcon:(0,r.jsx)(i.B,{name:"autoFixHigh",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"purple",variant:"solid",radius:6}),title:"Generate from image",description:"Build a slice based on your design image."},fromScratch:{BackgroundIcon:(0,r.jsx)(i.B,{name:"add",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Start from scratch",description:"Build a custom slice your way."},fromTemplate:{BackgroundIcon:(0,r.jsx)(i.B,{name:"contentCopy",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Use a template",description:"Choose from ready-made examples."},fromExisting:{BackgroundIcon:(0,r.jsx)(i.B,{name:"folder",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Reuse an existing slice",description:"Select from your created slices."}}}},6256:function(e,t,a){a.d(t,{c:function(){return b}});var r=a(52322),i=a(2784),n=a(36131),l=a(75289),s=a(94160),o=a(98250),c=a(88932),d=a(63908),u=a(358),m=a(80148);async function p(e){let{sliceName:t,libraryName:a,location:r,onSuccess:i}=e;try{let e=(0,d.fo)(t),{errors:n}=await m.managerClient.slices.createSlice({libraryID:a,model:e});if(n.length>0)throw n;s.Xe.track({event:"slice:created",id:(0,u.MP)(t),name:t,library:a,location:r,mode:"manual"}),await i(e)}catch(a){let e="An unexpected error happened while creating slice ".concat(t,".");console.error(e,a),c.Am.error(e)}}var g=a(68968),f=a(59532),h=a(54597),y=a(46999),x=a(63019);let b=e=>{let{onClose:t,onSuccess:a,localLibraries:c,location:d,remoteSlices:u}=e,{createSliceSuccess:m}=(0,h.Z)(),[b,w]=(0,i.useState)(!1),{syncChanges:v}=(0,g.g)(),{completeStep:S}=(0,o.k)(),j=async e=>{let t=e.sliceName,r=e.from;w(!0),await p({sliceName:t,libraryName:r,location:d,onSuccess:async e=>{m((await (0,s.y0)()).libraries),a(e,r),v(),S("createSlice")}})};return(0,r.jsx)(f.Z,{testId:"create-slice-modal",isOpen:!0,widthInPx:"530px",isLoading:b,formId:"create-new-slice",close:t,buttonLabel:"Create",onSubmit:e=>{j(e)},initialValues:{sliceName:"",from:c[0].name},validate:e=>(0,x.h)(e,c,u),content:{title:"Create a new slice"},children:e=>{let{touched:t,values:a,setFieldValue:i,errors:s}=e;return(0,r.jsxs)(l.xu,{children:[(0,r.jsx)(y.W,{name:"sliceName",label:"Slice name",placeholder:"Pascalised slice API ID (e.g. TextBlock)",error:t.sliceName?s.sliceName:void 0,testId:"slice-name-input"}),(0,r.jsx)(l.__,{htmlFor:"from",sx:{mb:2},children:"Target Library"}),(0,r.jsx)(n.ZP,{name:"from",options:c.map(e=>({value:e.name,label:e.name})),onChange:e=>e?void i("from",e.value):null,defaultValue:{value:a.from,label:a.from},styles:{option:e=>({...e,color:"#161618"})},theme:e=>({...e,colors:{...e.colors,primary:"#E9E8EA"}}),menuPortalTarget:document.body})]})}})}},63019:function(e,t,a){a.d(t,{h:function(){return o}});var r=a(96009),i=a.n(r),n=a(74600),l=a.n(n),s=a(7974);function o(e,t,a){let{sliceName:r}=e;return r?s.lS.includes(r.toLowerCase())?{sliceName:'Name "'.concat(r,'" is reserved for Slice Machine use.')}:s.xo.exec(r)?l()(i()(r)).replace(/\s/gm,"")!==r.trim()?{sliceName:"Value has to be PascalCased."}:r.match(/^\d/)?{sliceName:"Value cannot start with a number."}:[...t.flatMap(e=>e.components.map(e=>e.model.name)),...a.map(e=>e.name)].includes(r)?{sliceName:"Slice name is already taken."}:void 0:{sliceName:"No special characters allowed."}:{sliceName:"Cannot be empty"}}},21151:function(e,t,a){var r=a(52322),i=a(75289);t.Z=function(e){let{elems:t,renderElem:a,defineElementKey:n,gridTemplateMinPx:l="320px",gridGap:s="16px",sx:o}=e;return(0,r.jsx)(i.xu,{as:"section",sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(".concat(l,", 1fr))"),gridGap:s,pt:2,...o},children:t.map((e,t)=>e?(0,r.jsx)("span",{children:a(e,t)},"".concat(n(e),"-").concat(t+1)):null)})}}}]);
|
|
File without changes
|