@cleartrip/ct-design-theme 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.
Files changed (51) hide show
  1. package/dist/ThemeProvider/ThemeProvider.d.ts +2 -7
  2. package/dist/ThemeProvider/ThemeProvider.d.ts.map +1 -1
  3. package/dist/ThemeProvider/ThemeProvider.native.d.ts +5 -0
  4. package/dist/ThemeProvider/ThemeProvider.native.d.ts.map +1 -0
  5. package/dist/ThemeProvider/index.d.ts +1 -1
  6. package/dist/ThemeProvider/index.d.ts.map +1 -1
  7. package/dist/ct-design-theme.browser.cjs.js +1 -1
  8. package/dist/ct-design-theme.browser.cjs.js.map +1 -1
  9. package/dist/ct-design-theme.browser.esm.js +1 -1
  10. package/dist/ct-design-theme.browser.esm.js.map +1 -1
  11. package/dist/ct-design-theme.cjs.js +210 -111
  12. package/dist/ct-design-theme.cjs.js.map +1 -1
  13. package/dist/ct-design-theme.esm.js +208 -112
  14. package/dist/ct-design-theme.esm.js.map +1 -1
  15. package/dist/ct-design-theme.umd.js +2279 -147
  16. package/dist/ct-design-theme.umd.js.map +1 -1
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/themes/B2BTheme.d.ts.map +1 -1
  20. package/dist/themes/B2CTheme.d.ts +2 -229
  21. package/dist/themes/B2CTheme.d.ts.map +1 -1
  22. package/dist/themes/BaseTheme.d.ts +1 -1
  23. package/dist/themes/BaseTheme.d.ts.map +1 -1
  24. package/dist/themes/SMTheme.d.ts +4 -0
  25. package/dist/themes/SMTheme.d.ts.map +1 -0
  26. package/dist/themes/UltraFkTheme.d.ts.map +1 -1
  27. package/dist/themes/index.d.ts +2 -1
  28. package/dist/themes/index.d.ts.map +1 -1
  29. package/dist/themes/type.d.ts +80 -10
  30. package/dist/themes/type.d.ts.map +1 -1
  31. package/dist/utils/ThemeManager.d.ts +11 -0
  32. package/dist/utils/ThemeManager.d.ts.map +1 -0
  33. package/dist/utils/index.d.ts.map +1 -1
  34. package/package.json +9 -6
  35. package/src/ThemeProvider/ThemeProvider.native.tsx +20 -0
  36. package/src/ThemeProvider/ThemeProvider.tsx +29 -0
  37. package/src/ThemeProvider/index.ts +3 -0
  38. package/src/ThemeProvider/type.ts +15 -0
  39. package/src/hooks/index.ts +2 -0
  40. package/src/hooks/useTheme.ts +11 -0
  41. package/src/hooks/useThemeContext.ts +8 -0
  42. package/src/index.ts +5 -0
  43. package/src/themes/B2BTheme.ts +87 -0
  44. package/src/themes/B2CTheme.ts +7 -0
  45. package/src/themes/BaseTheme.ts +336 -0
  46. package/src/themes/SMTheme.ts +86 -0
  47. package/src/themes/UltraFkTheme.ts +93 -0
  48. package/src/themes/index.ts +7 -0
  49. package/src/themes/type.ts +272 -0
  50. package/src/utils/ThemeManager.ts +36 -0
  51. package/src/utils/index.ts +21 -0
