@cntrl-site/sdk 1.2.3 → 1.3.0
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/Client/Client.js +7 -32
- package/lib/index.js +18 -16
- package/lib/schemas/article/Article.schema.js +9 -0
- package/lib/schemas/article/Item.schema.js +137 -0
- package/lib/schemas/article/ItemArea.schema.js +16 -0
- package/lib/schemas/article/ItemBase.schema.js +20 -0
- package/lib/schemas/article/ItemState.schema.js +52 -0
- package/lib/schemas/article/RichTextItem.schema.js +60 -0
- package/lib/schemas/article/Section.schema.js +20 -0
- package/lib/schemas/keyframe/Keyframes.schema.js +114 -0
- package/lib/schemas/project/Layout.schema.js +10 -0
- package/lib/schemas/project/Project.schema.js +48 -0
- package/lib/types/article/Article.js +2 -0
- package/lib/types/article/ArticleItemType.js +13 -0
- package/lib/types/article/Item.js +3 -0
- package/lib/types/article/ItemArea.js +21 -0
- package/lib/types/article/ItemState.js +3 -0
- package/lib/types/article/RichText.js +27 -0
- package/lib/types/article/Section.js +8 -0
- package/lib/types/keyframe/Keyframe.js +20 -0
- package/lib/types/project/Fonts.js +11 -0
- package/lib/types/project/Layout.js +2 -0
- package/lib/types/project/Meta.js +2 -0
- package/lib/types/project/Page.js +2 -0
- package/lib/types/project/Project.js +2 -0
- package/lib/utils.js +15 -1
- package/package.json +3 -3
- package/src/Client/Client.test.ts +1 -5
- package/src/Client/Client.ts +18 -51
- package/src/Client/__mock__/articleMock.ts +2 -2
- package/src/Client/__mock__/keyframesMock.ts +2 -3
- package/src/Client/__mock__/projectMock.ts +2 -7
- package/src/FontFaceGenerator/FontFaceGenerator.test.ts +2 -4
- package/src/FontFaceGenerator/FontFaceGenerator.ts +2 -2
- package/src/cli.ts +2 -2
- package/src/index.ts +25 -2
- package/src/schemas/article/Article.schema.ts +7 -0
- package/src/schemas/article/Item.schema.ts +175 -0
- package/src/schemas/article/ItemArea.schema.ts +14 -0
- package/src/schemas/article/ItemBase.schema.ts +20 -0
- package/src/schemas/article/ItemState.schema.ts +62 -0
- package/src/schemas/article/RichTextItem.schema.ts +68 -0
- package/src/schemas/article/Section.schema.ts +19 -0
- package/src/schemas/keyframe/Keyframes.schema.ts +128 -0
- package/src/schemas/project/Layout.schema.ts +8 -0
- package/src/schemas/project/Project.schema.ts +48 -0
- package/src/types/article/Article.ts +6 -0
- package/src/types/article/ArticleItemType.ts +9 -0
- package/src/types/article/Item.ts +150 -0
- package/src/types/article/ItemArea.ts +29 -0
- package/src/types/article/ItemState.ts +64 -0
- package/src/types/article/RichText.ts +46 -0
- package/src/types/article/Section.ts +22 -0
- package/src/types/keyframe/Keyframe.ts +102 -0
- package/src/types/project/Fonts.ts +25 -0
- package/src/types/project/Layout.ts +6 -0
- package/src/types/project/Meta.ts +10 -0
- package/src/types/project/Page.ts +13 -0
- package/src/types/project/Project.ts +19 -0
- package/src/utils.ts +16 -2
- package/src/Client/__mock__/typePresetsMock.ts +0 -6
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z, ZodType } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
CustomHoverStateParams, EmbedHoverStateParams,
|
|
4
|
+
MediaHoverStateParams,
|
|
5
|
+
RectangleHoverStateParams, RichTextHoverStateParams
|
|
6
|
+
} from '../../types/article/ItemState';
|
|
7
|
+
|
|
8
|
+
export const getHoverParamsSchema = <T extends z.ZodTypeAny>(schema: T) => {
|
|
9
|
+
return z.object({
|
|
10
|
+
timing: z.string(),
|
|
11
|
+
duration: z.number(),
|
|
12
|
+
delay: z.number(),
|
|
13
|
+
value: schema
|
|
14
|
+
}).optional();
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const ItemHoverStateBaseSchema = z.object({
|
|
18
|
+
width: getHoverParamsSchema(z.number()),
|
|
19
|
+
height: getHoverParamsSchema(z.number()),
|
|
20
|
+
angle: getHoverParamsSchema(z.number()),
|
|
21
|
+
top: getHoverParamsSchema(z.number()),
|
|
22
|
+
left: getHoverParamsSchema(z.number()),
|
|
23
|
+
scale: getHoverParamsSchema(z.number()),
|
|
24
|
+
blur: getHoverParamsSchema(z.number())
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const MediaHoverStateParamsSchema =
|
|
28
|
+
z.object({
|
|
29
|
+
opacity: getHoverParamsSchema(z.number()),
|
|
30
|
+
radius: getHoverParamsSchema(z.number()),
|
|
31
|
+
strokeWidth: getHoverParamsSchema(z.number()),
|
|
32
|
+
strokeColor: getHoverParamsSchema(z.string())
|
|
33
|
+
})
|
|
34
|
+
.merge(ItemHoverStateBaseSchema) satisfies ZodType<MediaHoverStateParams>;
|
|
35
|
+
|
|
36
|
+
export const RectangleHoverStateParamsSchema = z.object({
|
|
37
|
+
strokeWidth: getHoverParamsSchema(z.number()),
|
|
38
|
+
radius: getHoverParamsSchema(z.number()),
|
|
39
|
+
fillColor: getHoverParamsSchema(z.string()),
|
|
40
|
+
strokeColor: getHoverParamsSchema(z.string()),
|
|
41
|
+
backdropBlur: getHoverParamsSchema(z.number())
|
|
42
|
+
}).merge(ItemHoverStateBaseSchema) satisfies ZodType<RectangleHoverStateParams>;
|
|
43
|
+
|
|
44
|
+
export const CustomItemHoverStateParamsSchema = ItemHoverStateBaseSchema satisfies ZodType<CustomHoverStateParams>;
|
|
45
|
+
|
|
46
|
+
export const EmbedHoverStateParamsSchema = z.object({
|
|
47
|
+
radius: getHoverParamsSchema(z.number())
|
|
48
|
+
}).merge(ItemHoverStateBaseSchema) satisfies ZodType<EmbedHoverStateParams>;
|
|
49
|
+
|
|
50
|
+
export const RichTextHoverStateParamsSchema = z.object({
|
|
51
|
+
color: getHoverParamsSchema(z.string()),
|
|
52
|
+
letterSpacing: getHoverParamsSchema(z.number()),
|
|
53
|
+
wordSpacing: getHoverParamsSchema(z.number())
|
|
54
|
+
}).merge(ItemHoverStateBaseSchema) satisfies ZodType<RichTextHoverStateParams>;
|
|
55
|
+
|
|
56
|
+
export const ItemHoverStateParamsSchema = z.union([
|
|
57
|
+
EmbedHoverStateParamsSchema,
|
|
58
|
+
MediaHoverStateParamsSchema,
|
|
59
|
+
RectangleHoverStateParamsSchema,
|
|
60
|
+
RichTextHoverStateParamsSchema,
|
|
61
|
+
CustomItemHoverStateParamsSchema
|
|
62
|
+
]);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z, ZodType } from 'zod';
|
|
2
|
+
import { RichTextBlock, TextAlign, TextDecoration, TextTransform, VerticalAlign } from '../../types/article/RichText';
|
|
3
|
+
import { ItemBaseSchema } from './ItemBase.schema';
|
|
4
|
+
import { ArticleItemType } from '../../types/article/ArticleItemType';
|
|
5
|
+
import { RichTextHoverStateParamsSchema } from './ItemState.schema';
|
|
6
|
+
import { RichTextItem } from '../../types/article/Item';
|
|
7
|
+
|
|
8
|
+
export const RichTextEntitySchema = z.object({
|
|
9
|
+
start: z.number().nonnegative(),
|
|
10
|
+
end: z.number().nonnegative(),
|
|
11
|
+
type: z.string(),
|
|
12
|
+
data: z.any().optional()
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const RichTextStyleSchema = z.object({
|
|
16
|
+
start: z.number().nonnegative(),
|
|
17
|
+
end: z.number().nonnegative(),
|
|
18
|
+
style: z.string().min(1),
|
|
19
|
+
value: z.string().optional()
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const RichTextBlockSchema: z.Schema<RichTextBlock> = z.lazy(() => (
|
|
23
|
+
z.object({
|
|
24
|
+
start: z.number().nonnegative(),
|
|
25
|
+
end: z.number().nonnegative(),
|
|
26
|
+
type: z.string().min(1),
|
|
27
|
+
entities: z.array(RichTextEntitySchema).optional(),
|
|
28
|
+
children: z.array(RichTextBlockSchema).optional(),
|
|
29
|
+
data: z.any().optional()
|
|
30
|
+
})
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
export const RichTextItemSchema = ItemBaseSchema.extend({
|
|
34
|
+
type: z.literal(ArticleItemType.RichText),
|
|
35
|
+
commonParams: z.object({
|
|
36
|
+
text: z.string(),
|
|
37
|
+
blocks: z.array(RichTextBlockSchema).optional()
|
|
38
|
+
}),
|
|
39
|
+
sticky: z.record(
|
|
40
|
+
z.object({
|
|
41
|
+
from: z.number(),
|
|
42
|
+
to: z.number().optional()
|
|
43
|
+
}).nullable(),
|
|
44
|
+
),
|
|
45
|
+
layoutParams: z.record(
|
|
46
|
+
z.object({
|
|
47
|
+
rangeStyles: z.array(RichTextStyleSchema).optional(),
|
|
48
|
+
textAlign: z.nativeEnum(TextAlign),
|
|
49
|
+
sizing: z.string(),
|
|
50
|
+
blur: z.number(),
|
|
51
|
+
fontSize: z.number(),
|
|
52
|
+
lineHeight: z.number(),
|
|
53
|
+
letterSpacing: z.number(),
|
|
54
|
+
wordSpacing: z.number(),
|
|
55
|
+
textTransform: z.nativeEnum(TextTransform),
|
|
56
|
+
verticalAlign: z.nativeEnum(VerticalAlign),
|
|
57
|
+
color: z.string(),
|
|
58
|
+
typeFace: z.string(),
|
|
59
|
+
fontStyle: z.string(),
|
|
60
|
+
fontWeight: z.number(),
|
|
61
|
+
fontVariant: z.string(),
|
|
62
|
+
textDecoration: z.nativeEnum(TextDecoration),
|
|
63
|
+
})
|
|
64
|
+
),
|
|
65
|
+
state: z.object({
|
|
66
|
+
hover: z.record(RichTextHoverStateParamsSchema)
|
|
67
|
+
})
|
|
68
|
+
}) satisfies ZodType<RichTextItem>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SectionHeightMode } from '../../types/article/Section';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { ItemSchema } from './Item.schema';
|
|
4
|
+
|
|
5
|
+
export const SectionHeightSchema = z.object({
|
|
6
|
+
mode: z.nativeEnum(SectionHeightMode),
|
|
7
|
+
units: z.number().nonnegative(),
|
|
8
|
+
vhUnits: z.number().nonnegative().optional()
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
export const SectionSchema = z.object({
|
|
12
|
+
id: z.string().min(1),
|
|
13
|
+
items: z.array(ItemSchema),
|
|
14
|
+
name: z.string().optional(),
|
|
15
|
+
height: z.record(SectionHeightSchema),
|
|
16
|
+
position: z.record(z.number()),
|
|
17
|
+
hidden: z.record(z.boolean()),
|
|
18
|
+
color: z.record(z.nullable(z.string()))
|
|
19
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { KeyframeType } from '../../types/keyframe/Keyframe';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
const KeyframesBaseSchema = z.object({
|
|
5
|
+
id: z.string().min(1),
|
|
6
|
+
layoutId: z.string().min(1),
|
|
7
|
+
itemId: z.string().min(1),
|
|
8
|
+
position: z.number()
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const DimensionsKeyframeSchema = KeyframesBaseSchema.extend({
|
|
12
|
+
type: z.literal(KeyframeType.Dimensions),
|
|
13
|
+
value: z.object({
|
|
14
|
+
width: z.number().nonnegative(),
|
|
15
|
+
height: z.number().nonnegative()
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const PositionKeyframeSchema = KeyframesBaseSchema.extend({
|
|
20
|
+
type: z.literal(KeyframeType.Position),
|
|
21
|
+
value: z.object({
|
|
22
|
+
top: z.number(),
|
|
23
|
+
left: z.number()
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const RotationKeyframeSchema = KeyframesBaseSchema.extend({
|
|
28
|
+
type: z.literal(KeyframeType.Rotation),
|
|
29
|
+
value: z.object({
|
|
30
|
+
angle: z.number()
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const BorderRadiusKeyframeSchema = KeyframesBaseSchema.extend({
|
|
35
|
+
type: z.literal(KeyframeType.BorderRadius),
|
|
36
|
+
value: z.object({
|
|
37
|
+
radius: z.number().nonnegative()
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const BorderWidthKeyframeSchema = KeyframesBaseSchema.extend({
|
|
42
|
+
type: z.literal(KeyframeType.BorderWidth),
|
|
43
|
+
value: z.object({
|
|
44
|
+
borderWidth: z.number().nonnegative()
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const ColorKeyframeSchema = KeyframesBaseSchema.extend({
|
|
49
|
+
type: z.literal(KeyframeType.Color),
|
|
50
|
+
value: z.object({
|
|
51
|
+
color: z.string()
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const BorderColorKeyframeSchema = KeyframesBaseSchema.extend({
|
|
56
|
+
type: z.literal(KeyframeType.BorderColor),
|
|
57
|
+
value: z.object({
|
|
58
|
+
color: z.string()
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const OpacityKeyframeSchema = KeyframesBaseSchema.extend({
|
|
63
|
+
type: z.literal(KeyframeType.Opacity),
|
|
64
|
+
value: z.object({
|
|
65
|
+
opacity: z.number().nonnegative()
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const ScaleKeyframeSchema = KeyframesBaseSchema.extend({
|
|
70
|
+
type: z.literal(KeyframeType.Scale),
|
|
71
|
+
value: z.object({
|
|
72
|
+
scale: z.number().nonnegative()
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const BlurKeyframeSchema = KeyframesBaseSchema.extend({
|
|
77
|
+
type: z.literal(KeyframeType.Blur),
|
|
78
|
+
value: z.object({
|
|
79
|
+
blur: z.number()
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const BackdropBlurKeyframeSchema = KeyframesBaseSchema.extend({
|
|
84
|
+
type: z.literal(KeyframeType.BackdropBlur),
|
|
85
|
+
value: z.object({
|
|
86
|
+
backdropBlur: z.number()
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const TextColorKeyframeSchema = KeyframesBaseSchema.extend({
|
|
91
|
+
type: z.literal(KeyframeType.TextColor),
|
|
92
|
+
value: z.object({
|
|
93
|
+
color: z.string()
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const LetterSpacingKeyframeSchema = KeyframesBaseSchema.extend({
|
|
98
|
+
type: z.literal(KeyframeType.LetterSpacing),
|
|
99
|
+
value: z.object({
|
|
100
|
+
letterSpacing: z.number()
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const WordSpacingKeyframeSchema = KeyframesBaseSchema.extend({
|
|
105
|
+
type: z.literal(KeyframeType.WordSpacing),
|
|
106
|
+
value: z.object({
|
|
107
|
+
wordSpacing: z.number()
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export const KeyframeSchema = z.discriminatedUnion('type', [
|
|
112
|
+
DimensionsKeyframeSchema,
|
|
113
|
+
PositionKeyframeSchema,
|
|
114
|
+
RotationKeyframeSchema,
|
|
115
|
+
BorderRadiusKeyframeSchema,
|
|
116
|
+
BorderWidthKeyframeSchema,
|
|
117
|
+
ColorKeyframeSchema,
|
|
118
|
+
BorderColorKeyframeSchema,
|
|
119
|
+
OpacityKeyframeSchema,
|
|
120
|
+
ScaleKeyframeSchema,
|
|
121
|
+
BlurKeyframeSchema,
|
|
122
|
+
BackdropBlurKeyframeSchema,
|
|
123
|
+
TextColorKeyframeSchema,
|
|
124
|
+
LetterSpacingKeyframeSchema,
|
|
125
|
+
WordSpacingKeyframeSchema
|
|
126
|
+
]);
|
|
127
|
+
|
|
128
|
+
export const KeyframesSchema = z.array(KeyframeSchema);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { LayoutSchema } from './Layout.schema';
|
|
3
|
+
import { FontFileTypes } from '../../types/project/Fonts';
|
|
4
|
+
|
|
5
|
+
export const ProjectSchema = z.object({
|
|
6
|
+
id: z.string().min(1),
|
|
7
|
+
html: z.object({
|
|
8
|
+
head: z.string(),
|
|
9
|
+
afterBodyOpen: z.string(),
|
|
10
|
+
beforeBodyClose: z.string()
|
|
11
|
+
}),
|
|
12
|
+
meta: z.object({
|
|
13
|
+
title: z.string().optional(),
|
|
14
|
+
description: z.string().optional(),
|
|
15
|
+
opengraphThumbnail: z.string().optional(),
|
|
16
|
+
keywords: z.string().optional(),
|
|
17
|
+
favicon: z.string().optional()
|
|
18
|
+
}),
|
|
19
|
+
layouts: z.array(LayoutSchema),
|
|
20
|
+
pages: z.array(z.object({
|
|
21
|
+
title: z.string(),
|
|
22
|
+
articleId: z.string().min(1),
|
|
23
|
+
slug: z.string(),
|
|
24
|
+
meta: z.object({
|
|
25
|
+
title: z.string().optional(),
|
|
26
|
+
description: z.string().optional(),
|
|
27
|
+
opengraphThumbnail: z.string().optional(),
|
|
28
|
+
keywords: z.string().optional(),
|
|
29
|
+
enabled: z.boolean()
|
|
30
|
+
}).optional(),
|
|
31
|
+
id: z.string().min(1)
|
|
32
|
+
})),
|
|
33
|
+
fonts: z.object({
|
|
34
|
+
google: z.string(),
|
|
35
|
+
adobe: z.string(),
|
|
36
|
+
custom: z.array(z.object({
|
|
37
|
+
name: z.string().min(1),
|
|
38
|
+
style: z.string().min(1),
|
|
39
|
+
weight: z.number(),
|
|
40
|
+
files: z.array(
|
|
41
|
+
z.object({
|
|
42
|
+
type: z.nativeEnum(FontFileTypes),
|
|
43
|
+
url: z.string().url()
|
|
44
|
+
})
|
|
45
|
+
)
|
|
46
|
+
}))
|
|
47
|
+
})
|
|
48
|
+
});
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { RichTextBlock, RichTextStyle, TextAlign, TextDecoration, TextTransform, VerticalAlign } from './RichText';
|
|
2
|
+
import { ArticleItemType } from './ArticleItemType';
|
|
3
|
+
import { ItemArea } from './ItemArea';
|
|
4
|
+
import { ItemState } from './ItemState';
|
|
5
|
+
|
|
6
|
+
export type ItemAny = Item<ArticleItemType>;
|
|
7
|
+
|
|
8
|
+
export interface Item<T extends ArticleItemType> {
|
|
9
|
+
id: string;
|
|
10
|
+
type: T;
|
|
11
|
+
area: Record<LayoutIdentifier, ItemArea>;
|
|
12
|
+
hidden: Record<LayoutIdentifier, boolean>;
|
|
13
|
+
link?: Link;
|
|
14
|
+
sticky: Record<LayoutIdentifier, StickyParams | null>;
|
|
15
|
+
commonParams: ItemCommonParamsMap[T];
|
|
16
|
+
state: ItemState<T>;
|
|
17
|
+
layoutParams: Record<LayoutIdentifier, ItemLayoutParamsMap[T]>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ItemCommonParamsMap {
|
|
21
|
+
[ArticleItemType.Image]: ImageCommonParams;
|
|
22
|
+
[ArticleItemType.Video]: VideoCommonParams;
|
|
23
|
+
[ArticleItemType.RichText]: RichTextCommonParams;
|
|
24
|
+
[ArticleItemType.Rectangle]: RectangleCommonParams;
|
|
25
|
+
[ArticleItemType.VimeoEmbed]: VimeoEmbedCommonParams;
|
|
26
|
+
[ArticleItemType.YoutubeEmbed]: YoutubeEmbedCommonParams;
|
|
27
|
+
[ArticleItemType.Custom]: CustomCommonParams;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ItemLayoutParamsMap {
|
|
31
|
+
[ArticleItemType.Image]: ImageLayoutParams;
|
|
32
|
+
[ArticleItemType.Video]: VideoLayoutParams;
|
|
33
|
+
[ArticleItemType.RichText]: RichTextLayoutParams;
|
|
34
|
+
[ArticleItemType.Rectangle]: RectangleLayoutParams;
|
|
35
|
+
[ArticleItemType.VimeoEmbed]: VimeoEmbedLayoutParams;
|
|
36
|
+
[ArticleItemType.YoutubeEmbed]: YoutubeEmbedLayoutParams;
|
|
37
|
+
[ArticleItemType.Custom]: CustomLayoutParams;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface MediaCommonParams {
|
|
41
|
+
url: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface VideoCommonParams extends MediaCommonParams {}
|
|
45
|
+
|
|
46
|
+
interface ImageCommonParams extends MediaCommonParams {}
|
|
47
|
+
|
|
48
|
+
interface RichTextCommonParams {
|
|
49
|
+
text: string;
|
|
50
|
+
blocks?: RichTextBlock[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface RectangleCommonParams {
|
|
54
|
+
ratioLock: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface CustomCommonParams {
|
|
58
|
+
name: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface VimeoEmbedCommonParams {
|
|
62
|
+
play: 'on-hover' | 'on-click' | 'auto';
|
|
63
|
+
controls: boolean;
|
|
64
|
+
loop: boolean;
|
|
65
|
+
muted: boolean;
|
|
66
|
+
pictureInPicture: boolean;
|
|
67
|
+
url: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface YoutubeEmbedCommonParams {
|
|
71
|
+
play: 'on-hover' | 'on-click' | 'auto';
|
|
72
|
+
controls: boolean;
|
|
73
|
+
loop: boolean;
|
|
74
|
+
url: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface MediaLayoutParams {
|
|
78
|
+
opacity: number;
|
|
79
|
+
radius: number;
|
|
80
|
+
strokeWidth: number;
|
|
81
|
+
strokeColor: string;
|
|
82
|
+
blur: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface CustomLayoutParams {}
|
|
86
|
+
|
|
87
|
+
interface VimeoEmbedLayoutParams {
|
|
88
|
+
radius: number;
|
|
89
|
+
blur: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface YoutubeEmbedLayoutParams {
|
|
93
|
+
radius: number;
|
|
94
|
+
blur: number;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface ImageLayoutParams extends MediaLayoutParams {}
|
|
98
|
+
|
|
99
|
+
interface VideoLayoutParams extends MediaLayoutParams {
|
|
100
|
+
autoplay: boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface RichTextLayoutParams {
|
|
104
|
+
rangeStyles?: RichTextStyle[];
|
|
105
|
+
textAlign: TextAlign;
|
|
106
|
+
sizing: string;
|
|
107
|
+
blur: number;
|
|
108
|
+
fontSize: number;
|
|
109
|
+
lineHeight: number;
|
|
110
|
+
letterSpacing: number;
|
|
111
|
+
wordSpacing: number;
|
|
112
|
+
textTransform: TextTransform;
|
|
113
|
+
verticalAlign: VerticalAlign;
|
|
114
|
+
color: string;
|
|
115
|
+
typeFace: string;
|
|
116
|
+
fontStyle: string;
|
|
117
|
+
fontWeight: number;
|
|
118
|
+
textDecoration: TextDecoration;
|
|
119
|
+
fontVariant: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface RectangleLayoutParams {
|
|
123
|
+
radius: number;
|
|
124
|
+
strokeWidth: number;
|
|
125
|
+
fillColor: string;
|
|
126
|
+
strokeColor: string;
|
|
127
|
+
blur: number;
|
|
128
|
+
backdropBlur: number;
|
|
129
|
+
blurMode: 'default' | 'backdrop';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface StickyParams {
|
|
133
|
+
from: number;
|
|
134
|
+
to?: number;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface Link {
|
|
138
|
+
url: string;
|
|
139
|
+
target: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
type LayoutIdentifier = string;
|
|
143
|
+
|
|
144
|
+
export type VideoItem = Item<ArticleItemType.Video>;
|
|
145
|
+
export type RectangleItem = Item<ArticleItemType.Rectangle>;
|
|
146
|
+
export type ImageItem = Item<ArticleItemType.Image>;
|
|
147
|
+
export type RichTextItem = Item<ArticleItemType.RichText>;
|
|
148
|
+
export type VimeoEmbedItem = Item<ArticleItemType.VimeoEmbed>;
|
|
149
|
+
export type YoutubeEmbedItem = Item<ArticleItemType.YoutubeEmbed>;
|
|
150
|
+
export type CustomItem = Item<ArticleItemType.Custom>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export enum AnchorSide {
|
|
2
|
+
Top = 'top',
|
|
3
|
+
Bottom = 'bottom',
|
|
4
|
+
Center = 'center'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export enum ScaleAnchor {
|
|
8
|
+
TopLeft = 'top-left',
|
|
9
|
+
TopCenter = 'top-center',
|
|
10
|
+
TopRight = 'top-right',
|
|
11
|
+
MiddleLeft = 'middle-left',
|
|
12
|
+
MiddleCenter = 'middle-center',
|
|
13
|
+
MiddleRight = 'middle-right',
|
|
14
|
+
BottomLeft = 'bottom-left',
|
|
15
|
+
BottomCenter = 'bottom-center',
|
|
16
|
+
BottomRight = 'bottom-right'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ItemArea {
|
|
20
|
+
top: number;
|
|
21
|
+
left: number;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
zIndex: number;
|
|
25
|
+
angle: number;
|
|
26
|
+
anchorSide?: AnchorSide;
|
|
27
|
+
scale: number;
|
|
28
|
+
scaleAnchor: ScaleAnchor;
|
|
29
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ArticleItemType } from './ArticleItemType';
|
|
2
|
+
|
|
3
|
+
type LayoutIdentifier = string;
|
|
4
|
+
|
|
5
|
+
export interface ItemState<T extends ArticleItemType> {
|
|
6
|
+
hover: Record<LayoutIdentifier, ItemHoverStatesMap[T]>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type ItemHoverState = ItemHoverStatesMap[ArticleItemType];
|
|
10
|
+
|
|
11
|
+
export interface ItemHoverStatesMap {
|
|
12
|
+
[ArticleItemType.Image]: MediaHoverStateParams;
|
|
13
|
+
[ArticleItemType.Video]: MediaHoverStateParams;
|
|
14
|
+
[ArticleItemType.RichText]: RichTextHoverStateParams;
|
|
15
|
+
[ArticleItemType.Rectangle]: RectangleHoverStateParams;
|
|
16
|
+
[ArticleItemType.VimeoEmbed]: EmbedHoverStateParams;
|
|
17
|
+
[ArticleItemType.YoutubeEmbed]: EmbedHoverStateParams;
|
|
18
|
+
[ArticleItemType.Custom]: CustomHoverStateParams;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface HoverParams<T> {
|
|
22
|
+
timing: string;
|
|
23
|
+
duration: number;
|
|
24
|
+
delay: number;
|
|
25
|
+
value: T;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface ItemHoversBaseMap {
|
|
29
|
+
width?: HoverParams<number>;
|
|
30
|
+
height?: HoverParams<number>;
|
|
31
|
+
angle?: HoverParams<number>;
|
|
32
|
+
top?: HoverParams<number>;
|
|
33
|
+
left?: HoverParams<number>;
|
|
34
|
+
scale?: HoverParams<number>;
|
|
35
|
+
blur?: HoverParams<number>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface MediaHoverStateParams extends ItemHoversBaseMap {
|
|
39
|
+
opacity?: HoverParams<number>;
|
|
40
|
+
radius?: HoverParams<number>;
|
|
41
|
+
strokeWidth?: HoverParams<number>;
|
|
42
|
+
strokeColor?: HoverParams<string>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface RichTextHoverStateParams extends ItemHoversBaseMap {
|
|
46
|
+
color?: HoverParams<string>;
|
|
47
|
+
letterSpacing?: HoverParams<number>;
|
|
48
|
+
wordSpacing?: HoverParams<number>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
export interface RectangleHoverStateParams extends ItemHoversBaseMap {
|
|
53
|
+
radius?: HoverParams<number>;
|
|
54
|
+
strokeWidth?: HoverParams<number>;
|
|
55
|
+
fillColor?: HoverParams<string>;
|
|
56
|
+
strokeColor?: HoverParams<string>;
|
|
57
|
+
backdropBlur?: HoverParams<number>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface EmbedHoverStateParams extends ItemHoversBaseMap {
|
|
61
|
+
radius?: HoverParams<number>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface CustomHoverStateParams extends ItemHoversBaseMap {}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface RichTextEntity {
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
4
|
+
type: string;
|
|
5
|
+
data?: any;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface RichTextStyle {
|
|
9
|
+
start: number;
|
|
10
|
+
end: number;
|
|
11
|
+
style: string;
|
|
12
|
+
value?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface RichTextBlock {
|
|
16
|
+
start: number;
|
|
17
|
+
end: number;
|
|
18
|
+
type: string;
|
|
19
|
+
entities?: RichTextEntity[];
|
|
20
|
+
children?: RichTextBlock[];
|
|
21
|
+
data?: any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export enum TextAlign {
|
|
25
|
+
Left = 'left',
|
|
26
|
+
Right = 'right',
|
|
27
|
+
Center = 'center',
|
|
28
|
+
Justify = 'justify'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export enum TextTransform {
|
|
32
|
+
None = 'none',
|
|
33
|
+
Uppercase = 'uppercase',
|
|
34
|
+
Lowercase = 'lowercase'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export enum VerticalAlign {
|
|
38
|
+
Super = 'super',
|
|
39
|
+
Sub = 'sub',
|
|
40
|
+
Unset = 'unset'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export enum TextDecoration {
|
|
44
|
+
Underline = 'underline',
|
|
45
|
+
None = 'none'
|
|
46
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ItemAny } from './Item';
|
|
2
|
+
|
|
3
|
+
export enum SectionHeightMode {
|
|
4
|
+
ControlUnits = 'control-units' ,
|
|
5
|
+
ViewportHeightUnits = 'viewport-height-units'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface SectionHeight {
|
|
9
|
+
mode: SectionHeightMode;
|
|
10
|
+
units: number;
|
|
11
|
+
vhUnits?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface Section {
|
|
15
|
+
id: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
height: Record<string, SectionHeight>;
|
|
18
|
+
hidden: Record<string, boolean>;
|
|
19
|
+
items: ItemAny[];
|
|
20
|
+
position: Record<string, number>;
|
|
21
|
+
color: Record<string, string | null>;
|
|
22
|
+
}
|