@cntrl-site/sdk 1.25.8 → 1.25.9-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/LICENSE +21 -21
- package/README.md +2 -2
- package/lib/FontFaceGenerator/FontFaceGenerator.js +6 -6
- package/lib/Rect/Rect.d.ts +1 -0
- package/lib/Rect/Rect.js +12 -4
- package/lib/utils.js +2 -2
- package/package.json +62 -62
- package/resources/template.scss.ejs +50 -50
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 CNTRL
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 CNTRL
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
# CNTRL SDK
|
|
2
|
-
This is a root SDK module for CNTRL. Should be used along with other framework-specific modules like `@cntrl-site/sdk-react`
|
|
1
|
+
# CNTRL SDK
|
|
2
|
+
This is a root SDK module for CNTRL. Should be used along with other framework-specific modules like `@cntrl-site/sdk-react`
|
|
@@ -15,12 +15,12 @@ class FontFaceGenerator {
|
|
|
15
15
|
const otherFiles = font.files
|
|
16
16
|
.filter(file => file.type !== 'eot')
|
|
17
17
|
.map(file => `url('${file.url}') format('${FILE_TYPES_MAP[file.type] || file.type}')`);
|
|
18
|
-
return `
|
|
19
|
-
@font-face {
|
|
20
|
-
font-family: "${font.name}";
|
|
21
|
-
font-weight: ${font.weight};
|
|
22
|
-
font-style: ${font.style};
|
|
23
|
-
${eotFile ? `src: url('${eotFile.url}');\n ` : ''}src: ${otherFiles.join(', ')};
|
|
18
|
+
return `
|
|
19
|
+
@font-face {
|
|
20
|
+
font-family: "${font.name}";
|
|
21
|
+
font-weight: ${font.weight};
|
|
22
|
+
font-style: ${font.style};
|
|
23
|
+
${eotFile ? `src: url('${eotFile.url}');\n ` : ''}src: ${otherFiles.join(', ')};
|
|
24
24
|
}`;
|
|
25
25
|
}).join('\n');
|
|
26
26
|
}
|
package/lib/Rect/Rect.d.ts
CHANGED
package/lib/Rect/Rect.js
CHANGED
|
@@ -30,8 +30,9 @@ class Rect {
|
|
|
30
30
|
&& Math.round(rect1.bottom) === Math.round(rect2.bottom);
|
|
31
31
|
}
|
|
32
32
|
static scale(rect, factor, origin) {
|
|
33
|
-
const
|
|
34
|
-
const
|
|
33
|
+
const normalizedFactor = _a.getNormalizedFactor(factor);
|
|
34
|
+
const width = rect.width * normalizedFactor;
|
|
35
|
+
const height = rect.height * normalizedFactor;
|
|
35
36
|
const dw = rect.width - width;
|
|
36
37
|
const dh = rect.height - height;
|
|
37
38
|
const [kt, kl] = Rect_1.scaleMatrix[origin];
|
|
@@ -40,8 +41,9 @@ class Rect {
|
|
|
40
41
|
return new _a(x, y, width, height);
|
|
41
42
|
}
|
|
42
43
|
static scaleWithOrigin(rect, factor, kt, kl) {
|
|
43
|
-
const
|
|
44
|
-
const
|
|
44
|
+
const normalizedFactor = _a.getNormalizedFactor(factor);
|
|
45
|
+
const width = rect.width * normalizedFactor;
|
|
46
|
+
const height = rect.height * normalizedFactor;
|
|
45
47
|
const dw = rect.width - width;
|
|
46
48
|
const dh = rect.height - height;
|
|
47
49
|
const x = rect.left + (kl * dw);
|
|
@@ -181,6 +183,12 @@ class Rect {
|
|
|
181
183
|
const y = rect.top + (rect.height - newDimensions.height) / 2;
|
|
182
184
|
return { x, y };
|
|
183
185
|
}
|
|
186
|
+
static getNormalizedFactor(factor) {
|
|
187
|
+
const EPSILON = 1e-10;
|
|
188
|
+
return factor === 0 ? EPSILON :
|
|
189
|
+
factor === Infinity ? 1 / EPSILON :
|
|
190
|
+
factor;
|
|
191
|
+
}
|
|
184
192
|
}
|
|
185
193
|
exports.Rect = Rect;
|
|
186
194
|
_a = Rect;
|
package/lib/utils.js
CHANGED
|
@@ -8,8 +8,8 @@ function getLayoutStyles(layouts, layoutValues, mapToStyles) {
|
|
|
8
8
|
.sort((a, b) => a.startsWith - b.startsWith)
|
|
9
9
|
.reduce((acc, layout) => {
|
|
10
10
|
const values = layoutValues.map(lv => lv[layout.id]);
|
|
11
|
-
return `
|
|
12
|
-
${acc}
|
|
11
|
+
return `
|
|
12
|
+
${acc}
|
|
13
13
|
${layout.startsWith !== 0
|
|
14
14
|
? `@media (min-width: ${layout.startsWith}px) {${mapToStyles(values, layout.exemplary)}}`
|
|
15
15
|
: `${mapToStyles(values, layout.exemplary)}`}`;
|
package/package.json
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@cntrl-site/sdk",
|
|
3
|
-
"version": "1.25.
|
|
4
|
-
"description": "Generic SDK for use in public websites.",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"types": "lib/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "jest",
|
|
9
|
-
"prebuild": "rimraf ./lib",
|
|
10
|
-
"build": "tsc --project tsconfig.build.json",
|
|
11
|
-
"prepublishOnly": "cross-env NODE_ENV=production npm run build"
|
|
12
|
-
},
|
|
13
|
-
"bin": {
|
|
14
|
-
"cntrl-sdk": "lib/cli.js"
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"lib",
|
|
18
|
-
"resources"
|
|
19
|
-
],
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/cntrl-site/sdk.git"
|
|
23
|
-
},
|
|
24
|
-
"author": "arsen@momdesign.nyc",
|
|
25
|
-
"license": "MIT",
|
|
26
|
-
"bugs": {
|
|
27
|
-
"url": "https://github.com/cntrl-site/sdk/issues"
|
|
28
|
-
},
|
|
29
|
-
"homepage": "https://github.com/cntrl-site/sdk#readme",
|
|
30
|
-
"directories": {
|
|
31
|
-
"lib": "lib"
|
|
32
|
-
},
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@splidejs/react-splide": "^0.7.12",
|
|
35
|
-
"@types/ejs": "^3.1.2",
|
|
36
|
-
"@types/isomorphic-fetch": "^0.0.36",
|
|
37
|
-
"@types/ua-parser-js": "^0.7.39",
|
|
38
|
-
"commander": "^10.0.1",
|
|
39
|
-
"dotenv": "^16.1.3",
|
|
40
|
-
"ejs": "^3.1.9",
|
|
41
|
-
"isomorphic-fetch": "^3.0.0",
|
|
42
|
-
"mp4box": "^0.5.2",
|
|
43
|
-
"styled-jsx": "^5.1.6",
|
|
44
|
-
"ts-node": "^10.9.1",
|
|
45
|
-
"ua-parser-js": "^1.0.37",
|
|
46
|
-
"url": "^0.11.0",
|
|
47
|
-
"zod": "^3.22.4"
|
|
48
|
-
},
|
|
49
|
-
"devDependencies": {
|
|
50
|
-
"@tsconfig/node16": "^1.0.3",
|
|
51
|
-
"@tsconfig/recommended": "^1.0.1",
|
|
52
|
-
"@types/jest": "^29.0.0",
|
|
53
|
-
"@types/node": "^18.11.7",
|
|
54
|
-
"@types/react": "^18.2.0",
|
|
55
|
-
"@types/react-dom": "^18.2.0",
|
|
56
|
-
"@vitejs/plugin-react": "^4.3.4",
|
|
57
|
-
"cross-env": "^10.1.0",
|
|
58
|
-
"jest": "^28.1.3",
|
|
59
|
-
"ts-jest": "^28.0.8",
|
|
60
|
-
"typescript": "^5.2.2"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@cntrl-site/sdk",
|
|
3
|
+
"version": "1.25.9-0",
|
|
4
|
+
"description": "Generic SDK for use in public websites.",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "jest",
|
|
9
|
+
"prebuild": "rimraf ./lib",
|
|
10
|
+
"build": "tsc --project tsconfig.build.json",
|
|
11
|
+
"prepublishOnly": "cross-env NODE_ENV=production npm run build"
|
|
12
|
+
},
|
|
13
|
+
"bin": {
|
|
14
|
+
"cntrl-sdk": "lib/cli.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"lib",
|
|
18
|
+
"resources"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/cntrl-site/sdk.git"
|
|
23
|
+
},
|
|
24
|
+
"author": "arsen@momdesign.nyc",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/cntrl-site/sdk/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/cntrl-site/sdk#readme",
|
|
30
|
+
"directories": {
|
|
31
|
+
"lib": "lib"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@splidejs/react-splide": "^0.7.12",
|
|
35
|
+
"@types/ejs": "^3.1.2",
|
|
36
|
+
"@types/isomorphic-fetch": "^0.0.36",
|
|
37
|
+
"@types/ua-parser-js": "^0.7.39",
|
|
38
|
+
"commander": "^10.0.1",
|
|
39
|
+
"dotenv": "^16.1.3",
|
|
40
|
+
"ejs": "^3.1.9",
|
|
41
|
+
"isomorphic-fetch": "^3.0.0",
|
|
42
|
+
"mp4box": "^0.5.2",
|
|
43
|
+
"styled-jsx": "^5.1.6",
|
|
44
|
+
"ts-node": "^10.9.1",
|
|
45
|
+
"ua-parser-js": "^1.0.37",
|
|
46
|
+
"url": "^0.11.0",
|
|
47
|
+
"zod": "^3.22.4"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@tsconfig/node16": "^1.0.3",
|
|
51
|
+
"@tsconfig/recommended": "^1.0.1",
|
|
52
|
+
"@types/jest": "^29.0.0",
|
|
53
|
+
"@types/node": "^18.11.7",
|
|
54
|
+
"@types/react": "^18.2.0",
|
|
55
|
+
"@types/react-dom": "^18.2.0",
|
|
56
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
57
|
+
"cross-env": "^10.1.0",
|
|
58
|
+
"jest": "^28.1.3",
|
|
59
|
+
"ts-jest": "^28.0.8",
|
|
60
|
+
"typescript": "^5.2.2"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
// CAUTION: THIS FILE IS AUTO-GENERATED BASED ON
|
|
2
|
-
// LAYOUT CONFIGURATION IN YOUR CNTRL PROJECT
|
|
3
|
-
// WE HIGHLY ADVICE YOU TO NOT CHANGE IT MANUALLY
|
|
4
|
-
@use "sass:map";
|
|
5
|
-
|
|
6
|
-
$__CNTRL_LAYOUT_WIDTH__: <%= ranges[0].exemplary %>;
|
|
7
|
-
|
|
8
|
-
$layout: (
|
|
9
|
-
<% ranges.forEach(function(range) { %>
|
|
10
|
-
<%= range.name %>: (
|
|
11
|
-
start: <%= range.start %>,
|
|
12
|
-
end: <%= range.end %>,
|
|
13
|
-
exemplary: <%= range.exemplary %>,
|
|
14
|
-
isFirst: <%= range.isFirst %>,
|
|
15
|
-
isLast: <%= range.isLast %>
|
|
16
|
-
),
|
|
17
|
-
<% }); %>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
@function size($value) {
|
|
21
|
-
@return #{$value/$__CNTRL_LAYOUT_WIDTH__*100}vw;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@mixin for($name) {
|
|
25
|
-
$start: map.get(map.get($layout, $name), "start");
|
|
26
|
-
$end: map.get(map.get($layout, $name), "end");
|
|
27
|
-
$isFirst: map.get(map.get($layout, $name), "isFirst");
|
|
28
|
-
$isLast: map.get(map.get($layout, $name), "isLast");
|
|
29
|
-
$exemplary: map.get(map.get($layout, $name), "exemplary");
|
|
30
|
-
$__CNTRL_LAYOUT_WIDTH__: $exemplary !global;
|
|
31
|
-
|
|
32
|
-
@if $isFirst == true and $isLast == true {
|
|
33
|
-
@content;
|
|
34
|
-
} @else if $isFirst == true {
|
|
35
|
-
@media (max-width: #{$end}px) {
|
|
36
|
-
@content;
|
|
37
|
-
}
|
|
38
|
-
} @else if $isLast == true {
|
|
39
|
-
@media (min-width: #{$start}px) {
|
|
40
|
-
@content;
|
|
41
|
-
}
|
|
42
|
-
} @else {
|
|
43
|
-
@media (min-width: #{$start}px) and (max-width: #{$end}px) {
|
|
44
|
-
@content;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// reset global variable back to first layout's exemplary (mobile-first)
|
|
49
|
-
$__CNTRL_LAYOUT_WIDTH__: <%= ranges[0].exemplary %> !global;
|
|
50
|
-
}
|
|
1
|
+
// CAUTION: THIS FILE IS AUTO-GENERATED BASED ON
|
|
2
|
+
// LAYOUT CONFIGURATION IN YOUR CNTRL PROJECT
|
|
3
|
+
// WE HIGHLY ADVICE YOU TO NOT CHANGE IT MANUALLY
|
|
4
|
+
@use "sass:map";
|
|
5
|
+
|
|
6
|
+
$__CNTRL_LAYOUT_WIDTH__: <%= ranges[0].exemplary %>;
|
|
7
|
+
|
|
8
|
+
$layout: (
|
|
9
|
+
<% ranges.forEach(function(range) { %>
|
|
10
|
+
<%= range.name %>: (
|
|
11
|
+
start: <%= range.start %>,
|
|
12
|
+
end: <%= range.end %>,
|
|
13
|
+
exemplary: <%= range.exemplary %>,
|
|
14
|
+
isFirst: <%= range.isFirst %>,
|
|
15
|
+
isLast: <%= range.isLast %>
|
|
16
|
+
),
|
|
17
|
+
<% }); %>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
@function size($value) {
|
|
21
|
+
@return #{$value/$__CNTRL_LAYOUT_WIDTH__*100}vw;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@mixin for($name) {
|
|
25
|
+
$start: map.get(map.get($layout, $name), "start");
|
|
26
|
+
$end: map.get(map.get($layout, $name), "end");
|
|
27
|
+
$isFirst: map.get(map.get($layout, $name), "isFirst");
|
|
28
|
+
$isLast: map.get(map.get($layout, $name), "isLast");
|
|
29
|
+
$exemplary: map.get(map.get($layout, $name), "exemplary");
|
|
30
|
+
$__CNTRL_LAYOUT_WIDTH__: $exemplary !global;
|
|
31
|
+
|
|
32
|
+
@if $isFirst == true and $isLast == true {
|
|
33
|
+
@content;
|
|
34
|
+
} @else if $isFirst == true {
|
|
35
|
+
@media (max-width: #{$end}px) {
|
|
36
|
+
@content;
|
|
37
|
+
}
|
|
38
|
+
} @else if $isLast == true {
|
|
39
|
+
@media (min-width: #{$start}px) {
|
|
40
|
+
@content;
|
|
41
|
+
}
|
|
42
|
+
} @else {
|
|
43
|
+
@media (min-width: #{$start}px) and (max-width: #{$end}px) {
|
|
44
|
+
@content;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// reset global variable back to first layout's exemplary (mobile-first)
|
|
49
|
+
$__CNTRL_LAYOUT_WIDTH__: <%= ranges[0].exemplary %> !global;
|
|
50
|
+
}
|