@pyreon/unistyle 0.11.4 → 0.11.6
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/README.md +39 -34
- package/lib/index.d.ts +13 -8
- package/lib/index.js +9 -4
- package/package.json +24 -24
- package/src/__tests__/alignContent.test.ts +57 -57
- package/src/__tests__/borderRadius.test.ts +40 -40
- package/src/__tests__/camelToKebab.test.ts +23 -23
- package/src/__tests__/context.test.ts +28 -28
- package/src/__tests__/createMediaQueries.test.ts +21 -21
- package/src/__tests__/edge.test.ts +76 -76
- package/src/__tests__/enrichTheme.test.ts +13 -13
- package/src/__tests__/index.test.ts +31 -31
- package/src/__tests__/makeItResponsive.test.ts +32 -32
- package/src/__tests__/processDescriptor.test.ts +107 -107
- package/src/__tests__/responsive.test.ts +66 -66
- package/src/__tests__/styles.test.ts +52 -52
- package/src/__tests__/units.test.ts +63 -63
- package/src/context.tsx +11 -6
- package/src/enrichTheme.ts +3 -3
- package/src/index.ts +11 -11
- package/src/responsive/createMediaQueries.ts +4 -4
- package/src/responsive/index.ts +14 -14
- package/src/responsive/makeItResponsive.ts +9 -9
- package/src/responsive/normalizeTheme.ts +2 -2
- package/src/responsive/transformTheme.ts +2 -2
- package/src/styles/alignContent.ts +14 -14
- package/src/styles/extendCss.ts +4 -4
- package/src/styles/index.ts +6 -6
- package/src/styles/shorthands/borderRadius.ts +6 -6
- package/src/styles/shorthands/edge.ts +29 -29
- package/src/styles/shorthands/index.ts +4 -4
- package/src/styles/styles/index.ts +6 -6
- package/src/styles/styles/processDescriptor.ts +31 -31
- package/src/styles/styles/propertyMap.ts +326 -326
- package/src/styles/styles/utils.ts +4 -4
- package/src/types.ts +155 -155
- package/src/units/index.ts +6 -6
- package/src/units/stripUnit.ts +1 -1
- package/src/units/value.ts +20 -20
- package/src/units/values.ts +18 -18
package/README.md
CHANGED
|
@@ -29,7 +29,12 @@ const theme = {
|
|
|
29
29
|
breakpoints: { xs: 0, sm: 576, md: 768, lg: 992, xl: 1200 },
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
Provider({
|
|
32
|
+
Provider({
|
|
33
|
+
theme,
|
|
34
|
+
children: [
|
|
35
|
+
/* your app */
|
|
36
|
+
],
|
|
37
|
+
})
|
|
33
38
|
```
|
|
34
39
|
|
|
35
40
|
## API
|
|
@@ -71,12 +76,12 @@ theme object → normalize (fill gaps) → transform (property → breakpoint pi
|
|
|
71
76
|
|
|
72
77
|
**Parameters:**
|
|
73
78
|
|
|
74
|
-
| Param
|
|
75
|
-
|
|
|
76
|
-
| key
|
|
77
|
-
| css
|
|
78
|
-
| styles
|
|
79
|
-
| normalize | `boolean`
|
|
79
|
+
| Param | Type | Description |
|
|
80
|
+
| --------- | ---------- | -------------------------------------------------------------------- |
|
|
81
|
+
| key | `string` | Theme prop name to read from styled-component props |
|
|
82
|
+
| css | `function` | `css` tagged template function |
|
|
83
|
+
| styles | `function` | Style processor (use the exported `styles`) |
|
|
84
|
+
| normalize | `boolean` | Fill missing breakpoints by inheriting from previous (default: true) |
|
|
80
85
|
|
|
81
86
|
### styles
|
|
82
87
|
|
|
@@ -98,16 +103,16 @@ Supports shorthand properties (`margin`, `padding`, `borderRadius`) with automat
|
|
|
98
103
|
import { value, values, stripUnit } from '@pyreon/unistyle'
|
|
99
104
|
|
|
100
105
|
// value(input, rootSize?, outputUnit?) => string | number | null
|
|
101
|
-
value(16)
|
|
102
|
-
value(24)
|
|
103
|
-
value(0)
|
|
104
|
-
value('2em')
|
|
106
|
+
value(16) // => '1rem' (16 / 16)
|
|
107
|
+
value(24) // => '1.5rem' (24 / 16)
|
|
108
|
+
value(0) // => '0' (always unitless)
|
|
109
|
+
value('2em') // => '2em' (string passthrough)
|
|
105
110
|
value(16, 16, 'px') // => '16px'
|
|
106
111
|
|
|
107
112
|
// stripUnit(input, unitReturn?)
|
|
108
|
-
stripUnit('24px')
|
|
109
|
-
stripUnit('24px', true)
|
|
110
|
-
stripUnit(24)
|
|
113
|
+
stripUnit('24px') // => 24
|
|
114
|
+
stripUnit('24px', true) // => [24, 'px']
|
|
115
|
+
stripUnit(24) // => 24
|
|
111
116
|
|
|
112
117
|
// values(array, rootSize?, outputUnit?) => string
|
|
113
118
|
// Picks first non-null and converts
|
|
@@ -122,14 +127,14 @@ import { alignContent, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y } from '@pyreon/
|
|
|
122
127
|
|
|
123
128
|
Maps alignment keywords to CSS flex values:
|
|
124
129
|
|
|
125
|
-
| Keyword
|
|
126
|
-
|
|
|
127
|
-
| `left` / `top`
|
|
128
|
-
| `center`
|
|
129
|
-
| `right` / `bottom` | `flex-end`
|
|
130
|
-
| `spaceBetween`
|
|
131
|
-
| `spaceAround`
|
|
132
|
-
| `block`
|
|
130
|
+
| Keyword | X-axis CSS | Y-axis CSS |
|
|
131
|
+
| ------------------ | --------------- | --------------- |
|
|
132
|
+
| `left` / `top` | `flex-start` | `flex-start` |
|
|
133
|
+
| `center` | `center` | `center` |
|
|
134
|
+
| `right` / `bottom` | `flex-end` | `flex-end` |
|
|
135
|
+
| `spaceBetween` | `space-between` | `space-between` |
|
|
136
|
+
| `spaceAround` | `space-around` | `space-around` |
|
|
137
|
+
| `block` | `stretch` | `stretch` |
|
|
133
138
|
|
|
134
139
|
### Default Breakpoints
|
|
135
140
|
|
|
@@ -155,14 +160,14 @@ Breakpoint values are converted to `em` units in media queries for correct cross
|
|
|
155
160
|
|
|
156
161
|
### Other Exports
|
|
157
162
|
|
|
158
|
-
| Export
|
|
159
|
-
|
|
|
160
|
-
| `createMediaQueries`
|
|
161
|
-
| `transformTheme`
|
|
162
|
-
| `normalizeTheme`
|
|
163
|
-
| `sortBreakpoints`
|
|
164
|
-
| `extendCss`
|
|
165
|
-
| `Provider` / `context` | Theme context provider and consumer
|
|
163
|
+
| Export | Description |
|
|
164
|
+
| ---------------------- | ------------------------------------------------------------------ |
|
|
165
|
+
| `createMediaQueries` | Builds breakpoint-name → tagged-template-function map |
|
|
166
|
+
| `transformTheme` | Pivots property-centric theme to breakpoint-centric |
|
|
167
|
+
| `normalizeTheme` | Fills gaps so every breakpoint has a complete set of values |
|
|
168
|
+
| `sortBreakpoints` | Sorts breakpoint definitions by value (ascending) |
|
|
169
|
+
| `extendCss` | Helper for processing ExtendCss props (string, function, callback) |
|
|
170
|
+
| `Provider` / `context` | Theme context provider and consumer |
|
|
166
171
|
|
|
167
172
|
## Responsive Value Formats
|
|
168
173
|
|
|
@@ -183,11 +188,11 @@ When using `normalize: true` (default), missing breakpoints inherit from the pre
|
|
|
183
188
|
|
|
184
189
|
## Peer Dependencies
|
|
185
190
|
|
|
186
|
-
| Package
|
|
187
|
-
|
|
|
188
|
-
| @pyreon/core
|
|
191
|
+
| Package | Version |
|
|
192
|
+
| ------------------ | -------- |
|
|
193
|
+
| @pyreon/core | >= 0.0.1 |
|
|
189
194
|
| @pyreon/reactivity | >= 0.0.1 |
|
|
190
|
-
| @pyreon/ui-core
|
|
195
|
+
| @pyreon/ui-core | >= 0.0.1 |
|
|
191
196
|
|
|
192
197
|
## License
|
|
193
198
|
|
package/lib/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ type PyreonTheme = {
|
|
|
22
22
|
* enriched.__PYREON__.sortedBreakpoints // ['xs', 'sm', 'md']
|
|
23
23
|
* enriched.__PYREON__.media.sm // tagged-template for @media (min-width: 36em)
|
|
24
24
|
*/
|
|
25
|
-
declare function enrichTheme<T extends PyreonTheme>(theme: T): T & Required<Pick<PyreonTheme,
|
|
25
|
+
declare function enrichTheme<T extends PyreonTheme>(theme: T): T & Required<Pick<PyreonTheme, '__PYREON__'>>;
|
|
26
26
|
//#endregion
|
|
27
27
|
//#region src/context.d.ts
|
|
28
28
|
type TProvider = {
|
|
@@ -30,9 +30,14 @@ type TProvider = {
|
|
|
30
30
|
children?: VNode | null;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
+
* @internal Low-level provider — use `PyreonUI` from `@pyreon/ui-core` instead.
|
|
34
|
+
*
|
|
33
35
|
* Unistyle Provider — wraps the core Provider and enriches the theme
|
|
34
36
|
* with pre-computed sorted breakpoints and media-query tagged-template
|
|
35
37
|
* helpers consumed by `makeItResponsive`.
|
|
38
|
+
*
|
|
39
|
+
* @deprecated Prefer `<PyreonUI theme={theme} mode="light">` which handles
|
|
40
|
+
* all three context layers (styler, core, mode) in one component.
|
|
36
41
|
*/
|
|
37
42
|
declare function Provider(props: TProvider): VNode | null;
|
|
38
43
|
//#endregion
|
|
@@ -490,12 +495,12 @@ type Styles = ({
|
|
|
490
495
|
declare const styles$1: Styles;
|
|
491
496
|
//#endregion
|
|
492
497
|
//#region src/types.d.ts
|
|
493
|
-
type Defaults =
|
|
494
|
-
type Units =
|
|
498
|
+
type Defaults = 'initial' | 'inherit';
|
|
499
|
+
type Units = 'px' | 'rem' | 'em' | '%' | 'vh' | 'vw' | 'vmin' | 'vmax' | 'ex';
|
|
495
500
|
type UnitValue = number | `${number}${Units}`;
|
|
496
|
-
type PropertyValue = UnitValue |
|
|
497
|
-
type Color = `#${string | number}` |
|
|
498
|
-
type BrowserColors =
|
|
501
|
+
type PropertyValue = UnitValue | 'auto' | Defaults | `calc(${string | number})`;
|
|
502
|
+
type Color = `#${string | number}` | 'currentColor' | 'transparent' | `rgb(${number}, ${number}, ${number})` | `rgb(${number},${number},${number})` | `rgba(${number}, ${number}, ${number}, ${number})` | `rgba(${number},${number},${number},${number})` | `hsl(${number}, ${number}%, ${number}%)` | `hsl(${number},${number}%,${number}%)` | `hsla(${number}, ${number}%, ${number}%, ${number})` | `hsla(${number},${number}%,${number}%,${number})` | BrowserColors | Defaults;
|
|
503
|
+
type BrowserColors = 'black' | 'silver' | 'gray' | 'white' | 'maroon' | 'red' | 'purple' | 'fuchsia' | 'green' | 'lime' | 'olive' | 'yellow' | 'navy' | 'blue' | 'teal' | 'aqua' | 'orange' | 'aliceblue' | 'antiquewhite' | 'aquamarine' | 'azure' | 'beige' | 'bisque' | 'blanchedalmond' | 'blueviolet' | 'brown' | 'burlywood' | 'cadetblue' | 'chartreuse' | 'chocolate' | 'coral' | 'cornflowerblue' | 'cornsilk' | 'crimson' | 'cyan' | 'darkblue' | 'darkcyan' | 'darkgoldenrod' | 'darkgray' | 'darkgreen' | 'darkgrey' | 'darkkhaki' | 'darkmagenta' | 'darkolivegreen' | 'darkorange' | 'darkorchid' | 'darkred' | 'darksalmon' | 'darkseagreen' | 'darkslateblue' | 'darkslategray' | 'darkslategrey' | 'darkturquoise' | 'darkviolet' | 'deeppink' | 'deepskyblue' | 'dimgray' | 'dimgrey' | 'dodgerblue' | 'firebrick' | 'floralwhite' | 'forestgreen' | 'gainsboro' | 'ghostwhite' | 'gold' | 'goldenrod' | 'greenyellow' | 'grey' | 'honeydew' | 'hotpink' | 'indianred' | 'indigo' | 'ivory' | 'khaki' | 'lavender' | 'lavenderblush' | 'lawngreen' | 'lemonchiffon' | 'lightblue' | 'lightcoral' | 'lightcyan' | 'lightgoldenrodyellow' | 'lightgray' | 'lightgreen' | 'lightgrey' | 'lightpink' | 'lightsalmon' | 'lightseagreen' | 'lightskyblue' | 'lightslategray' | 'lightslategrey' | 'lightsteelblue' | 'lightyellow' | 'limegreen' | 'linen' | 'magenta' | 'mediumaquamarine' | 'mediumblue' | 'mediumorchid' | 'mediumpurple' | 'mediumseagreen' | 'mediumslateblue' | 'mediumspringgreen' | 'mediumturquoise' | 'mediumvioletred' | 'midnightblue' | 'mintcream' | 'mistyrose' | 'moccasin' | 'navajowhite' | 'oldlace' | 'olivedrab' | 'orangered' | 'orchid' | 'palegoldenrod' | 'palegreen' | 'paleturquoise' | 'palevioletred' | 'papayawhip' | 'peachpuff' | 'peru' | 'pink' | 'plum' | 'powderblue' | 'rosybrown' | 'royalblue' | 'saddlebrown' | 'salmon' | 'sandybrown' | 'seagreen' | 'seashell' | 'sienna' | 'skyblue' | 'slateblue' | 'slategray' | 'slategrey' | 'snow' | 'springgreen' | 'steelblue' | 'tan' | 'thistle' | 'tomato' | 'turquoise' | 'violet' | 'wheat' | 'whitesmoke' | 'yellowgreen' | 'rebeccapurple';
|
|
499
504
|
//#endregion
|
|
500
505
|
//#region src/units/stripUnit.d.ts
|
|
501
506
|
type Value$1<V> = V extends string ? number : V;
|
|
@@ -504,12 +509,12 @@ type StripUnit = <V extends string | number, UR extends boolean = false>(value:
|
|
|
504
509
|
declare const stripUnit: StripUnit;
|
|
505
510
|
//#endregion
|
|
506
511
|
//#region src/units/value.d.ts
|
|
507
|
-
type CssUnits$1 =
|
|
512
|
+
type CssUnits$1 = 'px' | 'rem' | '%' | 'em' | 'ex' | 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'ch' | 'vh' | 'vw' | 'vmin' | 'vmax';
|
|
508
513
|
type Value = (param: string | number | null | undefined, rootSize?: number, outputUnit?: CssUnits$1) => string | number | null;
|
|
509
514
|
declare const value: Value;
|
|
510
515
|
//#endregion
|
|
511
516
|
//#region src/units/values.d.ts
|
|
512
|
-
type CssUnits =
|
|
517
|
+
type CssUnits = 'px' | 'rem' | '%' | 'em' | 'ex' | 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'ch' | 'vh' | 'vw' | 'vmin' | 'vmax';
|
|
513
518
|
type Values = (items: unknown[], rootSize?: number, outputUnit?: CssUnits) => string | number | null;
|
|
514
519
|
declare const values: Values;
|
|
515
520
|
//#endregion
|
package/lib/index.js
CHANGED
|
@@ -25,10 +25,10 @@ const createMediaQueries = ((props) => {
|
|
|
25
25
|
else if (breakpointValue != null) {
|
|
26
26
|
const emSize = breakpointValue / rootSize;
|
|
27
27
|
acc[key] = (...args) => css`
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
@media only screen and (min-width: ${emSize}em) {
|
|
29
|
+
${css(...args)};
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
32
|
}
|
|
33
33
|
return acc;
|
|
34
34
|
}, {});
|
|
@@ -211,9 +211,14 @@ function enrichTheme(theme) {
|
|
|
211
211
|
//#endregion
|
|
212
212
|
//#region src/context.tsx
|
|
213
213
|
/**
|
|
214
|
+
* @internal Low-level provider — use `PyreonUI` from `@pyreon/ui-core` instead.
|
|
215
|
+
*
|
|
214
216
|
* Unistyle Provider — wraps the core Provider and enriches the theme
|
|
215
217
|
* with pre-computed sorted breakpoints and media-query tagged-template
|
|
216
218
|
* helpers consumed by `makeItResponsive`.
|
|
219
|
+
*
|
|
220
|
+
* @deprecated Prefer `<PyreonUI theme={theme} mode="light">` which handles
|
|
221
|
+
* all three context layers (styler, core, mode) in one component.
|
|
217
222
|
*/
|
|
218
223
|
function Provider(props) {
|
|
219
224
|
const { theme, children } = props;
|
package/package.json
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/unistyle",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.6",
|
|
4
|
+
"description": "Responsive theming and breakpoint utilities for Pyreon",
|
|
5
|
+
"license": "MIT",
|
|
4
6
|
"repository": {
|
|
5
7
|
"type": "git",
|
|
6
8
|
"url": "https://github.com/pyreon/pyreon",
|
|
7
9
|
"directory": "packages/ui-system/unistyle"
|
|
8
10
|
},
|
|
9
|
-
"description": "Responsive theming and breakpoint utilities for Pyreon",
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"type": "module",
|
|
12
|
-
"sideEffects": false,
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"bun": "./src/index.ts",
|
|
16
|
-
"import": "./lib/index.js",
|
|
17
|
-
"types": "./lib/index.d.ts"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"types": "./lib/index.d.ts",
|
|
21
|
-
"main": "./lib/index.js",
|
|
22
11
|
"files": [
|
|
23
12
|
"lib",
|
|
24
13
|
"!lib/**/*.map",
|
|
@@ -27,8 +16,16 @@
|
|
|
27
16
|
"LICENSE",
|
|
28
17
|
"src"
|
|
29
18
|
],
|
|
30
|
-
"
|
|
31
|
-
|
|
19
|
+
"type": "module",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"main": "./lib/index.js",
|
|
22
|
+
"types": "./lib/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"bun": "./src/index.ts",
|
|
26
|
+
"import": "./lib/index.js",
|
|
27
|
+
"types": "./lib/index.d.ts"
|
|
28
|
+
}
|
|
32
29
|
},
|
|
33
30
|
"publishConfig": {
|
|
34
31
|
"access": "public"
|
|
@@ -37,20 +34,23 @@
|
|
|
37
34
|
"prepublish": "bun run build",
|
|
38
35
|
"build": "bun run vl_rolldown_build",
|
|
39
36
|
"build:watch": "bun run vl_rolldown_build-watch",
|
|
40
|
-
"lint": "
|
|
37
|
+
"lint": "oxlint .",
|
|
41
38
|
"test": "vitest run",
|
|
42
39
|
"test:coverage": "vitest run --coverage",
|
|
43
40
|
"test:watch": "vitest",
|
|
44
41
|
"typecheck": "tsc --noEmit"
|
|
45
42
|
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@pyreon/typescript": "^0.11.6",
|
|
45
|
+
"@vitus-labs/tools-rolldown": "^1.15.3"
|
|
46
|
+
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"@pyreon/core": "^0.11.
|
|
48
|
-
"@pyreon/reactivity": "^0.11.
|
|
49
|
-
"@pyreon/
|
|
50
|
-
"@pyreon/
|
|
48
|
+
"@pyreon/core": "^0.11.6",
|
|
49
|
+
"@pyreon/reactivity": "^0.11.6",
|
|
50
|
+
"@pyreon/styler": "^0.11.6",
|
|
51
|
+
"@pyreon/ui-core": "^0.11.6"
|
|
51
52
|
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"@pyreon/typescript": "^0.11.4"
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">= 22"
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
import { describe, expect, it } from
|
|
2
|
-
import alignContent from
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import alignContent from '../styles/alignContent'
|
|
3
3
|
|
|
4
|
-
describe(
|
|
5
|
-
it(
|
|
4
|
+
describe('alignContent', () => {
|
|
5
|
+
it('returns null for empty attrs', () => {
|
|
6
6
|
expect(alignContent({} as any)).toBeNull()
|
|
7
7
|
})
|
|
8
8
|
|
|
9
|
-
it(
|
|
10
|
-
expect(alignContent({ alignX:
|
|
9
|
+
it('returns null when direction is missing', () => {
|
|
10
|
+
expect(alignContent({ alignX: 'left', alignY: 'top' } as any)).toBeNull()
|
|
11
11
|
})
|
|
12
12
|
|
|
13
|
-
it(
|
|
14
|
-
expect(alignContent({ direction:
|
|
13
|
+
it('returns null when alignX is missing', () => {
|
|
14
|
+
expect(alignContent({ direction: 'inline', alignY: 'top' } as any)).toBeNull()
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
-
it(
|
|
18
|
-
expect(alignContent({ direction:
|
|
17
|
+
it('returns null when alignY is missing', () => {
|
|
18
|
+
expect(alignContent({ direction: 'inline', alignX: 'left' } as any)).toBeNull()
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
describe(
|
|
22
|
-
it(
|
|
23
|
-
const result = alignContent({ direction:
|
|
21
|
+
describe('inline direction (reverted)', () => {
|
|
22
|
+
it('returns row with align-items from Y and justify-content from X', () => {
|
|
23
|
+
const result = alignContent({ direction: 'inline', alignX: 'left', alignY: 'top' })
|
|
24
24
|
expect(result).toBe(
|
|
25
|
-
|
|
25
|
+
'flex-direction: row; align-items: flex-start; justify-content: flex-start;',
|
|
26
26
|
)
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
it(
|
|
30
|
-
const result = alignContent({ direction:
|
|
31
|
-
expect(result).toBe(
|
|
29
|
+
it('maps right/bottom correctly', () => {
|
|
30
|
+
const result = alignContent({ direction: 'inline', alignX: 'right', alignY: 'bottom' })
|
|
31
|
+
expect(result).toBe('flex-direction: row; align-items: flex-end; justify-content: flex-end;')
|
|
32
32
|
})
|
|
33
33
|
|
|
34
|
-
it(
|
|
35
|
-
const result = alignContent({ direction:
|
|
36
|
-
expect(result).toBe(
|
|
34
|
+
it('maps center/center', () => {
|
|
35
|
+
const result = alignContent({ direction: 'inline', alignX: 'center', alignY: 'center' })
|
|
36
|
+
expect(result).toBe('flex-direction: row; align-items: center; justify-content: center;')
|
|
37
37
|
})
|
|
38
38
|
|
|
39
|
-
it(
|
|
39
|
+
it('maps spaceBetween/spaceAround', () => {
|
|
40
40
|
const result = alignContent({
|
|
41
|
-
direction:
|
|
42
|
-
alignX:
|
|
43
|
-
alignY:
|
|
41
|
+
direction: 'inline',
|
|
42
|
+
alignX: 'spaceBetween',
|
|
43
|
+
alignY: 'spaceAround',
|
|
44
44
|
})
|
|
45
45
|
expect(result).toBe(
|
|
46
|
-
|
|
46
|
+
'flex-direction: row; align-items: space-around; justify-content: space-between;',
|
|
47
47
|
)
|
|
48
48
|
})
|
|
49
49
|
|
|
50
|
-
it(
|
|
51
|
-
const result = alignContent({ direction:
|
|
52
|
-
expect(result).toBe(
|
|
50
|
+
it('maps block/block', () => {
|
|
51
|
+
const result = alignContent({ direction: 'inline', alignX: 'block', alignY: 'block' })
|
|
52
|
+
expect(result).toBe('flex-direction: row; align-items: stretch; justify-content: stretch;')
|
|
53
53
|
})
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
-
describe(
|
|
57
|
-
it(
|
|
58
|
-
const result = alignContent({ direction:
|
|
56
|
+
describe('reverseInline direction (reverted)', () => {
|
|
57
|
+
it('returns row-reverse with align-items from Y and justify-content from X', () => {
|
|
58
|
+
const result = alignContent({ direction: 'reverseInline', alignX: 'left', alignY: 'top' })
|
|
59
59
|
expect(result).toBe(
|
|
60
|
-
|
|
60
|
+
'flex-direction: row-reverse; align-items: flex-start; justify-content: flex-start;',
|
|
61
61
|
)
|
|
62
62
|
})
|
|
63
63
|
|
|
64
|
-
it(
|
|
64
|
+
it('maps center/bottom', () => {
|
|
65
65
|
const result = alignContent({
|
|
66
|
-
direction:
|
|
67
|
-
alignX:
|
|
68
|
-
alignY:
|
|
66
|
+
direction: 'reverseInline',
|
|
67
|
+
alignX: 'center',
|
|
68
|
+
alignY: 'bottom',
|
|
69
69
|
})
|
|
70
70
|
expect(result).toBe(
|
|
71
|
-
|
|
71
|
+
'flex-direction: row-reverse; align-items: flex-end; justify-content: center;',
|
|
72
72
|
)
|
|
73
73
|
})
|
|
74
74
|
})
|
|
75
75
|
|
|
76
|
-
describe(
|
|
77
|
-
it(
|
|
78
|
-
const result = alignContent({ direction:
|
|
76
|
+
describe('rows direction (non-reverted)', () => {
|
|
77
|
+
it('returns column with align-items from X and justify-content from Y', () => {
|
|
78
|
+
const result = alignContent({ direction: 'rows', alignX: 'left', alignY: 'top' })
|
|
79
79
|
expect(result).toBe(
|
|
80
|
-
|
|
80
|
+
'flex-direction: column; align-items: flex-start; justify-content: flex-start;',
|
|
81
81
|
)
|
|
82
82
|
})
|
|
83
83
|
|
|
84
|
-
it(
|
|
85
|
-
const result = alignContent({ direction:
|
|
84
|
+
it('maps right/bottom correctly', () => {
|
|
85
|
+
const result = alignContent({ direction: 'rows', alignX: 'right', alignY: 'bottom' })
|
|
86
86
|
expect(result).toBe(
|
|
87
|
-
|
|
87
|
+
'flex-direction: column; align-items: flex-end; justify-content: flex-end;',
|
|
88
88
|
)
|
|
89
89
|
})
|
|
90
90
|
|
|
91
|
-
it(
|
|
92
|
-
const result = alignContent({ direction:
|
|
91
|
+
it('maps center/spaceBetween', () => {
|
|
92
|
+
const result = alignContent({ direction: 'rows', alignX: 'center', alignY: 'spaceBetween' })
|
|
93
93
|
expect(result).toBe(
|
|
94
|
-
|
|
94
|
+
'flex-direction: column; align-items: center; justify-content: space-between;',
|
|
95
95
|
)
|
|
96
96
|
})
|
|
97
97
|
|
|
98
|
-
it(
|
|
99
|
-
const result = alignContent({ direction:
|
|
98
|
+
it('maps spaceAround/block', () => {
|
|
99
|
+
const result = alignContent({ direction: 'rows', alignX: 'spaceAround', alignY: 'block' })
|
|
100
100
|
expect(result).toBe(
|
|
101
|
-
|
|
101
|
+
'flex-direction: column; align-items: space-around; justify-content: stretch;',
|
|
102
102
|
)
|
|
103
103
|
})
|
|
104
104
|
})
|
|
105
105
|
|
|
106
|
-
describe(
|
|
107
|
-
it(
|
|
108
|
-
const result = alignContent({ direction:
|
|
106
|
+
describe('reverseRows direction (non-reverted)', () => {
|
|
107
|
+
it('returns column-reverse with align-items from X and justify-content from Y', () => {
|
|
108
|
+
const result = alignContent({ direction: 'reverseRows', alignX: 'left', alignY: 'top' })
|
|
109
109
|
expect(result).toBe(
|
|
110
|
-
|
|
110
|
+
'flex-direction: column-reverse; align-items: flex-start; justify-content: flex-start;',
|
|
111
111
|
)
|
|
112
112
|
})
|
|
113
113
|
|
|
114
|
-
it(
|
|
115
|
-
const result = alignContent({ direction:
|
|
114
|
+
it('maps block/center', () => {
|
|
115
|
+
const result = alignContent({ direction: 'reverseRows', alignX: 'block', alignY: 'center' })
|
|
116
116
|
expect(result).toBe(
|
|
117
|
-
|
|
117
|
+
'flex-direction: column-reverse; align-items: stretch; justify-content: center;',
|
|
118
118
|
)
|
|
119
119
|
})
|
|
120
120
|
})
|