@codecademy/variance 0.22.2-alpha.eb27ba.0 → 0.23.0-alpha.11964f.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/dist/types/props.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ interface BreakpointKeys<T = string> {
|
|
|
8
8
|
md: T;
|
|
9
9
|
lg: T;
|
|
10
10
|
xl: T;
|
|
11
|
+
c_xs: T;
|
|
12
|
+
c_sm: T;
|
|
13
|
+
c_md: T;
|
|
14
|
+
c_lg: T;
|
|
15
|
+
c_xl: T;
|
|
11
16
|
}
|
|
12
17
|
export interface BreakpointCache {
|
|
13
18
|
map: BreakpointKeys;
|
|
@@ -16,13 +21,18 @@ export interface BreakpointCache {
|
|
|
16
21
|
export type ThemeProps<Props = {}> = Props & {
|
|
17
22
|
theme?: Theme;
|
|
18
23
|
};
|
|
19
|
-
export interface
|
|
24
|
+
export interface BreakpointArray<T> {
|
|
20
25
|
0?: T;
|
|
21
26
|
1?: T;
|
|
22
27
|
2?: T;
|
|
23
28
|
3?: T;
|
|
24
29
|
4?: T;
|
|
25
30
|
5?: T;
|
|
31
|
+
6?: T;
|
|
32
|
+
7?: T;
|
|
33
|
+
8?: T;
|
|
34
|
+
9?: T;
|
|
35
|
+
10?: T;
|
|
26
36
|
}
|
|
27
37
|
export interface MediaQueryMap<T> {
|
|
28
38
|
_?: T;
|
|
@@ -32,7 +42,15 @@ export interface MediaQueryMap<T> {
|
|
|
32
42
|
lg?: T;
|
|
33
43
|
xl?: T;
|
|
34
44
|
}
|
|
35
|
-
export
|
|
45
|
+
export interface ContainerQueryMap<T> {
|
|
46
|
+
c_xs?: T;
|
|
47
|
+
c_sm?: T;
|
|
48
|
+
c_md?: T;
|
|
49
|
+
c_lg?: T;
|
|
50
|
+
c_xl?: T;
|
|
51
|
+
}
|
|
52
|
+
export type BreakpointMap<T> = ContainerQueryMap<T> & MediaQueryMap<T>;
|
|
53
|
+
export type ResponsiveProp<T> = T | BreakpointMap<T> | BreakpointArray<T>;
|
|
36
54
|
export interface CSSObject {
|
|
37
55
|
[key: string]: string | number | CSSObject | undefined;
|
|
38
56
|
}
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { AbstractPropTransformer } from '../types/config';
|
|
2
|
-
import { BreakpointCache,
|
|
2
|
+
import { BreakpointCache, BreakpointMap, CSSObject, ThemeProps } from '../types/props';
|
|
3
3
|
import { Breakpoints } from '../types/theme';
|
|
4
4
|
/**
|
|
5
5
|
* Destructures the themes breakpoints into an ordered structure to traverse
|
|
6
6
|
*/
|
|
7
7
|
export declare const parseBreakpoints: (breakpoints?: Breakpoints | undefined) => BreakpointCache | null;
|
|
8
8
|
export declare const isMediaArray: (val: unknown) => val is (string | number)[];
|
|
9
|
-
export declare const isMediaMap: (val: object) => val is
|
|
10
|
-
interface ResponsiveParser<Bp extends
|
|
9
|
+
export declare const isMediaMap: (val: object) => val is BreakpointMap<string | number>;
|
|
10
|
+
interface ResponsiveParser<Bp extends BreakpointMap<string | number> | (string | number)[]> {
|
|
11
11
|
<C extends AbstractPropTransformer>(value: Bp, props: ThemeProps, config: C, breakpoints: Bp): CSSObject;
|
|
12
12
|
}
|
|
13
|
-
export declare const objectParser: ResponsiveParser<
|
|
13
|
+
export declare const objectParser: ResponsiveParser<BreakpointMap<string | number>>;
|
|
14
14
|
export declare const arrayParser: ResponsiveParser<(string | number)[]>;
|
|
15
15
|
export declare const orderBreakpoints: (styles: CSSObject, breakpoints: string[]) => CSSObject;
|
|
16
16
|
export {};
|
package/dist/utils/responsive.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import intersection from 'lodash/intersection';
|
|
2
2
|
import omit from 'lodash/omit';
|
|
3
|
-
const BREAKPOINT_KEYS = ['_', 'xs', 'sm', 'md', 'lg', 'xl'];
|
|
3
|
+
const BREAKPOINT_KEYS = ['_', 'xs', 'sm', 'md', 'lg', 'xl', 'c_xs', 'c_sm', 'c_md', 'c_lg', 'c_xl'];
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Destructures the themes breakpoints into an ordered structure to traverse
|
|
@@ -12,13 +12,18 @@ export const parseBreakpoints = breakpoints => {
|
|
|
12
12
|
sm,
|
|
13
13
|
md,
|
|
14
14
|
lg,
|
|
15
|
-
xl
|
|
15
|
+
xl,
|
|
16
|
+
c_xs,
|
|
17
|
+
c_sm,
|
|
18
|
+
c_md,
|
|
19
|
+
c_lg,
|
|
20
|
+
c_xl
|
|
16
21
|
} = breakpoints ?? {};
|
|
17
22
|
|
|
18
|
-
// Ensure order for mapping
|
|
23
|
+
// Ensure order for mapping - media queries first, then container queries
|
|
19
24
|
return {
|
|
20
25
|
map: breakpoints,
|
|
21
|
-
array: [xs, sm, md, lg, xl]
|
|
26
|
+
array: [xs, sm, md, lg, xl, c_xs, c_sm, c_md, c_lg, c_xl]
|
|
22
27
|
};
|
|
23
28
|
};
|
|
24
29
|
export const isMediaArray = val => Array.isArray(val);
|
|
@@ -20,9 +20,13 @@ const templateBreakpoints = (value, alias, theme) => {
|
|
|
20
20
|
breakpoints
|
|
21
21
|
} = theme;
|
|
22
22
|
Object.keys(breakpoints).forEach(key => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const breakpointValue = rest[key];
|
|
24
|
+
// Only create CSS rules for breakpoints that have defined values
|
|
25
|
+
if (breakpointValue !== undefined) {
|
|
26
|
+
css[breakpoints[key]] = {
|
|
27
|
+
[alias]: breakpointValue
|
|
28
|
+
};
|
|
29
|
+
}
|
|
26
30
|
});
|
|
27
31
|
}
|
|
28
32
|
return css;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/variance",
|
|
3
3
|
"description": "Constraint based CSS in JS for building scalable design systems",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.23.0-alpha.11964f.0",
|
|
5
5
|
"author": "codecaaron <aaron@codecademy.com>",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"csstype": "^3.0.7",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"build": "nx build @codecademy/variance"
|
|
33
33
|
},
|
|
34
34
|
"types": "dist/index.d.ts",
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "d1b63e6197d02d0edf8726e86715636ce1efad36"
|
|
36
36
|
}
|