@cleartrip/ct-design-theme 4.0.0-TEST.1 → 4.0.0-rc

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 (38) 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/ct-design-theme.browser.cjs.js +1 -1
  6. package/dist/ct-design-theme.browser.cjs.js.map +1 -1
  7. package/dist/ct-design-theme.browser.esm.js +1 -1
  8. package/dist/ct-design-theme.browser.esm.js.map +1 -1
  9. package/dist/ct-design-theme.cjs.js +114 -128
  10. package/dist/ct-design-theme.cjs.js.map +1 -1
  11. package/dist/ct-design-theme.esm.js +114 -128
  12. package/dist/ct-design-theme.esm.js.map +1 -1
  13. package/dist/ct-design-theme.umd.js +148 -192
  14. package/dist/ct-design-theme.umd.js.map +1 -1
  15. package/dist/themes/B2CTheme.d.ts +6 -64
  16. package/dist/themes/B2CTheme.d.ts.map +1 -1
  17. package/dist/themes/BaseTheme.d.ts.map +1 -1
  18. package/dist/themes/type.d.ts +3 -4
  19. package/dist/themes/type.d.ts.map +1 -1
  20. package/dist/utils/index.d.ts.map +1 -1
  21. package/package.json +8 -4
  22. package/src/ThemeProvider/ThemeProvider.native.tsx +20 -0
  23. package/src/ThemeProvider/ThemeProvider.tsx +29 -0
  24. package/src/ThemeProvider/index.ts +3 -0
  25. package/src/ThemeProvider/type.ts +15 -0
  26. package/src/hooks/index.ts +2 -0
  27. package/src/hooks/useTheme.ts +11 -0
  28. package/src/hooks/useThemeContext.ts +8 -0
  29. package/src/index.ts +5 -0
  30. package/src/themes/B2BTheme.ts +94 -0
  31. package/src/themes/B2CTheme.ts +5 -0
  32. package/src/themes/BaseTheme.ts +308 -0
  33. package/src/themes/SMTheme.ts +86 -0
  34. package/src/themes/UltraFkTheme.ts +93 -0
  35. package/src/themes/index.ts +7 -0
  36. package/src/themes/type.ts +233 -0
  37. package/src/utils/ThemeManager.ts +36 -0
  38. package/src/utils/index.ts +21 -0
