@gxpl/sdk 0.0.26 → 0.0.28
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/lib/sdk/schemas/project/Project.schema.d.ts +5 -0
- package/lib/sdk/schemas/project/Project.schema.js +2 -1
- package/lib/sdk/types/project/Page.d.ts +1 -0
- package/lib/sdk-nextjs/components/Page.js +2 -1
- package/lib/sdk-nextjs/components/fixedLayers/FixedLayer.js +19 -3
- package/package.json +1 -1
|
@@ -332,12 +332,15 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
332
332
|
pages: z.ZodArray<z.ZodObject<{
|
|
333
333
|
articleId: z.ZodString;
|
|
334
334
|
id: z.ZodString;
|
|
335
|
+
isStartScene: z.ZodDefault<z.ZodBoolean>;
|
|
335
336
|
}, "strip", z.ZodTypeAny, {
|
|
336
337
|
id: string;
|
|
337
338
|
articleId: string;
|
|
339
|
+
isStartScene: boolean;
|
|
338
340
|
}, {
|
|
339
341
|
id: string;
|
|
340
342
|
articleId: string;
|
|
343
|
+
isStartScene?: boolean | undefined;
|
|
341
344
|
}>, "many">;
|
|
342
345
|
fonts: z.ZodObject<{
|
|
343
346
|
google: z.ZodString;
|
|
@@ -1020,6 +1023,7 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
1020
1023
|
pages: {
|
|
1021
1024
|
id: string;
|
|
1022
1025
|
articleId: string;
|
|
1026
|
+
isStartScene: boolean;
|
|
1023
1027
|
}[];
|
|
1024
1028
|
fonts: {
|
|
1025
1029
|
custom: {
|
|
@@ -1166,6 +1170,7 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
1166
1170
|
pages: {
|
|
1167
1171
|
id: string;
|
|
1168
1172
|
articleId: string;
|
|
1173
|
+
isStartScene?: boolean | undefined;
|
|
1169
1174
|
}[];
|
|
1170
1175
|
fonts: {
|
|
1171
1176
|
custom: {
|
|
@@ -43,7 +43,8 @@ exports.ProjectSchema = zod_1.z.object({
|
|
|
43
43
|
exemplary: zod_1.z.number().positive(),
|
|
44
44
|
pages: zod_1.z.array(zod_1.z.object({
|
|
45
45
|
articleId: zod_1.z.string().min(1),
|
|
46
|
-
id: zod_1.z.string().min(1)
|
|
46
|
+
id: zod_1.z.string().min(1),
|
|
47
|
+
isStartScene: zod_1.z.boolean().default(false)
|
|
47
48
|
})),
|
|
48
49
|
fonts: zod_1.z.object({
|
|
49
50
|
google: zod_1.z.string(),
|
|
@@ -11,9 +11,10 @@ const TransitionMachineContext_1 = require("../provider/TransitionMachineContext
|
|
|
11
11
|
const Scenes_1 = require("./Scenes/Scenes");
|
|
12
12
|
const FixedLayer_1 = require("./fixedLayers/FixedLayer");
|
|
13
13
|
const Page = ({ project, articlesData }) => {
|
|
14
|
+
var _a, _b;
|
|
14
15
|
const afterBodyOpen = (0, html_react_parser_1.default)(project.html.afterBodyOpen);
|
|
15
16
|
const beforeBodyClose = (0, html_react_parser_1.default)(project.html.beforeBodyClose);
|
|
16
|
-
const startScene = Object.keys(articlesData)[0];
|
|
17
|
+
const startScene = (_b = (_a = project.pages.find(page => page.isStartScene)) === null || _a === void 0 ? void 0 : _a.articleId) !== null && _b !== void 0 ? _b : Object.keys(articlesData)[0];
|
|
17
18
|
const scenes = Object.values(articlesData).map(({ article }) => ({ id: article.id }));
|
|
18
19
|
const { relations } = project;
|
|
19
20
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Head_1.CNTRLHead, { project: project }), afterBodyOpen, (0, jsx_runtime_1.jsxs)(TransitionMachineContext_1.TransitionMachineContext.Provider, { options: {
|
|
@@ -13,12 +13,28 @@ const effects_1 = require("@cntrl-site/effects");
|
|
|
13
13
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
14
14
|
const Item_1 = require("../items/Item");
|
|
15
15
|
const FixedLayerTransitionsProvider_1 = require("../../fixedLayers/FixedLayerTransitionsProvider");
|
|
16
|
+
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
16
17
|
const FixedLayer = ({ layer, type }) => {
|
|
17
|
-
const fixedLayerRef = (0, react_1.
|
|
18
|
+
const [fixedLayerRef, setFixedLayerRef] = (0, react_1.useState)(null);
|
|
19
|
+
const { exemplary } = (0, useCntrlContext_1.useCntrlContext)();
|
|
18
20
|
const id = (0, react_1.useId)();
|
|
19
|
-
const
|
|
21
|
+
const [deviation, setDeviation] = (0, react_1.useState)(1);
|
|
22
|
+
const articleRectObserver = (0, useArticleRectObserver_1.useArticleRectObserver)(fixedLayerRef);
|
|
20
23
|
const webglContextManager = (0, react_1.useMemo)(() => new effects_1.WebGLContextManager(), []);
|
|
21
|
-
|
|
24
|
+
(0, react_1.useEffect)(() => {
|
|
25
|
+
if (!fixedLayerRef)
|
|
26
|
+
return;
|
|
27
|
+
const observer = new ResizeObserver((entries) => {
|
|
28
|
+
const entry = entries[0];
|
|
29
|
+
if (entry.contentRect.width !== 0) {
|
|
30
|
+
setDeviation(entry.contentRect.width / exemplary);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
observer.observe(fixedLayerRef);
|
|
34
|
+
return () => observer.unobserve(fixedLayerRef);
|
|
35
|
+
}, [articleRectObserver, fixedLayerRef, exemplary]);
|
|
36
|
+
const layoutDeviationStyle = { '--layout-deviation': deviation };
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(ArticleRectContext_1.ArticleRectContext.Provider, { value: articleRectObserver, children: (0, jsx_runtime_1.jsx)(FixedLayerTransitionsProvider_1.FixedLayerTransitionsProvider, { fixedLayer: layer, children: (0, jsx_runtime_1.jsxs)(WebGLContextManagerContext_1.WebglContextManagerContext.Provider, { value: webglContextManager, children: [(0, jsx_runtime_1.jsx)("div", { className: `fixed-layer-${type}`, ref: setFixedLayerRef, style: layoutDeviationStyle, children: layer.items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { isInFixedLayer: true, item: item, sectionId: layer.id }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
22
38
|
.fixed-layer-${type} {
|
|
23
39
|
position: fixed;
|
|
24
40
|
top: 0;
|