@cleartrip/ct-design-theme 4.0.0-SNAPSHOT-rnfinaltest.0 → 4.0.0-SNAPSHOT-rnfinaltest3.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 (34) hide show
  1. package/dist/ThemeProvider/ThemeProvider.d.ts +1 -0
  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 +1 -1
  10. package/dist/ct-design-theme.cjs.js.map +1 -1
  11. package/dist/ct-design-theme.esm.js +1 -1
  12. package/dist/ct-design-theme.esm.js.map +1 -1
  13. package/dist/ct-design-theme.umd.js +34 -34
  14. package/dist/ct-design-theme.umd.js.map +1 -1
  15. package/dist/themes/type.d.ts +0 -1
  16. package/dist/themes/type.d.ts.map +1 -1
  17. package/package.json +4 -3
  18. package/src/ThemeProvider/ThemeProvider.native.tsx +20 -0
  19. package/src/ThemeProvider/ThemeProvider.tsx +29 -0
  20. package/src/ThemeProvider/index.ts +3 -0
  21. package/src/ThemeProvider/type.ts +15 -0
  22. package/src/hooks/index.ts +2 -0
  23. package/src/hooks/useTheme.ts +11 -0
  24. package/src/hooks/useThemeContext.ts +8 -0
  25. package/src/index.ts +5 -0
  26. package/src/themes/B2BTheme.ts +94 -0
  27. package/src/themes/B2CTheme.ts +5 -0
  28. package/src/themes/BaseTheme.ts +308 -0
  29. package/src/themes/SMTheme.ts +86 -0
  30. package/src/themes/UltraFkTheme.ts +93 -0
  31. package/src/themes/index.ts +7 -0
  32. package/src/themes/type.ts +233 -0
  33. package/src/utils/ThemeManager.ts +36 -0
  34. package/src/utils/index.ts +21 -0
