@atlaskit/primitives 0.0.1
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/CHANGELOG.md +7 -0
- package/LICENSE.md +13 -0
- package/README.md +9 -0
- package/box/package.json +15 -0
- package/dist/cjs/components/box.js +13 -0
- package/dist/cjs/components/inline.partial.js +13 -0
- package/dist/cjs/components/internal/box.partial.js +605 -0
- package/dist/cjs/components/stack.partial.js +13 -0
- package/dist/cjs/components/types.js +5 -0
- package/dist/cjs/constants.js +18 -0
- package/dist/cjs/index.js +26 -0
- package/dist/cjs/internal/color-map.js +42 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/components/box.js +1 -0
- package/dist/es2019/components/inline.partial.js +2 -0
- package/dist/es2019/components/internal/box.partial.js +597 -0
- package/dist/es2019/components/stack.partial.js +2 -0
- package/dist/es2019/components/types.js +1 -0
- package/dist/es2019/constants.js +11 -0
- package/dist/es2019/index.js +3 -0
- package/dist/es2019/internal/color-map.js +35 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/components/box.js +1 -0
- package/dist/esm/components/inline.partial.js +2 -0
- package/dist/esm/components/internal/box.partial.js +600 -0
- package/dist/esm/components/stack.partial.js +2 -0
- package/dist/esm/components/types.js +1 -0
- package/dist/esm/constants.js +11 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/internal/color-map.js +35 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/components/box.d.ts +1 -0
- package/dist/types/components/inline.partial.d.ts +1 -0
- package/dist/types/components/internal/box.partial.d.ts +348 -0
- package/dist/types/components/stack.partial.d.ts +1 -0
- package/dist/types/components/types.d.ts +13 -0
- package/dist/types/constants.d.ts +12 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/internal/color-map.d.ts +36 -0
- package/inline/package.json +15 -0
- package/package.json +89 -0
- package/report.api.md +43 -0
- package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +181 -0
- package/scripts/__tests__/codegen.test.tsx +20 -0
- package/scripts/codegen-styles.tsx +124 -0
- package/scripts/color-codegen-template.tsx +111 -0
- package/scripts/color-map-template.tsx +52 -0
- package/scripts/dimension-codegen-template.tsx +63 -0
- package/scripts/misc-codegen-template.tsx +43 -0
- package/scripts/spacing-codegen-template.tsx +84 -0
- package/scripts/utils.tsx +55 -0
- package/stack/package.json +15 -0
- package/tmp/api-report-tmp.d.ts +19 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
export const tokenToStyle = (
|
|
4
|
+
prop: keyof CSSProperties,
|
|
5
|
+
token: string,
|
|
6
|
+
fallback: string | ShadowDefintion,
|
|
7
|
+
) => {
|
|
8
|
+
if (Array.isArray(fallback)) {
|
|
9
|
+
fallback = constructShadow(fallback);
|
|
10
|
+
}
|
|
11
|
+
return `css({\n\t${prop}: token('${token}', '${fallback}')\n})`;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type ShadowDefintion = Array<{
|
|
15
|
+
radius: number;
|
|
16
|
+
offset: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
};
|
|
20
|
+
color: string;
|
|
21
|
+
opacity: number;
|
|
22
|
+
}>;
|
|
23
|
+
|
|
24
|
+
const constructShadow = (shadowObject: ShadowDefintion) => {
|
|
25
|
+
return shadowObject
|
|
26
|
+
.map(
|
|
27
|
+
shadow =>
|
|
28
|
+
`${shadow.offset.x}px ${shadow.offset.y}px ${shadow.radius}px ${shadow.color}`,
|
|
29
|
+
)
|
|
30
|
+
.join(', ');
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type BooleanCallback<T> = (args: T) => boolean;
|
|
34
|
+
|
|
35
|
+
export const compose =
|
|
36
|
+
(...fns: ((...any: any[]) => any)[]) =>
|
|
37
|
+
(x: any) =>
|
|
38
|
+
fns.reduce((res, fn) => fn(res), x);
|
|
39
|
+
export const pick =
|
|
40
|
+
<T extends any>(key: keyof T) =>
|
|
41
|
+
(obj: T) =>
|
|
42
|
+
obj[key];
|
|
43
|
+
export const isAccent = (str: string) => str.includes('accent');
|
|
44
|
+
export const isPressed = (str: string) => str.includes('pressed');
|
|
45
|
+
export const isHovered = (str: string) => str.includes('hovered');
|
|
46
|
+
export const not =
|
|
47
|
+
<T extends any>(cb: BooleanCallback<T>) =>
|
|
48
|
+
(val: T) =>
|
|
49
|
+
!cb(val);
|
|
50
|
+
export const or =
|
|
51
|
+
<T extends any>(...fns: BooleanCallback<T>[]) =>
|
|
52
|
+
(val: T) =>
|
|
53
|
+
fns.some(fn => fn(val));
|
|
54
|
+
export const capitalize = (str: string) =>
|
|
55
|
+
str.charAt(0).toUpperCase() + str.slice(1);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/primitives/stack",
|
|
3
|
+
"main": "../dist/cjs/components/stack.partial.js",
|
|
4
|
+
"module": "../dist/esm/components/stack.partial.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/components/stack.partial.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/components/stack.partial.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.0 <4.5": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.0/components/stack.partial.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/primitives"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import { default as Box } from '@atlaskit/ds-explorations/box';
|
|
8
|
+
import { default as Inline } from '@atlaskit/ds-explorations/inline';
|
|
9
|
+
import { default as Stack } from '@atlaskit/ds-explorations/stack';
|
|
10
|
+
|
|
11
|
+
export { Box }
|
|
12
|
+
|
|
13
|
+
export { Inline }
|
|
14
|
+
|
|
15
|
+
export { Stack }
|
|
16
|
+
|
|
17
|
+
// (No @packageDocumentation comment for this package)
|
|
18
|
+
|
|
19
|
+
```
|