@@ -0,0 +1,272 @@
1
+ import type { Border } from '@cleartrip/ct-design-tokens';
2
+ import { Size, Elevation } from '@cleartrip/ct-design-tokens';
3
+ import type { Spacing } from '@cleartrip/ct-design-tokens';
4
+ import type { Typography } from '@cleartrip/ct-design-tokens';
5
+
6
+ export type UnderlineType = '' | 'underline';
7
+
8
+ export type Theme = {
9
+ color: {
10
+ text: {
11
+ primary: string;
12
+ secondary: string;
13
+ tertiary: string;
14
+ heading: string;
15
+ subHeading: string;
16
+ disabled: string;
17
+ success: string;
18
+ alert: string;
19
+ warning: string;
20
+ link: string;
21
+ brand: string;
22
+ neutral: string;
23
+ link2: string;
24
+ margarita: string;
25
+ // it's a new color introducted in figma
26
+ primary2: string;
27
+ secondary2: string;
28
+ grapetini900: string;
29
+ pinaColada750: string;
30
+ alert500: string;
31
+ neutral50: string;
32
+ margarita750?: string;
33
+ green100: string;
34
+ red100: string;
35
+ coralpink: string;
36
+ primary3: string;
37
+ };
38
+ button: {
39
+ outlinedPrimaryLabel: string;
40
+ outlinedPrimaryBorder: string;
41
+ outlinedPrimaryBg: string;
42
+ outlinedSecondaryLabel: string;
43
+ outlinedSecondaryBorder: string;
44
+ outlinedSecondaryBg: string;
45
+ outlinedTertiaryLabel: string;
46
+ outlinedTertiaryBorder: string;
47
+ outlinedTertiaryBg: string;
48
+ outlinedDisabledLabel: string;
49
+ outlinedDisabledBg: string;
50
+ containedPrimaryLabel: string;
51
+ containedPrimaryBg: string;
52
+ containedSecondaryLabel: string;
53
+ containedSecondaryBg: string;
54
+ containedTertiaryLabel: string;
55
+ containedTertiaryBg: string;
56
+ containedDisabledLabel: string;
57
+ containedDisabledBg: string;
58
+ containedNeutralLabel: string;
59
+ containedNeutralBg: string;
60
+ outlinedNeutralLabel: string;
61
+ outlinedNeutralBorder: string;
62
+ outlinedNeutralBg: string;
63
+ hover: unknown;
64
+ };
65
+ chip: {
66
+ nonSelectedPrimaryLabel: string;
67
+ selectedPrimaryLabel: string;
68
+ selectedPrimaryBorder: string;
69
+ selectedPrimaryBg: string;
70
+ disabledPrimaryLabel: string;
71
+ disabledPrimaryBg: string;
72
+ };
73
+ dropdown: {
74
+ shadow: string;
75
+ };
76
+ tab: {
77
+ nonSelectedPrimaryLabel: string;
78
+ selectedPrimaryLabel: string;
79
+ };
80
+ sidenav: {
81
+ primaryBg: string;
82
+ selectedTabBg: string;
83
+ };
84
+ tooltip: {
85
+ primaryBg: string;
86
+ };
87
+ background: {
88
+ primary: string;
89
+ secondary: string;
90
+ tertiary: string;
91
+ brand: string;
92
+ brandLightBg: string;
93
+ link: string;
94
+ link2: string;
95
+ linkLightBg: string;
96
+ success: string;
97
+ successLightBg: string;
98
+ alert: string;
99
+ alertLightBg: string;
100
+ alertSoft: string;
101
+ warning: string;
102
+ warningLightBg: string;
103
+ neutral: string;
104
+ disabled: string;
105
+ disabledSecondaryLight: string;
106
+ disabledSecondary: string;
107
+ disabledDark: string;
108
+ defaultDark: string;
109
+ defaultDarkest: string;
110
+ darkNetural300: string;
111
+ darkGrey: string;
112
+ transparent: string;
113
+ secondary2: string;
114
+ gray500: string;
115
+ mintCream: string;
116
+ pinaColada100: string;
117
+ lightCyan: string;
118
+ margarita100: string;
119
+ neutral300: string;
120
+ orange200: string;
121
+ couponGreen: string;
122
+ black100: string;
123
+ orange100: string;
124
+ lightRed: string;
125
+ neutral100: string;
126
+ };
127
+ border: {
128
+ primary: string;
129
+ secondary: string;
130
+ tertiary: string;
131
+ brand: string;
132
+ neutral: string;
133
+ link: string;
134
+ default: string;
135
+ defaultDark: string;
136
+ disabled: string;
137
+ disabledDark: string;
138
+ warning: string;
139
+ divider: string;
140
+ disabled100: string;
141
+ borderAccent: string;
142
+ neutral100: string;
143
+ bluePrimary500: string;
144
+ lightGray: string;
145
+ darkRed: string;
146
+ };
147
+ spinner: {
148
+ primary: string;
149
+ primaryBg: string;
150
+ };
151
+ shimmer: {
152
+ disabledLight: string;
153
+ disabledDark: string;
154
+ };
155
+ counter: {
156
+ enabled: {
157
+ stroke: string;
158
+ };
159
+ disabled: {
160
+ stroke: string;
161
+ };
162
+ };
163
+ coupon: {
164
+ primaryBg: string;
165
+ };
166
+ alert: {
167
+ success: string;
168
+ warning: string;
169
+ warningLight: string;
170
+ error: string;
171
+ info: string;
172
+ neutral: string;
173
+ };
174
+ badge: {
175
+ curacao: string;
176
+ curacao900: string;
177
+ pinaColada: string;
178
+ pinaColada300: string;
179
+ margarita250: string;
180
+ default: string;
181
+ green: string;
182
+ green100: string;
183
+ margarita100: string;
184
+ yellow: string;
185
+ orange100: string;
186
+ orange250: string;
187
+ orange500: string;
188
+ red: string;
189
+ red100: string;
190
+ green500: string;
191
+ green600: string;
192
+ purple100: string;
193
+ purple250: string;
194
+ gray100: string;
195
+ gray250: string;
196
+ aqua100: string;
197
+ aqua250: string;
198
+ black: string;
199
+ link: string;
200
+ blue100: string;
201
+ blue900: string;
202
+ blue500: string;
203
+ neutral100: string;
204
+ neutral700: string;
205
+ pinaColada750: string;
206
+ pinaColada100: string;
207
+ gray800: string;
208
+ couponGreen: string;
209
+ alert500: string;
210
+ alertSoft: string;
211
+ red200: string;
212
+ red500: string;
213
+ redSoft: string;
214
+ brown: string;
215
+ };
216
+ calendar: {
217
+ accent: string;
218
+ background: string;
219
+ selected: string;
220
+ };
221
+ cursor: {
222
+ neutral900: string;
223
+ };
224
+ chipicon: {
225
+ default: string;
226
+ blue: string;
227
+ pink: string;
228
+ yellow: string;
229
+ purple: string;
230
+ green: string;
231
+ cfwBlue: string;
232
+ orange: string;
233
+ };
234
+ };
235
+ elevation: Elevation;
236
+ border: Border;
237
+ spacing: Spacing;
238
+ typography: Typography;
239
+ size: Size;
240
+ transitions: {
241
+ easing: {
242
+ easeInOut: string;
243
+ easeOut: string;
244
+ easeIn: string;
245
+ sharp: string;
246
+ };
247
+ duration: {
248
+ shortest: number;
249
+ shorter: number;
250
+ short: number;
251
+ standard: number;
252
+ complex: number;
253
+ enteringScreen: number;
254
+ leavingScreen: number;
255
+ };
256
+ getAutoHeightDuration: (height: number) => number;
257
+ create: (
258
+ props: string[],
259
+ options: {
260
+ duration?: number | string;
261
+ easing?: string;
262
+ delay?: number | string;
263
+ },
264
+ ) => string;
265
+ };
266
+ zIndex: Record<
267
+ 'modal' | 'drawer' | 'tooltip' | 'popOver' | 'sideNav' | 'toolbar' | 'bottomSheet' | 'pageLoader',
268
+ number
269
+ >;
270
+ };
271
+
272
+ export type ThemeType = 'B2C' | 'B2B' | 'FK' | 'SM';
@@ -0,0 +1,36 @@
1
+ import { Theme as ThemeType } from '../themes/index';
2
+ import B2CTheme from '../themes/B2CTheme';
3
+
4
+ class ThemeManagerClass {
5
+ static instance: ThemeManagerClass;
6
+ private theme: ThemeType;
7
+
8
+ constructor() {
9
+ if (ThemeManagerClass.instance) {
10
+ throw new Error('You can only create one instance!');
11
+ }
12
+ ThemeManagerClass.instance = this;
13
+ /**
14
+ * 1.) Default theme (Ultra, Light Mode, Dark Mode)
15
+ * 2.) Build time theme
16
+ */
17
+ this.theme = B2CTheme;
18
+ }
19
+
20
+ set(theme: string) {
21
+ switch (theme) {
22
+ case 'B2C':
23
+ default: {
24
+ this.theme = B2CTheme;
25
+ break;
26
+ }
27
+ }
28
+ }
29
+
30
+ get() {
31
+ return this.theme;
32
+ }
33
+ }
34
+
35
+ const ThemeManager = Object.freeze(new ThemeManagerClass());
36
+ export default ThemeManager;
@@ -0,0 +1,21 @@
1
+ import { B2BTheme, B2CTheme, Theme, ThemeType, FKTheme, SMTheme } from '../themes';
2
+
3
+ export const getTheme = (themeType: ThemeType): Theme => {
4
+ switch (themeType) {
5
+ case 'B2C': {
6
+ return B2CTheme;
7
+ }
8
+ case 'B2B': {
9
+ return B2BTheme;
10
+ }
11
+ case 'FK': {
12
+ return FKTheme;
13
+ }
14
+ case 'SM': {
15
+ return SMTheme;
16
+ }
17
+ default: {
18
+ return B2CTheme;
19
+ }
20
+ }
21
+ };