@cntrl-site/sdk-nextjs 0.17.1 → 0.18.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/common/useRegisterResize.js +1 -1
- package/lib/components/Head.js +1 -1
- package/lib/components/Item.js +8 -8
- package/lib/components/Page.js +1 -4
- package/lib/components/items/ImageItem.js +2 -1
- package/lib/components/items/RectangleItem.js +3 -2
- package/lib/components/items/RichTextItem.js +3 -2
- package/lib/components/items/VideoItem.js +2 -1
- package/lib/components/items/useRichTextItem.js +2 -9
- package/lib/components/items/useStickyItemTop.js +1 -5
- package/lib/components/useSectionColor.js +3 -3
- package/lib/provider/CntrlSdkContext.js +1 -8
- package/lib/utils/Animator/Animator.js +3 -2
- package/lib/utils/HoverStyles/HoverStyles.js +4 -4
- package/lib/utils/RichTextConverter/RichTextConverter.js +3 -2
- package/package.json +3 -2
- package/src/common/useKeyframeValue.ts +3 -3
- package/src/common/useRegisterResize.ts +1 -1
- package/src/components/Article.tsx +1 -1
- package/src/components/Head.tsx +4 -4
- package/src/components/Item.tsx +15 -16
- package/src/components/LayoutStyle.tsx +3 -3
- package/src/components/Page.tsx +4 -10
- package/src/components/Section.tsx +4 -4
- package/src/components/items/CustomItem.tsx +1 -1
- package/src/components/items/ImageItem.tsx +2 -1
- package/src/components/items/RectangleItem.tsx +2 -1
- package/src/components/items/RichTextItem.tsx +2 -1
- package/src/components/items/VideoItem.tsx +2 -1
- package/src/components/items/VimeoEmbed.tsx +1 -2
- package/src/components/items/YoutubeEmbed.tsx +1 -2
- package/src/components/items/useEmbedVideoItem.ts +2 -2
- package/src/components/items/useFileItem.ts +2 -2
- package/src/components/items/useRectangleItem.ts +2 -2
- package/src/components/items/useRichTextItem.ts +4 -10
- package/src/components/items/useRichTextItemValues.ts +2 -2
- package/src/components/items/useStickyItemTop.ts +3 -6
- package/src/components/useItemAngle.ts +2 -2
- package/src/components/useItemDimensions.ts +2 -2
- package/src/components/useItemPosition.ts +2 -2
- package/src/components/useItemScale.ts +2 -2
- package/src/components/useSectionColor.ts +1 -1
- package/src/components/useSectionHeightMap.ts +3 -3
- package/src/provider/CntrlSdkContext.ts +10 -21
- package/src/provider/Keyframes.ts +2 -2
- package/src/utils/Animator/Animator.ts +31 -30
- package/src/utils/HoverStyles/HoverStyles.ts +5 -4
- package/src/utils/RichTextConverter/RichTextConverter.tsx +10 -9
- package/cntrl-site-sdk-nextjs-0.17.1.tgz +0 -0
- package/lib/utils/generateTypePresetStyles/generateTypePresetStyles.js +0 -27
- package/src/utils/generateTypePresetStyles/__mock__/layoutsMock.ts +0 -43
- package/src/utils/generateTypePresetStyles/__mock__/presetMock.ts +0 -33
- package/src/utils/generateTypePresetStyles/generateTypePresetStyles.test.ts +0 -49
- package/src/utils/generateTypePresetStyles/generateTypePresetStyles.ts +0 -25
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { TTypePresets, TypePresetStatus } from '@cntrl-site/sdk';
|
|
2
|
-
|
|
3
|
-
export const presetMock: TTypePresets = {
|
|
4
|
-
id: 'presetId',
|
|
5
|
-
presets: [
|
|
6
|
-
{
|
|
7
|
-
id: 'heading01',
|
|
8
|
-
fontFamily: 'Aeonik',
|
|
9
|
-
fontWeight: '400',
|
|
10
|
-
fontStyle: '',
|
|
11
|
-
name: 'Heading',
|
|
12
|
-
fontSize: 24,
|
|
13
|
-
lineHeight: 36,
|
|
14
|
-
wordSpacing: 1,
|
|
15
|
-
letterSpacing: 1,
|
|
16
|
-
color: 'rgba(0, 0, 0, 1)',
|
|
17
|
-
status: TypePresetStatus.Active
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
id: 'heading02',
|
|
21
|
-
fontFamily: 'Aeonik',
|
|
22
|
-
fontWeight: '400',
|
|
23
|
-
fontStyle: 'italic',
|
|
24
|
-
name: 'Heading 2',
|
|
25
|
-
fontSize: 24,
|
|
26
|
-
lineHeight: 36,
|
|
27
|
-
wordSpacing: 1,
|
|
28
|
-
letterSpacing: 1,
|
|
29
|
-
color: 'rgba(0, 0, 0, 1)',
|
|
30
|
-
status: TypePresetStatus.Active
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { generateTypePresetStyles } from './generateTypePresetStyles';
|
|
2
|
-
import { presetMock } from './__mock__/presetMock';
|
|
3
|
-
import { layoutsMock } from './__mock__/layoutsMock';
|
|
4
|
-
|
|
5
|
-
describe('generateTypePresetStyles', () => {
|
|
6
|
-
it('generates blocks of styles', () => {
|
|
7
|
-
const styles = generateTypePresetStyles(presetMock, layoutsMock);
|
|
8
|
-
const expectedMedia = (id: string) =>
|
|
9
|
-
`@media (min-width: 0px) and (max-width: 767px) {
|
|
10
|
-
.cntrl-preset-${id} {
|
|
11
|
-
font-size: 6.4vw;
|
|
12
|
-
line-height: 9.6vw;
|
|
13
|
-
letter-spacing: 0.26666666666666666vw;
|
|
14
|
-
word-spacing: 0.26666666666666666vw;
|
|
15
|
-
color: rgba(0, 0, 0, 1);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
@media (min-width: 768px) and (max-width: 1023px) {
|
|
19
|
-
.cntrl-preset-${id} {
|
|
20
|
-
font-size: 3.125vw;
|
|
21
|
-
line-height: 4.6875vw;
|
|
22
|
-
letter-spacing: 0.13020833333333331vw;
|
|
23
|
-
word-spacing: 0.13020833333333331vw;
|
|
24
|
-
color: rgba(0, 0, 0, 1);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
@media (min-width: 1024px) {
|
|
28
|
-
.cntrl-preset-${id} {
|
|
29
|
-
font-size: 1.6666666666666667vw;
|
|
30
|
-
line-height: 2.5vw;
|
|
31
|
-
letter-spacing: 0.06944444444444445vw;
|
|
32
|
-
word-spacing: 0.06944444444444445vw;
|
|
33
|
-
color: rgba(0, 0, 0, 1);
|
|
34
|
-
}
|
|
35
|
-
}`;
|
|
36
|
-
expect(styles).toBe(
|
|
37
|
-
`.cntrl-preset-heading01 {
|
|
38
|
-
font-family: Aeonik;
|
|
39
|
-
font-weight: 400;
|
|
40
|
-
}
|
|
41
|
-
${expectedMedia('heading01')}
|
|
42
|
-
.cntrl-preset-heading02 {
|
|
43
|
-
font-family: Aeonik;
|
|
44
|
-
font-style: italic;
|
|
45
|
-
font-weight: 400;
|
|
46
|
-
}
|
|
47
|
-
${expectedMedia('heading02')}`);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getLayoutMediaQuery, TLayout, TTypePresets, CntrlColor } from '@cntrl-site/sdk';
|
|
2
|
-
|
|
3
|
-
const reEmptyLines = /^\s*\n/gm;
|
|
4
|
-
|
|
5
|
-
export function generateTypePresetStyles(preset: TTypePresets, layouts: TLayout[]): string {
|
|
6
|
-
const sorted = layouts.slice().sort((a, b) => a.startsWith - b.startsWith);
|
|
7
|
-
const stylesStr = (`
|
|
8
|
-
${preset.presets.map(p => (`
|
|
9
|
-
.cntrl-preset-${p.id} {
|
|
10
|
-
font-family: ${p.fontFamily};
|
|
11
|
-
${p.fontStyle.length > 0 ? `font-style: ${p.fontStyle};` : ''}
|
|
12
|
-
font-weight: ${p.fontWeight};
|
|
13
|
-
}
|
|
14
|
-
${sorted.map(l => (`
|
|
15
|
-
${getLayoutMediaQuery(l.id, sorted)} {
|
|
16
|
-
.cntrl-preset-${p.id} {
|
|
17
|
-
font-size: ${p.fontSize / l.exemplary * 100}vw;
|
|
18
|
-
line-height: ${p.lineHeight / l.exemplary * 100}vw;
|
|
19
|
-
letter-spacing: ${p.letterSpacing / l.exemplary * 100}vw;
|
|
20
|
-
word-spacing: ${p.wordSpacing / l.exemplary * 100}vw;
|
|
21
|
-
color: ${CntrlColor.parse(p.color).toCss()};
|
|
22
|
-
}
|
|
23
|
-
}`)).join('\n')}`)).join('\n')}`);
|
|
24
|
-
return stylesStr.replace(reEmptyLines, '');
|
|
25
|
-
}
|