@cleartrip/ct-design-dotted-loader 4.0.0 → 5.0.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/README.md +80 -0
- package/dist/DottedLoader.d.ts +3 -5
- package/dist/DottedLoader.d.ts.map +1 -1
- package/dist/DottedLoader.native.d.ts +5 -0
- package/dist/DottedLoader.native.d.ts.map +1 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/ct-design-dottedLoader.browser.cjs.js +5 -1
- package/dist/ct-design-dottedLoader.browser.cjs.js.map +1 -1
- package/dist/ct-design-dottedLoader.browser.esm.js +5 -1
- package/dist/ct-design-dottedLoader.browser.esm.js.map +1 -1
- package/dist/ct-design-dottedLoader.cjs.js +53 -37
- package/dist/ct-design-dottedLoader.cjs.js.map +1 -1
- package/dist/ct-design-dottedLoader.esm.js +52 -32
- package/dist/ct-design-dottedLoader.esm.js.map +1 -1
- package/dist/ct-design-dottedLoader.umd.js +67 -92
- package/dist/ct-design-dottedLoader.umd.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.native.d.ts +4 -0
- package/dist/index.native.d.ts.map +1 -0
- package/dist/style.d.ts +19 -12
- package/dist/style.d.ts.map +1 -1
- package/dist/type.d.ts +18 -11
- package/dist/type.d.ts.map +1 -1
- package/package.json +30 -8
- package/src/DottedLoader.native.tsx +125 -0
- package/src/DottedLoader.tsx +80 -0
- package/src/constants.ts +5 -0
- package/src/index.native.ts +3 -0
- package/src/index.ts +3 -0
- package/src/style.ts +54 -0
- package/src/type.ts +82 -0
package/src/style.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { keyframes } from '@emotion/css';
|
|
2
|
+
|
|
3
|
+
import type { Theme } from '@cleartrip/ct-design-theme';
|
|
4
|
+
import { makeStyles } from '@cleartrip/ct-design-style-manager';
|
|
5
|
+
|
|
6
|
+
import { LoaderVariant } from './type';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the dot dimension based on the `variant` prop. Mirrors the
|
|
10
|
+
* aldenui behaviour: `large` → theme.size[3], `medium` → theme.size[2],
|
|
11
|
+
* `small` (default) → theme.size[1].
|
|
12
|
+
*/
|
|
13
|
+
export function getLoaderDimension(size: LoaderVariant | undefined, theme: Theme) {
|
|
14
|
+
switch (size) {
|
|
15
|
+
case 'large':
|
|
16
|
+
return theme.size[3];
|
|
17
|
+
case 'medium':
|
|
18
|
+
return theme.size[2];
|
|
19
|
+
default:
|
|
20
|
+
return theme.size[1];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Produces a stable emotion keyframe animation name for the given
|
|
26
|
+
* colour pair. Each unique `(color1, color2)` combination is cached by
|
|
27
|
+
* emotion so repeated calls with the same theme share a single
|
|
28
|
+
* declaration.
|
|
29
|
+
*/
|
|
30
|
+
export const dotAnimationKeyframe = ({ color1, color2 }: { color1: string; color2: string }) => keyframes`
|
|
31
|
+
0% { background-color: ${color1}; transform: scale(1); }
|
|
32
|
+
50% { background-color: ${color2}; transform: scale(1.2); }
|
|
33
|
+
100% { background-color: ${color1}; transform: scale(1); }
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Static styles shared by both web and native implementations. Dot
|
|
38
|
+
* radius and wrapper layout are pure theme lookups; dynamic values
|
|
39
|
+
* (size, colour, animation) are applied on top per-render.
|
|
40
|
+
*/
|
|
41
|
+
const staticLoaderStyles = makeStyles((theme) => ({
|
|
42
|
+
root: {
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
justifyContent: 'center',
|
|
45
|
+
flexDirection: 'row',
|
|
46
|
+
columnGap: 8,
|
|
47
|
+
},
|
|
48
|
+
dot: {
|
|
49
|
+
borderRadius: theme.border.radius[32],
|
|
50
|
+
backgroundColor: theme.color.background.defaultDark,
|
|
51
|
+
},
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
export default staticLoaderStyles;
|
package/src/type.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Styles } from '@cleartrip/ct-design-types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Enum of supported DottedLoader sizes. Consumers typically use the
|
|
7
|
+
* `LoaderVariant` string-literal form.
|
|
8
|
+
*/
|
|
9
|
+
import { DottedLoaderSize } from './constants';
|
|
10
|
+
|
|
11
|
+
export type LoaderVariant = `${DottedLoaderSize}`;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* `styleConfig` shape for DottedLoader. Exposes slots for the outer
|
|
15
|
+
* wrapper (`root`) and the individual dot (`loaderCont`).
|
|
16
|
+
*/
|
|
17
|
+
export interface IDottedLoaderStyleConfig {
|
|
18
|
+
/**
|
|
19
|
+
* Styles applied to the outer loader container.
|
|
20
|
+
*/
|
|
21
|
+
root?: Styles[];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Styles applied to each dot element.
|
|
25
|
+
*/
|
|
26
|
+
loaderCont?: Styles[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Props for the DottedLoader component.
|
|
31
|
+
*/
|
|
32
|
+
export interface IDottedLoaderProps {
|
|
33
|
+
/**
|
|
34
|
+
* Size variant for the loader dots. Defaults to `'medium'`.
|
|
35
|
+
*/
|
|
36
|
+
variant?: LoaderVariant;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* `styleConfig` slots for fine-grained style overrides.
|
|
40
|
+
*/
|
|
41
|
+
styleConfig?: IDottedLoaderStyleConfig;
|
|
42
|
+
|
|
43
|
+
// ---------------------------------------------------------------------
|
|
44
|
+
// Deprecated / legacy escape hatches retained for backward compatibility.
|
|
45
|
+
// ---------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use `styleConfig.root` instead. Still appended last so
|
|
49
|
+
* existing overrides continue to win on web.
|
|
50
|
+
*/
|
|
51
|
+
css?: CSSProperties;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Props for the single-dot sub-component.
|
|
56
|
+
*/
|
|
57
|
+
export interface IDotStyleConfig {
|
|
58
|
+
/**
|
|
59
|
+
* Styles applied to the dot element.
|
|
60
|
+
*/
|
|
61
|
+
root?: Styles[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface IDot {
|
|
65
|
+
/**
|
|
66
|
+
* Zero-indexed position of the dot within the loader. Drives the
|
|
67
|
+
* staggered animation delay.
|
|
68
|
+
*/
|
|
69
|
+
dotId: number;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Size variant inherited from the parent loader.
|
|
73
|
+
*/
|
|
74
|
+
variant?: LoaderVariant;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Per-dot style overrides.
|
|
78
|
+
*/
|
|
79
|
+
styleConfig?: IDotStyleConfig;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type DottedLoaderProps = IDottedLoaderProps;
|