@@ -0,0 +1,308 @@
1
+ import { colors, border, typography, spacing, size, elevation } from '@cleartrip/ct-design-tokens';
2
+ import { Theme } from './type';
3
+
4
+ // inspired from chakra UI
5
+ export const duration = {
6
+ shortest: 150,
7
+ shorter: 200,
8
+ short: 250,
9
+ // most basic recommended timing
10
+ standard: 300,
11
+ // this is to be used in complex animations
12
+ complex: 375,
13
+ // recommended when something is entering screen
14
+ enteringScreen: 225,
15
+ // recommended when something is leaving screen
16
+ leavingScreen: 195,
17
+ };
18
+
19
+ // inspired from chakra UI
20
+ export const easing = {
21
+ // This is the most common easing curve.
22
+ easeInOut: 'cubic-bezier(0.4, 0, 0.2, 1)',
23
+ // Objects enter the screen at full velocity from off-screen and
24
+ // slowly decelerate to a resting point.
25
+ easeOut: 'cubic-bezier(0.0, 0, 0.2, 1)',
26
+ // Objects leave the screen at full velocity. They do not decelerate when off-screen.
27
+ easeIn: 'cubic-bezier(0.4, 0, 1, 1)',
28
+ // The sharp curve is used by objects that may return to the screen at any time.
29
+ sharp: 'cubic-bezier(0.4, 0, 0.6, 1)',
30
+ };
31
+
32
+ function getAutoHeightDuration(height: number) {
33
+ if (!height) {
34
+ return 0;
35
+ }
36
+
37
+ const constant = height / 36;
38
+
39
+ // https://www.wolframalpha.com/input/?i=(4+%2B+15+*+(x+%2F+36+)+**+0.25+%2B+(x+%2F+36)+%2F+5)+*+10
40
+ return Math.round((4 + 15 * constant ** 0.25 + constant / 5) * 10);
41
+ }
42
+
43
+ const create = (props = ['all'], options: unknown = {}) => {
44
+ // @ts-ignore
45
+ const { duration: durationOption = duration.standard, easing: easingOption = easing.easeInOut, delay = 0 } = options;
46
+ return (Array.isArray(props) ? props : [props])
47
+ .map(
48
+ (animatedProp) =>
49
+ `${animatedProp} ${
50
+ typeof durationOption === 'string' ? durationOption : `${durationOption}ms`
51
+ } ${easingOption} ${typeof delay === 'string' ? delay : `${delay}ms`}`,
52
+ )
53
+ .join(',');
54
+ };
55
+
56
+ const hover = (key: string) => {
57
+ const bg = {
58
+ [colors.neutral100]: colors.neutral100,
59
+ [colors.neutral900]: colors.neutral900,
60
+ [colors.neutral900]: colors.neutral900,
61
+ [colors.neutral100]: colors.neutral100,
62
+ [colors.brand]: colors.bgPrimaryHover,
63
+ [colors.neutral100]: colors.neutral100,
64
+ [colors.disabledText]: colors.disabledText,
65
+ [colors.neutral300]: colors.neutral300,
66
+ [colors.neutral100]: colors.neutral100,
67
+ [colors.link2]: colors.link2Hover,
68
+ [colors.neutral100]: colors.neutral100,
69
+ [colors.neutral900]: colors.neutral900,
70
+ [colors.neutral100]: colors.neutral100,
71
+ [colors.disabledText]: colors.disabledText,
72
+ [colors.neutral300]: colors.neutral300,
73
+ };
74
+ return bg[key];
75
+ };
76
+
77
+ const zIndex = {
78
+ drawer: 1200,
79
+ modal: 1300,
80
+ popOver: 1300,
81
+ tooltip: 1500,
82
+ sideNav: 100,
83
+ toolbar: 50,
84
+ bottomSheet: 100,
85
+ };
86
+
87
+ const counter = {
88
+ enabled: {
89
+ stroke: colors.neutral900,
90
+ },
91
+ disabled: {
92
+ stroke: colors.neutral500,
93
+ },
94
+ };
95
+
96
+ const BaseTheme: Theme = {
97
+ color: {
98
+ text: {
99
+ primary: colors.neutral900,
100
+ secondary: colors.brandText,
101
+ tertiary: colors.neutral500,
102
+ heading: colors.neutral900,
103
+ subHeading: colors.neutral700,
104
+ disabled: colors.disabledText,
105
+ success: colors.successText,
106
+ alert: colors.alertText,
107
+ alert500: colors.alert500,
108
+ warning: colors.warningText,
109
+ link: colors.linkText,
110
+ brand: colors.brandText,
111
+ neutral: colors.neutral100,
112
+ link2: colors.link2,
113
+ margarita: colors.margarita750,
114
+ primary2: colors.grapetini900,
115
+ secondary2: colors.blue100,
116
+ grapetini900: colors.grapetini900,
117
+ pinaColada750: colors.pinaColada750,
118
+ neutral50: colors.neutral50,
119
+ coralpink: colors.coralpink,
120
+ },
121
+ button: {
122
+ outlinedPrimaryLabel: colors.neutral900,
123
+ outlinedPrimaryBorder: colors.neutral900,
124
+ outlinedPrimaryBg: colors.neutral100,
125
+ outlinedSecondaryLabel: colors.brand,
126
+ outlinedSecondaryBorder: colors.brand,
127
+ outlinedSecondaryBg: colors.neutral100,
128
+ outlinedTertiaryLabel: colors.link,
129
+ outlinedTertiaryBorder: colors.link,
130
+ outlinedTertiaryBg: colors.neutral100,
131
+ outlinedNeutralLabel: colors.neutral100,
132
+ outlinedNeutralBorder: colors.neutral100,
133
+ outlinedNeutralBg: colors.transparent,
134
+ outlinedDisabledLabel: colors.disabledText,
135
+ outlinedDisabledBg: colors.neutral300,
136
+ containedPrimaryLabel: colors.neutral100,
137
+ containedPrimaryBg: colors.neutral900,
138
+ containedSecondaryLabel: colors.neutral100,
139
+ containedSecondaryBg: colors.brand,
140
+ containedTertiaryLabel: colors.neutral100,
141
+ containedTertiaryBg: colors.link,
142
+ containedDisabledLabel: colors.disabledText,
143
+ containedDisabledBg: colors.neutral300,
144
+ containedNeutralLabel: colors.neutral900,
145
+ containedNeutralBg: colors.neutral100,
146
+ hover,
147
+ },
148
+ chip: {
149
+ nonSelectedPrimaryLabel: colors.neutral900,
150
+ disabledPrimaryLabel: colors.disabledText,
151
+ selectedPrimaryLabel: colors.neutral900,
152
+ selectedPrimaryBorder: colors.neutral900,
153
+ selectedPrimaryBg: colors.neutral300,
154
+ disabledPrimaryBg: colors.neutral100,
155
+ },
156
+ dropdown: {
157
+ shadow: colors.shadow,
158
+ },
159
+ tab: {
160
+ nonSelectedPrimaryLabel: colors.neutral700,
161
+ selectedPrimaryLabel: colors.neutral900,
162
+ },
163
+ sidenav: {
164
+ primaryBg: colors.neutral900,
165
+ selectedTabBg: colors.highlightBg,
166
+ },
167
+ tooltip: {
168
+ primaryBg: colors.neutral900,
169
+ },
170
+ background: {
171
+ primary: colors.neutral900,
172
+ secondary: colors.brand,
173
+ tertiary: colors.link,
174
+ brand: colors.brand,
175
+ brandLightBg: colors.brandBg,
176
+ link: colors.link,
177
+ link2: colors.link2,
178
+ linkLightBg: colors.linkBg,
179
+ success: colors.success,
180
+ successLightBg: colors.successBg,
181
+ alert: colors.alert,
182
+ alertLightBg: colors.alertBg,
183
+ alertSoft: colors.alert100,
184
+ warning: colors.warning,
185
+ warningLightBg: colors.warningBg,
186
+ neutral: colors.neutral100,
187
+ disabled: colors.neutral300,
188
+ disabledSecondaryLight: colors.neutral350,
189
+ disabledSecondary: colors.neutral400,
190
+ disabledDark: colors.disabled100,
191
+ defaultDark: colors.neutral700,
192
+ defaultDarkest: colors.neutral900,
193
+ grey: colors.neutral500,
194
+ secondary2: colors.blue100,
195
+ sandGrey100: colors.sandGrey100,
196
+ },
197
+ border: {
198
+ primary: colors.neutral900,
199
+ secondary: colors.brand,
200
+ tertiary: colors.link,
201
+ brand: colors.brand,
202
+ neutral: colors.neutral900,
203
+ link: colors.link,
204
+ default: colors.line,
205
+ defaultDark: colors.neutral700,
206
+ disabled: colors.neutral500,
207
+ disabledDark: colors.disabled100,
208
+ warning: colors.warning,
209
+ divider: colors.neutral300,
210
+ },
211
+ spinner: {
212
+ primary: colors.neutral700,
213
+ primaryBg: colors.alertBg,
214
+ },
215
+ shimmer: {
216
+ disabledLight: colors.disabledLight,
217
+ disabledDark: colors.disabled250,
218
+ },
219
+ coupon: {
220
+ primaryBg: colors.blue100,
221
+ },
222
+ alert: {
223
+ success: colors.successBg,
224
+ warning: colors.alertBg,
225
+ info: colors.blue100,
226
+ error: colors.orange100,
227
+ neutral: colors.neutral100,
228
+ },
229
+ badge: {
230
+ curacao: colors.curacao250,
231
+ curacao900: colors.curacao900,
232
+ pinaColada: colors.pinaColada250,
233
+ margarita250: colors.margarita250,
234
+ default: colors.neutral300,
235
+ green: colors.successBg,
236
+ margarita100: colors.margarita100,
237
+ yellow: colors.alertBg,
238
+ orange100: colors.orange100,
239
+ orange250: colors.orange250,
240
+ orange500: colors.orange500,
241
+ red: colors.warningBg,
242
+ green500: colors.success500,
243
+ green600: colors.success600,
244
+ purple100: colors.purple100,
245
+ purple250: colors.purple250,
246
+ gray100: colors.gray100,
247
+ gray250: colors.gray250,
248
+ aqua100: colors.aqua100,
249
+ aqua250: colors.aqua250,
250
+ black: colors.black,
251
+ link: colors.link,
252
+ linkText: colors.linkText,
253
+ blue100: colors.blue100,
254
+ blue500: colors.blue500,
255
+ blue900: colors.blue900,
256
+ neutral100: colors.neutral100,
257
+ pinaColada750: colors.pinaColada750,
258
+ pinaColada100: colors.pinaColada100,
259
+ brown: colors.brown,
260
+ },
261
+ counter,
262
+ calendar: {
263
+ accent: colors.neutral900,
264
+ background: colors.neutral300,
265
+ selected: colors.neutral900,
266
+ },
267
+ },
268
+ elevation: { ...elevation },
269
+ border: {
270
+ ...border,
271
+ },
272
+ spacing: {
273
+ ...spacing,
274
+ },
275
+ typography: {
276
+ ...typography,
277
+ },
278
+ size: {
279
+ ...size,
280
+ },
281
+ transitions: {
282
+ duration,
283
+ easing,
284
+ create,
285
+ getAutoHeightDuration,
286
+ },
287
+ underline: {
288
+ link: '',
289
+ primary: '',
290
+ secondary: '',
291
+ tertiary: '',
292
+ disabled: '',
293
+ heading: '',
294
+ subHeading: '',
295
+ success: '',
296
+ warning: '',
297
+ neutral: '',
298
+ link2: '',
299
+ primary2: '',
300
+ secondary2: '',
301
+ grapetini900: '',
302
+ pinaColada750: '',
303
+ alert: '',
304
+ },
305
+ zIndex,
306
+ };
307
+
308
+ export default BaseTheme;
@@ -0,0 +1,86 @@
1
+ import { Theme } from './type';
2
+ import { colors } from '@cleartrip/ct-design-tokens';
3
+ import BaseTheme from './BaseTheme';
4
+
5
+ const hover = (key: string) => {
6
+ const bg = {
7
+ [colors.neutral100]: colors.neutral100,
8
+ [colors.brand]: colors.bgPrimaryHover,
9
+ [colors.disabledText]: colors.disabledText,
10
+ [colors.neutral300]: colors.neutral300,
11
+ [colors.link2]: colors.link2Hover,
12
+ [colors.neutral100]: colors.neutral100,
13
+ [colors.neutral900]: colors.neutral900,
14
+ [colors.superGrey700]: colors.superGrey700,
15
+ [colors.superGrey300]: colors.superGrey300,
16
+ [colors.superGrey800]: colors.superGrey800,
17
+ [colors.superGreen500]: colors.superGreen500,
18
+ };
19
+ return bg[key];
20
+ };
21
+
22
+ const SMTheme: Theme = {
23
+ ...BaseTheme,
24
+ color: {
25
+ ...BaseTheme.color,
26
+ text: {
27
+ ...BaseTheme.color.text,
28
+ primary: colors.superGrey800,
29
+ secondary: colors.superGrey500,
30
+ tertiary: colors.superGrey400,
31
+ warning: colors.systemRed500,
32
+ disabled: colors.superGrey400,
33
+ subHeading: colors.superGrey400,
34
+ success: colors.systemGreen500,
35
+ link: colors.superBlue500,
36
+ link2: colors.superBlue500,
37
+ },
38
+ button: {
39
+ ...BaseTheme.color.button,
40
+ outlinedPrimaryLabel: colors.superGrey700,
41
+ outlinedPrimaryBorder: colors.superGrey300,
42
+ outlinedTertiaryLabel: colors.superGrey700,
43
+ outlinedTertiaryBorder: colors.superGrey300,
44
+ outlinedDisabledLabel: colors.disabledText,
45
+ containedSecondaryLabel: colors.superGrey800,
46
+ containedPrimaryBg: colors.superBlue500,
47
+ containedSecondaryBg: colors.superGreen500,
48
+ containedTertiaryLabel: colors.superGrey300,
49
+ containedDisabledLabel: colors.disabledText,
50
+ containedPrimaryLabel: colors.neutral100,
51
+ hover: hover,
52
+ },
53
+ chip: {
54
+ ...BaseTheme.color.chip,
55
+ selectedPrimaryLabel: colors.superBlue500,
56
+ selectedPrimaryBorder: colors.superBlue500,
57
+ selectedPrimaryBg: colors.superBlue25,
58
+ disabledPrimaryLabel: colors.superGrey400,
59
+ nonSelectedPrimaryLabel: colors.superGrey700,
60
+ disabledPrimaryBg: colors.superGrey200,
61
+ },
62
+ tab: {
63
+ ...BaseTheme.color.tab,
64
+ nonSelectedPrimaryLabel: colors.superGrey500,
65
+ selectedPrimaryLabel: colors.superBlue500,
66
+ },
67
+ background: {
68
+ ...BaseTheme.color.background,
69
+ primary: colors.superBlue500,
70
+ disabled: colors.superGrey50,
71
+ disabledDark: colors.superGrey300,
72
+ warning: colors.systemRed500,
73
+ },
74
+ border: {
75
+ ...BaseTheme.color.border,
76
+ primary: colors.superBlue500,
77
+ secondary: colors.neutral900,
78
+ disabledDark: colors.superGrey300,
79
+ defaultDark: colors.superGrey400,
80
+ default: colors.superGrey300,
81
+ disabled: colors.superGrey200,
82
+ },
83
+ },
84
+ };
85
+
86
+ export default SMTheme;
@@ -0,0 +1,93 @@
1
+ import { colors } from '@cleartrip/ct-design-tokens';
2
+
3
+ import { Theme } from './type';
4
+ import BaseTheme from './BaseTheme';
5
+
6
+ const hover = (key: string) => {
7
+ const bg = {
8
+ [colors.neutral100]: colors.neutral100,
9
+ [colors.neutral900]: colors.neutral900,
10
+ [colors.neutral900]: colors.neutral900,
11
+ [colors.neutral100]: colors.neutral100,
12
+ [colors.brand]: colors.bgPrimaryHover,
13
+ [colors.neutral100]: colors.neutral100,
14
+ [colors.disabledText]: colors.disabledText,
15
+ [colors.neutral300]: colors.neutral300,
16
+ [colors.neutral100]: colors.neutral100,
17
+ [colors.link2]: colors.link2Hover,
18
+ [colors.neutral100]: colors.neutral100,
19
+ [colors.neutral900]: colors.neutral900,
20
+ [colors.neutral100]: colors.neutral100,
21
+ [colors.disabledText]: colors.disabledText,
22
+ [colors.neutral300]: colors.neutral300,
23
+ [colors.bluePrimary500]: colors.bluePrimary500,
24
+ [colors.yellowSecondary]: colors.yellowSecondary,
25
+ };
26
+ return bg[key];
27
+ };
28
+
29
+ const counter = {
30
+ enabled: {
31
+ stroke: colors.bluePrimary500,
32
+ },
33
+ disabled: {
34
+ stroke: colors.neutral500,
35
+ },
36
+ };
37
+
38
+ const FKTheme: Theme = {
39
+ ...BaseTheme,
40
+ color: {
41
+ ...BaseTheme.color,
42
+ text: {
43
+ ...BaseTheme.color.text,
44
+ link: colors.bluePrimary500,
45
+ },
46
+ button: {
47
+ ...BaseTheme.color.button,
48
+ outlinedPrimaryLabel: colors.primaryNeutral900,
49
+ outlinedPrimaryBg: colors.neutral100,
50
+ containedPrimaryLabel: colors.neutral100,
51
+ containedPrimaryBg: colors.bluePrimary500,
52
+ containedSecondaryLabel: colors.primaryNeutral900,
53
+ containedSecondaryBg: colors.yellowSecondary,
54
+ hover: hover,
55
+ },
56
+ chip: {
57
+ ...BaseTheme.color.chip,
58
+ selectedPrimaryLabel: colors.link2,
59
+ selectedPrimaryBorder: colors.link2,
60
+ selectedPrimaryBg: colors.linkBg,
61
+ nonSelectedPrimaryLabel: colors.neutral900,
62
+ },
63
+ tab: {
64
+ ...BaseTheme.color.tab,
65
+ nonSelectedPrimaryLabel: colors.neutral900,
66
+ selectedPrimaryLabel: colors.bluePrimary500,
67
+ },
68
+ background: {
69
+ ...BaseTheme.color.background,
70
+ primary: colors.bluePrimary500,
71
+ secondary: colors.neutral900,
72
+ tertiary: colors.brand,
73
+ linkLightBg: colors.blueSecondary,
74
+ },
75
+ border: {
76
+ ...BaseTheme.color.border,
77
+ primary: colors.bluePrimary500,
78
+ brand: colors.bluePrimary500,
79
+ },
80
+ spinner: {
81
+ primary: colors.link2,
82
+ primaryBg: colors.alertBg,
83
+ },
84
+ counter,
85
+ calendar: {
86
+ accent: colors.bluePrimary500,
87
+ background: colors.blueSecondary,
88
+ selected: colors.bluePrimary500,
89
+ },
90
+ },
91
+ };
92
+
93
+ export default FKTheme;
@@ -0,0 +1,7 @@
1
+ export { default as B2CTheme } from './B2CTheme';
2
+ export { default as B2BTheme } from './B2BTheme';
3
+ export { default as FKTheme } from './UltraFkTheme';
4
+ export { default as BaseTheme } from './BaseTheme';
5
+ export { default as SMTheme } from './SMTheme';
6
+
7
+ export * from './type';