@@ -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';
@@ -0,0 +1,233 @@
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
+ alert500: string;
27
+ primary2: string;
28
+ secondary2: string;
29
+ grapetini900: string;
30
+ pinaColada750: string;
31
+ neutral50: string;
32
+ coralpink: string;
33
+ };
34
+ button: {
35
+ outlinedPrimaryLabel: string;
36
+ outlinedPrimaryBorder: string;
37
+ outlinedPrimaryBg: string;
38
+ outlinedSecondaryLabel: string;
39
+ outlinedSecondaryBorder: string;
40
+ outlinedSecondaryBg: string;
41
+ outlinedTertiaryLabel: string;
42
+ outlinedTertiaryBorder: string;
43
+ outlinedTertiaryBg: string;
44
+ outlinedNeutralLabel: string;
45
+ outlinedNeutralBorder: string;
46
+ outlinedNeutralBg: string;
47
+ outlinedDisabledLabel: string;
48
+ outlinedDisabledBg: string;
49
+ containedPrimaryLabel: string;
50
+ containedPrimaryBg: string;
51
+ containedSecondaryLabel: string;
52
+ containedSecondaryBg: string;
53
+ containedTertiaryLabel: string;
54
+ containedTertiaryBg: string;
55
+ containedDisabledLabel: string;
56
+ containedDisabledBg: string;
57
+ containedNeutralLabel: string;
58
+ containedNeutralBg: string;
59
+ hover: unknown;
60
+ };
61
+ chip: {
62
+ nonSelectedPrimaryLabel: string;
63
+ selectedPrimaryLabel: string;
64
+ selectedPrimaryBorder: string;
65
+ selectedPrimaryBg: string;
66
+ disabledPrimaryLabel: string;
67
+ disabledPrimaryBg: string;
68
+ };
69
+ dropdown: {
70
+ shadow: string;
71
+ };
72
+ tab: {
73
+ nonSelectedPrimaryLabel: string;
74
+ selectedPrimaryLabel: string;
75
+ };
76
+ sidenav: {
77
+ primaryBg: string;
78
+ selectedTabBg: string;
79
+ };
80
+ tooltip: {
81
+ primaryBg: string;
82
+ };
83
+ background: {
84
+ primary: string;
85
+ secondary: string;
86
+ tertiary: string;
87
+ brand: string;
88
+ brandLightBg: string;
89
+ link: string;
90
+ link2: string;
91
+ linkLightBg: string;
92
+ success: string;
93
+ successLightBg: string;
94
+ alert: string;
95
+ alertLightBg: string;
96
+ alertSoft: string;
97
+ warning: string;
98
+ warningLightBg: string;
99
+ neutral: string;
100
+ disabled: string;
101
+ disabledSecondaryLight: string;
102
+ disabledSecondary: string;
103
+ disabledDark: string;
104
+ defaultDark: string;
105
+ defaultDarkest: string;
106
+ grey: string;
107
+ secondary2: string;
108
+ sandGrey100: string;
109
+ };
110
+ border: {
111
+ primary: string;
112
+ secondary: string;
113
+ tertiary: string;
114
+ brand: string;
115
+ neutral: string;
116
+ link: string;
117
+ default: string;
118
+ defaultDark: string;
119
+ disabled: string;
120
+ disabledDark: string;
121
+ warning: string;
122
+ divider: string;
123
+ };
124
+ spinner: {
125
+ primary: string;
126
+ primaryBg: string;
127
+ };
128
+ shimmer: {
129
+ disabledLight: string;
130
+ disabledDark: string;
131
+ };
132
+ counter: {
133
+ enabled: {
134
+ stroke: string;
135
+ };
136
+ disabled: {
137
+ stroke: string;
138
+ };
139
+ };
140
+ coupon: {
141
+ primaryBg: string;
142
+ };
143
+ alert: {
144
+ success: string;
145
+ warning: string;
146
+ error: string;
147
+ info: string;
148
+ neutral: string;
149
+ };
150
+ badge: {
151
+ curacao: string;
152
+ curacao900: string;
153
+ pinaColada: string;
154
+ margarita250: string;
155
+ default: string;
156
+ green: string;
157
+ margarita100: string;
158
+ yellow: string;
159
+ orange100: string;
160
+ orange250: string;
161
+ orange500: string;
162
+ red: string;
163
+ green500: string;
164
+ green600: string;
165
+ purple100: string;
166
+ purple250: string;
167
+ gray100: string;
168
+ gray250: string;
169
+ aqua100: string;
170
+ aqua250: string;
171
+ black: string;
172
+ link: string;
173
+ linkText: string;
174
+ blue100: string;
175
+ blue500: string;
176
+ blue900: string;
177
+ neutral100: string;
178
+ pinaColada750: string;
179
+ pinaColada100: string;
180
+ brown: string;
181
+ };
182
+ calendar: {
183
+ accent: string;
184
+ background: string;
185
+ selected: string;
186
+ };
187
+ };
188
+ elevation: Elevation;
189
+ border: Border;
190
+ spacing: Spacing;
191
+ typography: Typography;
192
+ size: Size;
193
+ transitions: {
194
+ easing: {
195
+ easeInOut: string;
196
+ easeOut: string;
197
+ easeIn: string;
198
+ sharp: string;
199
+ };
200
+ duration: {
201
+ shortest: number;
202
+ shorter: number;
203
+ short: number;
204
+ standard: number;
205
+ complex: number;
206
+ enteringScreen: number;
207
+ leavingScreen: number;
208
+ };
209
+ getAutoHeightDuration: unknown;
210
+ create: unknown;
211
+ };
212
+ zIndex: Record<'modal' | 'drawer' | 'tooltip' | 'popOver' | 'sideNav' | 'toolbar' | 'bottomSheet', number>;
213
+ underline: {
214
+ link: UnderlineType;
215
+ primary: UnderlineType;
216
+ secondary: UnderlineType;
217
+ tertiary: UnderlineType;
218
+ disabled: UnderlineType;
219
+ heading: UnderlineType;
220
+ subHeading: UnderlineType;
221
+ success: UnderlineType;
222
+ warning: UnderlineType;
223
+ neutral: UnderlineType;
224
+ link2: UnderlineType;
225
+ primary2: UnderlineType;
226
+ secondary2: UnderlineType;
227
+ grapetini900: UnderlineType;
228
+ pinaColada750: UnderlineType;
229
+ alert: UnderlineType;
230
+ };
231
+ };
232
+
233
+ 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
+ };