@carbon/layout 11.51.0 → 11.52.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/es/index.js +24 -43
- package/lib/index.d.ts +68 -0
- package/lib/index.js +25 -45
- package/lib/tokens.d.ts +7 -0
- package/package.json +9 -5
- package/src/{index.js → index.ts} +31 -34
- package/src/{tokens.js → tokens.ts} +2 -2
- package/tsconfig.json +8 -0
- package/tsconfig.types.json +9 -0
- package/umd/index.js +84 -106
package/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//#region src/tokens.
|
|
1
|
+
//#region src/tokens.ts
|
|
2
2
|
/**
|
|
3
|
-
* Copyright IBM Corp. 2018,
|
|
3
|
+
* Copyright IBM Corp. 2018, 2026
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -44,40 +44,24 @@ const unstable_tokens = [
|
|
|
44
44
|
"layout06",
|
|
45
45
|
"layout07"
|
|
46
46
|
];
|
|
47
|
-
|
|
48
47
|
//#endregion
|
|
49
|
-
//#region src/index.
|
|
48
|
+
//#region src/index.ts
|
|
50
49
|
/**
|
|
51
|
-
* Copyright IBM Corp. 2018,
|
|
50
|
+
* Copyright IBM Corp. 2018, 2026
|
|
52
51
|
*
|
|
53
52
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
54
53
|
* LICENSE file in the root directory of this source tree.
|
|
55
54
|
*/
|
|
56
55
|
const baseFontSize = 16;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Convert a given px unit to a em unit
|
|
67
|
-
* @param {number} px
|
|
68
|
-
* @returns {string}
|
|
69
|
-
*/
|
|
70
|
-
function em(px) {
|
|
71
|
-
return `${px / baseFontSize}em`;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Convert a given px unit to its string representation
|
|
75
|
-
* @param {number} value - number of pixels
|
|
76
|
-
* @returns {string}
|
|
77
|
-
*/
|
|
78
|
-
function px(value) {
|
|
56
|
+
const rem = (px) => {
|
|
57
|
+
return `${px / 16}rem`;
|
|
58
|
+
};
|
|
59
|
+
const em = (px) => {
|
|
60
|
+
return `${px / 16}em`;
|
|
61
|
+
};
|
|
62
|
+
const px = (value) => {
|
|
79
63
|
return `${value}px`;
|
|
80
|
-
}
|
|
64
|
+
};
|
|
81
65
|
const breakpoints = {
|
|
82
66
|
sm: {
|
|
83
67
|
width: rem(320),
|
|
@@ -105,19 +89,17 @@ const breakpoints = {
|
|
|
105
89
|
margin: rem(24)
|
|
106
90
|
}
|
|
107
91
|
};
|
|
108
|
-
|
|
92
|
+
const breakpointUp = (name) => {
|
|
109
93
|
return `@media (min-width: ${breakpoints[name].width})`;
|
|
110
|
-
}
|
|
111
|
-
|
|
94
|
+
};
|
|
95
|
+
const breakpointDown = (name) => {
|
|
112
96
|
return `@media (max-width: ${breakpoints[name].width})`;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return breakpointUp(...args);
|
|
116
|
-
}
|
|
97
|
+
};
|
|
98
|
+
const breakpoint = breakpointUp;
|
|
117
99
|
const miniUnit = 8;
|
|
118
|
-
|
|
119
|
-
return rem(
|
|
120
|
-
}
|
|
100
|
+
const miniUnits = (count) => {
|
|
101
|
+
return rem(8 * count);
|
|
102
|
+
};
|
|
121
103
|
const spacing01 = miniUnits(.25);
|
|
122
104
|
const spacing02 = miniUnits(.5);
|
|
123
105
|
const spacing03 = miniUnits(1);
|
|
@@ -151,9 +133,9 @@ const fluidSpacing02 = "2vw";
|
|
|
151
133
|
const fluidSpacing03 = "5vw";
|
|
152
134
|
const fluidSpacing04 = "10vw";
|
|
153
135
|
const fluidSpacing = [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
136
|
+
0,
|
|
137
|
+
"2vw",
|
|
138
|
+
"5vw",
|
|
157
139
|
fluidSpacing04
|
|
158
140
|
];
|
|
159
141
|
const layout01 = miniUnits(2);
|
|
@@ -201,6 +183,5 @@ const sizes = {
|
|
|
201
183
|
const iconSize01 = "1rem";
|
|
202
184
|
const iconSize02 = "1.25rem";
|
|
203
185
|
const iconSize = [iconSize01, iconSize02];
|
|
204
|
-
|
|
205
186
|
//#endregion
|
|
206
|
-
export { baseFontSize, breakpoint, breakpointDown, breakpointUp, breakpoints, container, container01, container02, container03, container04, container05, em, fluidSpacing, fluidSpacing01, fluidSpacing02, fluidSpacing03, fluidSpacing04, iconSize, iconSize01, iconSize02, layout, layout01, layout02, layout03, layout04, layout05, layout06, layout07, miniUnit, miniUnits, px, rem, size2XLarge, sizeLarge, sizeMedium, sizeSmall, sizeXLarge, sizeXSmall, sizes, spacing, spacing01, spacing02, spacing03, spacing04, spacing05, spacing06, spacing07, spacing08, spacing09, spacing10, spacing11, spacing12, spacing13, unstable_tokens };
|
|
187
|
+
export { baseFontSize, breakpoint, breakpointDown, breakpointUp, breakpoints, container, container01, container02, container03, container04, container05, em, fluidSpacing, fluidSpacing01, fluidSpacing02, fluidSpacing03, fluidSpacing04, iconSize, iconSize01, iconSize02, layout, layout01, layout02, layout03, layout04, layout05, layout06, layout07, miniUnit, miniUnits, px, rem, size2XLarge, sizeLarge, sizeMedium, sizeSmall, sizeXLarge, sizeXSmall, sizes, spacing, spacing01, spacing02, spacing03, spacing04, spacing05, spacing06, spacing07, spacing08, spacing09, spacing10, spacing11, spacing12, spacing13, unstable_tokens };
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2018, 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { unstable_tokens } from './tokens';
|
|
8
|
+
export { unstable_tokens };
|
|
9
|
+
export type BreakpointName = 'sm' | 'md' | 'lg' | 'xlg' | 'max';
|
|
10
|
+
export type Breakpoint = {
|
|
11
|
+
width: string;
|
|
12
|
+
columns: number;
|
|
13
|
+
margin: string;
|
|
14
|
+
};
|
|
15
|
+
export type SizeName = 'XSmall' | 'Small' | 'Medium' | 'Large' | 'XLarge' | '2XLarge';
|
|
16
|
+
export declare const baseFontSize = 16;
|
|
17
|
+
export declare const rem: (px: number) => string;
|
|
18
|
+
export declare const em: (px: number) => string;
|
|
19
|
+
export declare const px: (value: number) => string;
|
|
20
|
+
export declare const breakpoints: Record<BreakpointName, Breakpoint>;
|
|
21
|
+
export declare const breakpointUp: (name: BreakpointName) => string;
|
|
22
|
+
export declare const breakpointDown: (name: BreakpointName) => string;
|
|
23
|
+
export declare const breakpoint: (name: BreakpointName) => string;
|
|
24
|
+
export declare const miniUnit = 8;
|
|
25
|
+
export declare const miniUnits: (count: number) => string;
|
|
26
|
+
export declare const spacing01: string;
|
|
27
|
+
export declare const spacing02: string;
|
|
28
|
+
export declare const spacing03: string;
|
|
29
|
+
export declare const spacing04: string;
|
|
30
|
+
export declare const spacing05: string;
|
|
31
|
+
export declare const spacing06: string;
|
|
32
|
+
export declare const spacing07: string;
|
|
33
|
+
export declare const spacing08: string;
|
|
34
|
+
export declare const spacing09: string;
|
|
35
|
+
export declare const spacing10: string;
|
|
36
|
+
export declare const spacing11: string;
|
|
37
|
+
export declare const spacing12: string;
|
|
38
|
+
export declare const spacing13: string;
|
|
39
|
+
export declare const spacing: string[];
|
|
40
|
+
export declare const fluidSpacing01 = 0;
|
|
41
|
+
export declare const fluidSpacing02 = "2vw";
|
|
42
|
+
export declare const fluidSpacing03 = "5vw";
|
|
43
|
+
export declare const fluidSpacing04 = "10vw";
|
|
44
|
+
export declare const fluidSpacing: (string | number)[];
|
|
45
|
+
export declare const layout01: string;
|
|
46
|
+
export declare const layout02: string;
|
|
47
|
+
export declare const layout03: string;
|
|
48
|
+
export declare const layout04: string;
|
|
49
|
+
export declare const layout05: string;
|
|
50
|
+
export declare const layout06: string;
|
|
51
|
+
export declare const layout07: string;
|
|
52
|
+
export declare const layout: string[];
|
|
53
|
+
export declare const container01: string;
|
|
54
|
+
export declare const container02: string;
|
|
55
|
+
export declare const container03: string;
|
|
56
|
+
export declare const container04: string;
|
|
57
|
+
export declare const container05: string;
|
|
58
|
+
export declare const container: string[];
|
|
59
|
+
export declare const sizeXSmall: string;
|
|
60
|
+
export declare const sizeSmall: string;
|
|
61
|
+
export declare const sizeMedium: string;
|
|
62
|
+
export declare const sizeLarge: string;
|
|
63
|
+
export declare const sizeXLarge: string;
|
|
64
|
+
export declare const size2XLarge: string;
|
|
65
|
+
export declare const sizes: Record<SizeName, string>;
|
|
66
|
+
export declare const iconSize01 = "1rem";
|
|
67
|
+
export declare const iconSize02 = "1.25rem";
|
|
68
|
+
export declare const iconSize: string[];
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
|
|
3
|
-
//#region src/tokens.js
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/tokens.ts
|
|
4
3
|
/**
|
|
5
|
-
* Copyright IBM Corp. 2018,
|
|
4
|
+
* Copyright IBM Corp. 2018, 2026
|
|
6
5
|
*
|
|
7
6
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
8
7
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -46,40 +45,24 @@ const unstable_tokens = [
|
|
|
46
45
|
"layout06",
|
|
47
46
|
"layout07"
|
|
48
47
|
];
|
|
49
|
-
|
|
50
48
|
//#endregion
|
|
51
|
-
//#region src/index.
|
|
49
|
+
//#region src/index.ts
|
|
52
50
|
/**
|
|
53
|
-
* Copyright IBM Corp. 2018,
|
|
51
|
+
* Copyright IBM Corp. 2018, 2026
|
|
54
52
|
*
|
|
55
53
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
56
54
|
* LICENSE file in the root directory of this source tree.
|
|
57
55
|
*/
|
|
58
56
|
const baseFontSize = 16;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Convert a given px unit to a em unit
|
|
69
|
-
* @param {number} px
|
|
70
|
-
* @returns {string}
|
|
71
|
-
*/
|
|
72
|
-
function em(px) {
|
|
73
|
-
return `${px / baseFontSize}em`;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Convert a given px unit to its string representation
|
|
77
|
-
* @param {number} value - number of pixels
|
|
78
|
-
* @returns {string}
|
|
79
|
-
*/
|
|
80
|
-
function px(value) {
|
|
57
|
+
const rem = (px) => {
|
|
58
|
+
return `${px / 16}rem`;
|
|
59
|
+
};
|
|
60
|
+
const em = (px) => {
|
|
61
|
+
return `${px / 16}em`;
|
|
62
|
+
};
|
|
63
|
+
const px = (value) => {
|
|
81
64
|
return `${value}px`;
|
|
82
|
-
}
|
|
65
|
+
};
|
|
83
66
|
const breakpoints = {
|
|
84
67
|
sm: {
|
|
85
68
|
width: rem(320),
|
|
@@ -107,19 +90,17 @@ const breakpoints = {
|
|
|
107
90
|
margin: rem(24)
|
|
108
91
|
}
|
|
109
92
|
};
|
|
110
|
-
|
|
93
|
+
const breakpointUp = (name) => {
|
|
111
94
|
return `@media (min-width: ${breakpoints[name].width})`;
|
|
112
|
-
}
|
|
113
|
-
|
|
95
|
+
};
|
|
96
|
+
const breakpointDown = (name) => {
|
|
114
97
|
return `@media (max-width: ${breakpoints[name].width})`;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return breakpointUp(...args);
|
|
118
|
-
}
|
|
98
|
+
};
|
|
99
|
+
const breakpoint = breakpointUp;
|
|
119
100
|
const miniUnit = 8;
|
|
120
|
-
|
|
121
|
-
return rem(
|
|
122
|
-
}
|
|
101
|
+
const miniUnits = (count) => {
|
|
102
|
+
return rem(8 * count);
|
|
103
|
+
};
|
|
123
104
|
const spacing01 = miniUnits(.25);
|
|
124
105
|
const spacing02 = miniUnits(.5);
|
|
125
106
|
const spacing03 = miniUnits(1);
|
|
@@ -153,9 +134,9 @@ const fluidSpacing02 = "2vw";
|
|
|
153
134
|
const fluidSpacing03 = "5vw";
|
|
154
135
|
const fluidSpacing04 = "10vw";
|
|
155
136
|
const fluidSpacing = [
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
137
|
+
0,
|
|
138
|
+
"2vw",
|
|
139
|
+
"5vw",
|
|
159
140
|
fluidSpacing04
|
|
160
141
|
];
|
|
161
142
|
const layout01 = miniUnits(2);
|
|
@@ -203,7 +184,6 @@ const sizes = {
|
|
|
203
184
|
const iconSize01 = "1rem";
|
|
204
185
|
const iconSize02 = "1.25rem";
|
|
205
186
|
const iconSize = [iconSize01, iconSize02];
|
|
206
|
-
|
|
207
187
|
//#endregion
|
|
208
188
|
exports.baseFontSize = baseFontSize;
|
|
209
189
|
exports.breakpoint = breakpoint;
|
|
@@ -258,4 +238,4 @@ exports.spacing10 = spacing10;
|
|
|
258
238
|
exports.spacing11 = spacing11;
|
|
259
239
|
exports.spacing12 = spacing12;
|
|
260
240
|
exports.spacing13 = spacing13;
|
|
261
|
-
exports.unstable_tokens = unstable_tokens;
|
|
241
|
+
exports.unstable_tokens = unstable_tokens;
|
package/lib/tokens.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2018, 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
export declare const unstable_tokens: readonly ["spacing01", "spacing02", "spacing03", "spacing04", "spacing05", "spacing06", "spacing07", "spacing08", "spacing09", "spacing10", "spacing11", "spacing12", "spacing13", "fluidSpacing01", "fluidSpacing02", "fluidSpacing03", "fluidSpacing04", "container01", "container02", "container03", "container04", "container05", "sizeXSmall", "sizeSmall", "sizeMedium", "sizeLarge", "sizeXLarge", "size2XLarge", "iconSize01", "iconSize02", "layout01", "layout02", "layout03", "layout04", "layout05", "layout06", "layout07"];
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/layout",
|
|
3
3
|
"description": "Layout helpers for digital and software products using the Carbon Design System",
|
|
4
|
-
"version": "11.
|
|
4
|
+
"version": "11.52.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
7
8
|
"module": "es/index.js",
|
|
8
9
|
"sass": "index.scss",
|
|
9
10
|
"repository": {
|
|
@@ -26,20 +27,23 @@
|
|
|
26
27
|
"provenance": true
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|
|
29
|
-
"build": "
|
|
30
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
31
|
+
"build": "yarn clean && carbon-cli bundle src/index.ts --name CarbonLayout && node tasks/build.js && yarn build:types",
|
|
30
32
|
"clean": "rimraf es lib umd scss/generated",
|
|
31
33
|
"postinstall": "ibmtelemetry --config=telemetry.yml"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
|
-
"@carbon/cli": "^11.
|
|
36
|
+
"@carbon/cli": "^11.43.0",
|
|
35
37
|
"@carbon/cli-reporter": "^10.8.0",
|
|
36
38
|
"@carbon/scss-generator": "^10.20.0",
|
|
37
39
|
"@carbon/test-utils": "^10.41.0",
|
|
38
40
|
"core-js": "^3.16.0",
|
|
39
|
-
"rimraf": "^6.0.1"
|
|
41
|
+
"rimraf": "^6.0.1",
|
|
42
|
+
"typescript": "^5.7.3",
|
|
43
|
+
"typescript-config-carbon": "^0.9.0"
|
|
40
44
|
},
|
|
41
45
|
"dependencies": {
|
|
42
46
|
"@ibm/telemetry-js": "^1.5.0"
|
|
43
47
|
},
|
|
44
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "5e89339998bd16c8ddd42e1cc6a2d0c15b3b0af5"
|
|
45
49
|
}
|
|
@@ -1,48 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2018,
|
|
2
|
+
* Copyright IBM Corp. 2018, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { unstable_tokens } from './tokens
|
|
8
|
+
import { unstable_tokens } from './tokens';
|
|
9
9
|
|
|
10
10
|
export { unstable_tokens };
|
|
11
11
|
|
|
12
|
+
export type BreakpointName = 'sm' | 'md' | 'lg' | 'xlg' | 'max';
|
|
13
|
+
export type Breakpoint = {
|
|
14
|
+
width: string;
|
|
15
|
+
columns: number;
|
|
16
|
+
margin: string;
|
|
17
|
+
};
|
|
18
|
+
export type SizeName =
|
|
19
|
+
| 'XSmall'
|
|
20
|
+
| 'Small'
|
|
21
|
+
| 'Medium'
|
|
22
|
+
| 'Large'
|
|
23
|
+
| 'XLarge'
|
|
24
|
+
| '2XLarge';
|
|
25
|
+
|
|
12
26
|
// Convert
|
|
13
27
|
// Default, Use with em() and rem() functions
|
|
14
28
|
export const baseFontSize = 16;
|
|
15
29
|
|
|
16
|
-
|
|
17
|
-
* Convert a given px unit to a rem unit
|
|
18
|
-
* @param {number} px
|
|
19
|
-
* @returns {string}
|
|
20
|
-
*/
|
|
21
|
-
export function rem(px) {
|
|
30
|
+
export const rem = (px: number) => {
|
|
22
31
|
return `${px / baseFontSize}rem`;
|
|
23
|
-
}
|
|
32
|
+
};
|
|
24
33
|
|
|
25
|
-
|
|
26
|
-
* Convert a given px unit to a em unit
|
|
27
|
-
* @param {number} px
|
|
28
|
-
* @returns {string}
|
|
29
|
-
*/
|
|
30
|
-
export function em(px) {
|
|
34
|
+
export const em = (px: number) => {
|
|
31
35
|
return `${px / baseFontSize}em`;
|
|
32
|
-
}
|
|
36
|
+
};
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
* Convert a given px unit to its string representation
|
|
36
|
-
* @param {number} value - number of pixels
|
|
37
|
-
* @returns {string}
|
|
38
|
-
*/
|
|
39
|
-
export function px(value) {
|
|
38
|
+
export const px = (value: number) => {
|
|
40
39
|
return `${value}px`;
|
|
41
|
-
}
|
|
40
|
+
};
|
|
42
41
|
|
|
43
42
|
// Breakpoint
|
|
44
43
|
// Initial map of our breakpoints and their values
|
|
45
|
-
export const breakpoints = {
|
|
44
|
+
export const breakpoints: Record<BreakpointName, Breakpoint> = {
|
|
46
45
|
sm: {
|
|
47
46
|
width: rem(320),
|
|
48
47
|
columns: 4,
|
|
@@ -70,24 +69,22 @@ export const breakpoints = {
|
|
|
70
69
|
},
|
|
71
70
|
};
|
|
72
71
|
|
|
73
|
-
export
|
|
72
|
+
export const breakpointUp = (name: BreakpointName) => {
|
|
74
73
|
return `@media (min-width: ${breakpoints[name].width})`;
|
|
75
|
-
}
|
|
74
|
+
};
|
|
76
75
|
|
|
77
|
-
export
|
|
76
|
+
export const breakpointDown = (name: BreakpointName) => {
|
|
78
77
|
return `@media (max-width: ${breakpoints[name].width})`;
|
|
79
|
-
}
|
|
78
|
+
};
|
|
80
79
|
|
|
81
|
-
export
|
|
82
|
-
return breakpointUp(...args);
|
|
83
|
-
}
|
|
80
|
+
export const breakpoint = breakpointUp;
|
|
84
81
|
|
|
85
82
|
// Mini-unit
|
|
86
83
|
export const miniUnit = 8;
|
|
87
84
|
|
|
88
|
-
export
|
|
85
|
+
export const miniUnits = (count: number) => {
|
|
89
86
|
return rem(miniUnit * count);
|
|
90
|
-
}
|
|
87
|
+
};
|
|
91
88
|
|
|
92
89
|
// Spacing
|
|
93
90
|
export const spacing01 = miniUnits(0.25);
|
|
@@ -169,7 +166,7 @@ export const sizeMedium = rem(40);
|
|
|
169
166
|
export const sizeLarge = rem(48);
|
|
170
167
|
export const sizeXLarge = rem(64);
|
|
171
168
|
export const size2XLarge = rem(80);
|
|
172
|
-
export const sizes = {
|
|
169
|
+
export const sizes: Record<SizeName, string> = {
|
|
173
170
|
XSmall: sizeXSmall,
|
|
174
171
|
Small: sizeSmall,
|
|
175
172
|
Medium: sizeMedium,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2018,
|
|
2
|
+
* Copyright IBM Corp. 2018, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -53,4 +53,4 @@ export const unstable_tokens = [
|
|
|
53
53
|
'layout05',
|
|
54
54
|
'layout06',
|
|
55
55
|
'layout07',
|
|
56
|
-
];
|
|
56
|
+
] as const;
|
package/tsconfig.json
ADDED
package/umd/index.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CarbonLayout = {})));
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.CarbonLayout = {}));
|
|
5
3
|
})(this, function(exports) {
|
|
6
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Copyright IBM Corp. 2018, 2023
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
5
|
+
//#region src/tokens.ts
|
|
6
|
+
/**
|
|
7
|
+
* Copyright IBM Corp. 2018, 2026
|
|
11
8
|
*
|
|
12
9
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
13
10
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -51,40 +48,24 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
51
48
|
"layout06",
|
|
52
49
|
"layout07"
|
|
53
50
|
];
|
|
54
|
-
|
|
55
|
-
//#
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* Copyright IBM Corp. 2018, 2023
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/index.ts
|
|
53
|
+
/**
|
|
54
|
+
* Copyright IBM Corp. 2018, 2026
|
|
59
55
|
*
|
|
60
56
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
61
57
|
* LICENSE file in the root directory of this source tree.
|
|
62
58
|
*/
|
|
63
59
|
const baseFontSize = 16;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Convert a given px unit to a em unit
|
|
74
|
-
* @param {number} px
|
|
75
|
-
* @returns {string}
|
|
76
|
-
*/
|
|
77
|
-
function em(px) {
|
|
78
|
-
return `${px / baseFontSize}em`;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Convert a given px unit to its string representation
|
|
82
|
-
* @param {number} value - number of pixels
|
|
83
|
-
* @returns {string}
|
|
84
|
-
*/
|
|
85
|
-
function px(value) {
|
|
60
|
+
const rem = (px) => {
|
|
61
|
+
return `${px / 16}rem`;
|
|
62
|
+
};
|
|
63
|
+
const em = (px) => {
|
|
64
|
+
return `${px / 16}em`;
|
|
65
|
+
};
|
|
66
|
+
const px = (value) => {
|
|
86
67
|
return `${value}px`;
|
|
87
|
-
}
|
|
68
|
+
};
|
|
88
69
|
const breakpoints = {
|
|
89
70
|
sm: {
|
|
90
71
|
width: rem(320),
|
|
@@ -112,19 +93,17 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
112
93
|
margin: rem(24)
|
|
113
94
|
}
|
|
114
95
|
};
|
|
115
|
-
|
|
96
|
+
const breakpointUp = (name) => {
|
|
116
97
|
return `@media (min-width: ${breakpoints[name].width})`;
|
|
117
|
-
}
|
|
118
|
-
|
|
98
|
+
};
|
|
99
|
+
const breakpointDown = (name) => {
|
|
119
100
|
return `@media (max-width: ${breakpoints[name].width})`;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return breakpointUp(...args);
|
|
123
|
-
}
|
|
101
|
+
};
|
|
102
|
+
const breakpoint = breakpointUp;
|
|
124
103
|
const miniUnit = 8;
|
|
125
|
-
|
|
126
|
-
return rem(
|
|
127
|
-
}
|
|
104
|
+
const miniUnits = (count) => {
|
|
105
|
+
return rem(8 * count);
|
|
106
|
+
};
|
|
128
107
|
const spacing01 = miniUnits(.25);
|
|
129
108
|
const spacing02 = miniUnits(.5);
|
|
130
109
|
const spacing03 = miniUnits(1);
|
|
@@ -158,9 +137,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
158
137
|
const fluidSpacing03 = "5vw";
|
|
159
138
|
const fluidSpacing04 = "10vw";
|
|
160
139
|
const fluidSpacing = [
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
140
|
+
0,
|
|
141
|
+
"2vw",
|
|
142
|
+
"5vw",
|
|
164
143
|
fluidSpacing04
|
|
165
144
|
];
|
|
166
145
|
const layout01 = miniUnits(2);
|
|
@@ -208,60 +187,59 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
208
187
|
const iconSize01 = "1rem";
|
|
209
188
|
const iconSize02 = "1.25rem";
|
|
210
189
|
const iconSize = [iconSize01, iconSize02];
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
exports.
|
|
214
|
-
exports.
|
|
215
|
-
exports.
|
|
216
|
-
exports.
|
|
217
|
-
exports.
|
|
218
|
-
exports.
|
|
219
|
-
exports.
|
|
220
|
-
exports.
|
|
221
|
-
exports.
|
|
222
|
-
exports.
|
|
223
|
-
exports.
|
|
224
|
-
exports.
|
|
225
|
-
exports.
|
|
226
|
-
exports.
|
|
227
|
-
exports.
|
|
228
|
-
exports.
|
|
229
|
-
exports.
|
|
230
|
-
exports.
|
|
231
|
-
exports.
|
|
232
|
-
exports.
|
|
233
|
-
exports.
|
|
234
|
-
exports.
|
|
235
|
-
exports.
|
|
236
|
-
exports.
|
|
237
|
-
exports.
|
|
238
|
-
exports.
|
|
239
|
-
exports.
|
|
240
|
-
exports.
|
|
241
|
-
exports.
|
|
242
|
-
exports.
|
|
243
|
-
exports.
|
|
244
|
-
exports.
|
|
245
|
-
exports.
|
|
246
|
-
exports.
|
|
247
|
-
exports.
|
|
248
|
-
exports.
|
|
249
|
-
exports.
|
|
250
|
-
exports.
|
|
251
|
-
exports.
|
|
252
|
-
exports.
|
|
253
|
-
exports.
|
|
254
|
-
exports.
|
|
255
|
-
exports.
|
|
256
|
-
exports.
|
|
257
|
-
exports.
|
|
258
|
-
exports.
|
|
259
|
-
exports.
|
|
260
|
-
exports.
|
|
261
|
-
exports.
|
|
262
|
-
exports.
|
|
263
|
-
exports.
|
|
264
|
-
exports.
|
|
265
|
-
exports.
|
|
266
|
-
|
|
267
|
-
});
|
|
190
|
+
//#endregion
|
|
191
|
+
exports.baseFontSize = baseFontSize;
|
|
192
|
+
exports.breakpoint = breakpoint;
|
|
193
|
+
exports.breakpointDown = breakpointDown;
|
|
194
|
+
exports.breakpointUp = breakpointUp;
|
|
195
|
+
exports.breakpoints = breakpoints;
|
|
196
|
+
exports.container = container;
|
|
197
|
+
exports.container01 = container01;
|
|
198
|
+
exports.container02 = container02;
|
|
199
|
+
exports.container03 = container03;
|
|
200
|
+
exports.container04 = container04;
|
|
201
|
+
exports.container05 = container05;
|
|
202
|
+
exports.em = em;
|
|
203
|
+
exports.fluidSpacing = fluidSpacing;
|
|
204
|
+
exports.fluidSpacing01 = fluidSpacing01;
|
|
205
|
+
exports.fluidSpacing02 = fluidSpacing02;
|
|
206
|
+
exports.fluidSpacing03 = fluidSpacing03;
|
|
207
|
+
exports.fluidSpacing04 = fluidSpacing04;
|
|
208
|
+
exports.iconSize = iconSize;
|
|
209
|
+
exports.iconSize01 = iconSize01;
|
|
210
|
+
exports.iconSize02 = iconSize02;
|
|
211
|
+
exports.layout = layout;
|
|
212
|
+
exports.layout01 = layout01;
|
|
213
|
+
exports.layout02 = layout02;
|
|
214
|
+
exports.layout03 = layout03;
|
|
215
|
+
exports.layout04 = layout04;
|
|
216
|
+
exports.layout05 = layout05;
|
|
217
|
+
exports.layout06 = layout06;
|
|
218
|
+
exports.layout07 = layout07;
|
|
219
|
+
exports.miniUnit = miniUnit;
|
|
220
|
+
exports.miniUnits = miniUnits;
|
|
221
|
+
exports.px = px;
|
|
222
|
+
exports.rem = rem;
|
|
223
|
+
exports.size2XLarge = size2XLarge;
|
|
224
|
+
exports.sizeLarge = sizeLarge;
|
|
225
|
+
exports.sizeMedium = sizeMedium;
|
|
226
|
+
exports.sizeSmall = sizeSmall;
|
|
227
|
+
exports.sizeXLarge = sizeXLarge;
|
|
228
|
+
exports.sizeXSmall = sizeXSmall;
|
|
229
|
+
exports.sizes = sizes;
|
|
230
|
+
exports.spacing = spacing;
|
|
231
|
+
exports.spacing01 = spacing01;
|
|
232
|
+
exports.spacing02 = spacing02;
|
|
233
|
+
exports.spacing03 = spacing03;
|
|
234
|
+
exports.spacing04 = spacing04;
|
|
235
|
+
exports.spacing05 = spacing05;
|
|
236
|
+
exports.spacing06 = spacing06;
|
|
237
|
+
exports.spacing07 = spacing07;
|
|
238
|
+
exports.spacing08 = spacing08;
|
|
239
|
+
exports.spacing09 = spacing09;
|
|
240
|
+
exports.spacing10 = spacing10;
|
|
241
|
+
exports.spacing11 = spacing11;
|
|
242
|
+
exports.spacing12 = spacing12;
|
|
243
|
+
exports.spacing13 = spacing13;
|
|
244
|
+
exports.unstable_tokens = unstable_tokens;
|
|
245
|
+
});
|