@open-tender/utils 0.4.31 → 0.4.33
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/LICENSE.md +21 -21
- package/README.md +2 -2
- package/dist/cjs/__tests__/utils/helpers.test.d.ts +1 -1
- package/dist/cjs/__tests__/utils/helpers.test.js +96 -96
- package/dist/cjs/__tests__/utils/theme.test.d.ts +1 -1
- package/dist/cjs/__tests__/utils/theme.test.js +37 -37
- package/dist/cjs/hooks/index.d.ts +35 -35
- package/dist/cjs/hooks/index.js +38 -38
- package/dist/cjs/hooks/types.d.ts +4 -4
- package/dist/cjs/hooks/types.js +2 -2
- package/dist/cjs/hooks/useAccordion.d.ts +22 -22
- package/dist/cjs/hooks/useAccordion.js +56 -56
- package/dist/cjs/hooks/useAddressForm.d.ts +12 -12
- package/dist/cjs/hooks/useAddressForm.js +83 -83
- package/dist/cjs/hooks/useAllergenForm.d.ts +10 -10
- package/dist/cjs/hooks/useAllergenForm.js +58 -58
- package/dist/cjs/hooks/useBuilder.d.ts +14 -14
- package/dist/cjs/hooks/useBuilder.js +144 -144
- package/dist/cjs/hooks/useCartGuestForm.d.ts +12 -12
- package/dist/cjs/hooks/useCartGuestForm.js +58 -58
- package/dist/cjs/hooks/useCartPoints.d.ts +13 -13
- package/dist/cjs/hooks/useCartPoints.js +74 -74
- package/dist/cjs/hooks/useCommunicationPreferences.js +1 -1
- package/dist/cjs/hooks/useCreditCard.d.ts +13 -13
- package/dist/cjs/hooks/useCreditCard.js +63 -63
- package/dist/cjs/hooks/useCreditCardForm.d.ts +10 -10
- package/dist/cjs/hooks/useCreditCardForm.js +71 -71
- package/dist/cjs/hooks/useCurbside.d.ts +9 -9
- package/dist/cjs/hooks/useCurbside.js +39 -39
- package/dist/cjs/hooks/useDineInForm.d.ts +11 -11
- package/dist/cjs/hooks/useDineInForm.js +56 -56
- package/dist/cjs/hooks/useDonationForm.d.ts +28 -28
- package/dist/cjs/hooks/useDonationForm.js +172 -172
- package/dist/cjs/hooks/useFirstTimes.d.ts +18 -18
- package/dist/cjs/hooks/useFirstTimes.js +81 -81
- package/dist/cjs/hooks/useGiftCardAssignForm.d.ts +14 -14
- package/dist/cjs/hooks/useGiftCardAssignForm.js +57 -57
- package/dist/cjs/hooks/useGiftCardAssignOtherForm.d.ts +14 -14
- package/dist/cjs/hooks/useGiftCardAssignOtherForm.js +50 -50
- package/dist/cjs/hooks/useGiftCardForm.d.ts +12 -12
- package/dist/cjs/hooks/useGiftCardForm.js +74 -74
- package/dist/cjs/hooks/useGiftCardsForm.d.ts +31 -31
- package/dist/cjs/hooks/useGiftCardsForm.js +195 -195
- package/dist/cjs/hooks/useGuestCheckoutForm.d.ts +21 -21
- package/dist/cjs/hooks/useGuestCheckoutForm.js +89 -89
- package/dist/cjs/hooks/useGuestForm.d.ts +12 -12
- package/dist/cjs/hooks/useGuestForm.js +60 -60
- package/dist/cjs/hooks/useImage.d.ts +5 -5
- package/dist/cjs/hooks/useImage.js +33 -33
- package/dist/cjs/hooks/useLoginForm.d.ts +12 -12
- package/dist/cjs/hooks/useLoginForm.js +67 -67
- package/dist/cjs/hooks/useMenuItem.d.ts +57 -57
- package/dist/cjs/hooks/useMenuItem.js +67 -67
- package/dist/cjs/hooks/useModifier.d.ts +53 -53
- package/dist/cjs/hooks/useModifier.js +72 -72
- package/dist/cjs/hooks/useModifierGroup.d.ts +15 -15
- package/dist/cjs/hooks/useModifierGroup.js +17 -17
- package/dist/cjs/hooks/useOneTimePasscodeForm.d.ts +16 -16
- package/dist/cjs/hooks/useOneTimePasscodeForm.js +87 -87
- package/dist/cjs/hooks/useOrderFulfillmentForm.d.ts +11 -11
- package/dist/cjs/hooks/useOrderFulfillmentForm.js +65 -65
- package/dist/cjs/hooks/useOrderItem.d.ts +48 -48
- package/dist/cjs/hooks/useOrderItem.js +54 -54
- package/dist/cjs/hooks/useOrderRating.d.ts +10 -10
- package/dist/cjs/hooks/useOrderRating.js +34 -34
- package/dist/cjs/hooks/useOrderRatingForm.d.ts +11 -11
- package/dist/cjs/hooks/useOrderRatingForm.js +35 -35
- package/dist/cjs/hooks/useProfileForm.d.ts +15 -15
- package/dist/cjs/hooks/useProfileForm.js +116 -116
- package/dist/cjs/hooks/useResetPasswordForm.d.ts +12 -12
- package/dist/cjs/hooks/useResetPasswordForm.js +77 -77
- package/dist/cjs/hooks/useSendResetForm.d.ts +14 -14
- package/dist/cjs/hooks/useSendResetForm.js +57 -57
- package/dist/cjs/hooks/useSignUpForm.d.ts +20 -20
- package/dist/cjs/hooks/useSignUpForm.js +160 -151
- package/dist/cjs/hooks/useSignUpGuestForm.d.ts +23 -23
- package/dist/cjs/hooks/useSignUpGuestForm.js +124 -113
- package/dist/cjs/hooks/useSigninForm.d.ts +12 -12
- package/dist/cjs/hooks/useSigninForm.js +66 -66
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/utils/cards.d.ts +20 -20
- package/dist/cjs/utils/cards.js +155 -155
- package/dist/cjs/utils/cart.d.ts +202 -202
- package/dist/cjs/utils/cart.js +909 -909
- package/dist/cjs/utils/checkout.d.ts +55 -55
- package/dist/cjs/utils/checkout.js +125 -125
- package/dist/cjs/utils/constants.d.ts +43 -43
- package/dist/cjs/utils/constants.js +58 -58
- package/dist/cjs/utils/customer.d.ts +4 -4
- package/dist/cjs/utils/customer.js +34 -34
- package/dist/cjs/utils/datetimes.d.ts +99 -99
- package/dist/cjs/utils/datetimes.js +601 -601
- package/dist/cjs/utils/errors.d.ts +51 -51
- package/dist/cjs/utils/errors.js +191 -191
- package/dist/cjs/utils/favorites.d.ts +10 -10
- package/dist/cjs/utils/favorites.js +119 -119
- package/dist/cjs/utils/googleMaps.d.ts +14 -14
- package/dist/cjs/utils/googleMaps.js +30 -30
- package/dist/cjs/utils/helpers.d.ts +63 -63
- package/dist/cjs/utils/helpers.js +244 -244
- package/dist/cjs/utils/index.d.ts +19 -19
- package/dist/cjs/utils/index.js +23 -23
- package/dist/cjs/utils/keypad.d.ts +9 -9
- package/dist/cjs/utils/keypad.js +105 -105
- package/dist/cjs/utils/maps.d.ts +226 -226
- package/dist/cjs/utils/maps.js +334 -334
- package/dist/cjs/utils/menu.d.ts +117 -117
- package/dist/cjs/utils/menu.js +82 -82
- package/dist/cjs/utils/orders.d.ts +21 -21
- package/dist/cjs/utils/orders.js +202 -202
- package/dist/cjs/utils/pizzaBuilder.d.ts +10 -10
- package/dist/cjs/utils/pizzaBuilder.js +43 -43
- package/dist/cjs/utils/refunds.d.ts +35 -35
- package/dist/cjs/utils/refunds.js +98 -98
- package/dist/cjs/utils/revenueCenters.d.ts +11 -11
- package/dist/cjs/utils/revenueCenters.js +125 -125
- package/dist/cjs/utils/rewards.d.ts +4 -4
- package/dist/cjs/utils/rewards.js +106 -106
- package/dist/cjs/utils/theme.d.ts +27 -27
- package/dist/cjs/utils/theme.js +266 -266
- package/dist/cjs/utils/version.d.ts +4 -4
- package/dist/cjs/utils/version.js +38 -38
- package/dist/esm/__tests__/utils/helpers.test.d.ts +1 -1
- package/dist/esm/__tests__/utils/helpers.test.js +94 -94
- package/dist/esm/__tests__/utils/theme.test.d.ts +1 -1
- package/dist/esm/__tests__/utils/theme.test.js +35 -35
- package/dist/esm/hooks/index.d.ts +35 -35
- package/dist/esm/hooks/index.js +35 -35
- package/dist/esm/hooks/types.d.ts +4 -4
- package/dist/esm/hooks/types.js +1 -1
- package/dist/esm/hooks/useAccordion.d.ts +22 -22
- package/dist/esm/hooks/useAccordion.js +52 -52
- package/dist/esm/hooks/useAddressForm.d.ts +12 -12
- package/dist/esm/hooks/useAddressForm.js +79 -79
- package/dist/esm/hooks/useAllergenForm.d.ts +10 -10
- package/dist/esm/hooks/useAllergenForm.js +54 -54
- package/dist/esm/hooks/useBuilder.d.ts +14 -14
- package/dist/esm/hooks/useBuilder.js +140 -140
- package/dist/esm/hooks/useCartGuestForm.d.ts +12 -12
- package/dist/esm/hooks/useCartGuestForm.js +54 -54
- package/dist/esm/hooks/useCartPoints.d.ts +13 -13
- package/dist/esm/hooks/useCartPoints.js +70 -70
- package/dist/esm/hooks/useCommunicationPreferences.js +1 -1
- package/dist/esm/hooks/useCreditCard.d.ts +13 -13
- package/dist/esm/hooks/useCreditCard.js +59 -59
- package/dist/esm/hooks/useCreditCardForm.d.ts +10 -10
- package/dist/esm/hooks/useCreditCardForm.js +67 -67
- package/dist/esm/hooks/useCurbside.d.ts +9 -9
- package/dist/esm/hooks/useCurbside.js +35 -35
- package/dist/esm/hooks/useDineInForm.d.ts +11 -11
- package/dist/esm/hooks/useDineInForm.js +52 -52
- package/dist/esm/hooks/useDonationForm.d.ts +28 -28
- package/dist/esm/hooks/useDonationForm.js +168 -168
- package/dist/esm/hooks/useFirstTimes.d.ts +18 -18
- package/dist/esm/hooks/useFirstTimes.js +77 -77
- package/dist/esm/hooks/useGiftCardAssignForm.d.ts +14 -14
- package/dist/esm/hooks/useGiftCardAssignForm.js +53 -53
- package/dist/esm/hooks/useGiftCardAssignOtherForm.d.ts +14 -14
- package/dist/esm/hooks/useGiftCardAssignOtherForm.js +46 -46
- package/dist/esm/hooks/useGiftCardForm.d.ts +12 -12
- package/dist/esm/hooks/useGiftCardForm.js +70 -70
- package/dist/esm/hooks/useGiftCardsForm.d.ts +31 -31
- package/dist/esm/hooks/useGiftCardsForm.js +191 -191
- package/dist/esm/hooks/useGuestCheckoutForm.d.ts +21 -21
- package/dist/esm/hooks/useGuestCheckoutForm.js +85 -85
- package/dist/esm/hooks/useGuestForm.d.ts +12 -12
- package/dist/esm/hooks/useGuestForm.js +56 -56
- package/dist/esm/hooks/useImage.d.ts +5 -5
- package/dist/esm/hooks/useImage.js +29 -29
- package/dist/esm/hooks/useLoginForm.d.ts +12 -12
- package/dist/esm/hooks/useLoginForm.js +63 -63
- package/dist/esm/hooks/useMenuItem.d.ts +57 -57
- package/dist/esm/hooks/useMenuItem.js +63 -63
- package/dist/esm/hooks/useModifier.d.ts +53 -53
- package/dist/esm/hooks/useModifier.js +68 -68
- package/dist/esm/hooks/useModifierGroup.d.ts +15 -15
- package/dist/esm/hooks/useModifierGroup.js +13 -13
- package/dist/esm/hooks/useOneTimePasscodeForm.d.ts +16 -16
- package/dist/esm/hooks/useOneTimePasscodeForm.js +83 -83
- package/dist/esm/hooks/useOrderFulfillmentForm.d.ts +11 -11
- package/dist/esm/hooks/useOrderFulfillmentForm.js +61 -61
- package/dist/esm/hooks/useOrderItem.d.ts +48 -48
- package/dist/esm/hooks/useOrderItem.js +50 -50
- package/dist/esm/hooks/useOrderRating.d.ts +10 -10
- package/dist/esm/hooks/useOrderRating.js +30 -30
- package/dist/esm/hooks/useOrderRatingForm.d.ts +11 -11
- package/dist/esm/hooks/useOrderRatingForm.js +31 -31
- package/dist/esm/hooks/useProfileForm.d.ts +15 -15
- package/dist/esm/hooks/useProfileForm.js +112 -112
- package/dist/esm/hooks/useResetPasswordForm.d.ts +12 -12
- package/dist/esm/hooks/useResetPasswordForm.js +73 -73
- package/dist/esm/hooks/useSendResetForm.d.ts +14 -14
- package/dist/esm/hooks/useSendResetForm.js +53 -53
- package/dist/esm/hooks/useSignUpForm.d.ts +20 -20
- package/dist/esm/hooks/useSignUpForm.js +156 -147
- package/dist/esm/hooks/useSignUpGuestForm.d.ts +23 -23
- package/dist/esm/hooks/useSignUpGuestForm.js +120 -109
- package/dist/esm/hooks/useSigninForm.d.ts +12 -12
- package/dist/esm/hooks/useSigninForm.js +62 -62
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/utils/cards.d.ts +20 -20
- package/dist/esm/utils/cards.js +146 -146
- package/dist/esm/utils/cart.d.ts +202 -202
- package/dist/esm/utils/cart.js +868 -868
- package/dist/esm/utils/checkout.d.ts +55 -55
- package/dist/esm/utils/checkout.js +117 -117
- package/dist/esm/utils/constants.d.ts +43 -43
- package/dist/esm/utils/constants.js +55 -55
- package/dist/esm/utils/customer.d.ts +4 -4
- package/dist/esm/utils/customer.js +29 -29
- package/dist/esm/utils/datetimes.d.ts +99 -99
- package/dist/esm/utils/datetimes.js +531 -531
- package/dist/esm/utils/errors.d.ts +51 -51
- package/dist/esm/utils/errors.js +180 -180
- package/dist/esm/utils/favorites.d.ts +10 -10
- package/dist/esm/utils/favorites.js +109 -109
- package/dist/esm/utils/googleMaps.d.ts +14 -14
- package/dist/esm/utils/googleMaps.js +26 -26
- package/dist/esm/utils/helpers.d.ts +63 -63
- package/dist/esm/utils/helpers.js +205 -205
- package/dist/esm/utils/index.d.ts +19 -19
- package/dist/esm/utils/index.js +20 -20
- package/dist/esm/utils/keypad.d.ts +9 -9
- package/dist/esm/utils/keypad.js +97 -97
- package/dist/esm/utils/maps.d.ts +226 -226
- package/dist/esm/utils/maps.js +316 -316
- package/dist/esm/utils/menu.d.ts +117 -117
- package/dist/esm/utils/menu.js +74 -74
- package/dist/esm/utils/orders.d.ts +21 -21
- package/dist/esm/utils/orders.js +185 -185
- package/dist/esm/utils/pizzaBuilder.d.ts +10 -10
- package/dist/esm/utils/pizzaBuilder.js +38 -38
- package/dist/esm/utils/refunds.d.ts +35 -35
- package/dist/esm/utils/refunds.js +90 -90
- package/dist/esm/utils/revenueCenters.d.ts +11 -11
- package/dist/esm/utils/revenueCenters.js +115 -115
- package/dist/esm/utils/rewards.d.ts +4 -4
- package/dist/esm/utils/rewards.js +100 -100
- package/dist/esm/utils/theme.d.ts +27 -27
- package/dist/esm/utils/theme.js +254 -254
- package/dist/esm/utils/version.d.ts +4 -4
- package/dist/esm/utils/version.js +34 -34
- package/package.json +69 -68
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { AppTheme, ThemeLayout, Theme, ThemeBottomTabs } from '@open-tender/types';
|
|
2
|
-
export declare const makeLineHeight: (lineHeight?: string, fontSize?: string) => string;
|
|
3
|
-
export declare const remsToPixels: (rems?: string, responsive?: boolean) => string;
|
|
4
|
-
export declare const remsToNumber: (rems: string) => number;
|
|
5
|
-
export declare const objRemsToPixels: <T extends Partial<ThemeLayout & {
|
|
6
|
-
big: string;
|
|
7
|
-
small: string;
|
|
8
|
-
giga: string;
|
|
9
|
-
h1: string;
|
|
10
|
-
h2: string;
|
|
11
|
-
h3: string;
|
|
12
|
-
h4: string;
|
|
13
|
-
h5: string;
|
|
14
|
-
h6: string;
|
|
15
|
-
main: string;
|
|
16
|
-
mega: string;
|
|
17
|
-
tera: string;
|
|
18
|
-
xBig: string;
|
|
19
|
-
xSmall: string;
|
|
20
|
-
xxBig: string;
|
|
21
|
-
xxSmall: string;
|
|
22
|
-
}>>(object: T, responsive?: boolean) => Partial<T>;
|
|
23
|
-
export declare const pixelsToInt: (pixels: string) => number;
|
|
24
|
-
export declare const pixelsToFloat: (pixels: string) => number;
|
|
25
|
-
export declare const makeBottomTabs: (bottomTabs: ThemeBottomTabs) => ThemeBottomTabs;
|
|
26
|
-
export declare const decorateTheme: (theme: Theme) => AppTheme;
|
|
27
|
-
export declare const hexToRgbA: (hex: string, opacity: number) => string | null;
|
|
1
|
+
import { AppTheme, ThemeLayout, Theme, ThemeBottomTabs } from '@open-tender/types';
|
|
2
|
+
export declare const makeLineHeight: (lineHeight?: string, fontSize?: string) => string;
|
|
3
|
+
export declare const remsToPixels: (rems?: string, responsive?: boolean) => string;
|
|
4
|
+
export declare const remsToNumber: (rems: string) => number;
|
|
5
|
+
export declare const objRemsToPixels: <T extends Partial<ThemeLayout & {
|
|
6
|
+
big: string;
|
|
7
|
+
small: string;
|
|
8
|
+
giga: string;
|
|
9
|
+
h1: string;
|
|
10
|
+
h2: string;
|
|
11
|
+
h3: string;
|
|
12
|
+
h4: string;
|
|
13
|
+
h5: string;
|
|
14
|
+
h6: string;
|
|
15
|
+
main: string;
|
|
16
|
+
mega: string;
|
|
17
|
+
tera: string;
|
|
18
|
+
xBig: string;
|
|
19
|
+
xSmall: string;
|
|
20
|
+
xxBig: string;
|
|
21
|
+
xxSmall: string;
|
|
22
|
+
}>>(object: T, responsive?: boolean) => Partial<T>;
|
|
23
|
+
export declare const pixelsToInt: (pixels: string) => number;
|
|
24
|
+
export declare const pixelsToFloat: (pixels: string) => number;
|
|
25
|
+
export declare const makeBottomTabs: (bottomTabs: ThemeBottomTabs) => ThemeBottomTabs;
|
|
26
|
+
export declare const decorateTheme: (theme: Theme) => AppTheme;
|
|
27
|
+
export declare const hexToRgbA: (hex: string, opacity: number) => string | null;
|
package/dist/esm/utils/theme.js
CHANGED
|
@@ -1,254 +1,254 @@
|
|
|
1
|
-
export const makeLineHeight = (lineHeight, fontSize) => {
|
|
2
|
-
var _a;
|
|
3
|
-
const size = parseInt((_a = fontSize === null || fontSize === void 0 ? void 0 : fontSize.replace('px', '')) !== null && _a !== void 0 ? _a : '0');
|
|
4
|
-
return `${(parseFloat(lineHeight !== null && lineHeight !== void 0 ? lineHeight : '0') * size).toFixed(3)}px`;
|
|
5
|
-
};
|
|
6
|
-
// TODO: remove responsive option
|
|
7
|
-
export const remsToPixels = (rems, responsive = false) => {
|
|
8
|
-
const cleanedUpRems = rems === null || rems === void 0 ? void 0 : rems.trim().replace(/\s+/g, ' ');
|
|
9
|
-
if (!cleanedUpRems)
|
|
10
|
-
return '0';
|
|
11
|
-
const remsToPixelsSingleValue = (remsValue) => {
|
|
12
|
-
const pixels = parseFloat(remsValue.replace('rem', '')) * 10;
|
|
13
|
-
const adjustedPixels = responsive ? pixels : pixels;
|
|
14
|
-
const noZeroes = parseFloat(adjustedPixels.toFixed(2)).toString();
|
|
15
|
-
return noZeroes === '0' ? '0' : `${noZeroes}px`;
|
|
16
|
-
};
|
|
17
|
-
return cleanedUpRems
|
|
18
|
-
.split(' ')
|
|
19
|
-
.map(i => remsToPixelsSingleValue(i))
|
|
20
|
-
.join(' ');
|
|
21
|
-
};
|
|
22
|
-
export const remsToNumber = (rems) => {
|
|
23
|
-
return parseFloat(rems.replace('rem', '')) * 10;
|
|
24
|
-
};
|
|
25
|
-
export const objRemsToPixels = (object, responsive = false) => {
|
|
26
|
-
return Object.entries(object).reduce((obj, [key, value]) => {
|
|
27
|
-
return Object.assign(Object.assign({}, obj), { [key]: remsToPixels(value, responsive) });
|
|
28
|
-
}, {});
|
|
29
|
-
};
|
|
30
|
-
export const pixelsToInt = (pixels) => {
|
|
31
|
-
try {
|
|
32
|
-
return parseInt(pixels.replace('px', ''));
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
return 0;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
export const pixelsToFloat = (pixels) => {
|
|
39
|
-
try {
|
|
40
|
-
return parseFloat(pixels.replace('px', ''));
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
return 0.0;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const paddingToPixels = (padding) => {
|
|
47
|
-
const [top, horizontal, bottom] = padding.split(' ');
|
|
48
|
-
return `${remsToPixels(top)} ${remsToPixels(horizontal)} ${remsToPixels(bottom)}`;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* @deprecated use remsToPixels instead
|
|
52
|
-
*/
|
|
53
|
-
const boxRemsToPixels = (box) => {
|
|
54
|
-
const pixels = box
|
|
55
|
-
.split(' ')
|
|
56
|
-
.map(i => remsToPixels(i))
|
|
57
|
-
.join(' ');
|
|
58
|
-
return pixels === '0 0 0 0' ? '0px' : pixels;
|
|
59
|
-
};
|
|
60
|
-
const buttonToPixels = (button) => {
|
|
61
|
-
return Object.assign(Object.assign({}, button), { borderRadius: remsToPixels(button.borderRadius), borderWidth: remsToPixels(button.borderWidth), borderWidthApp: button.borderWidthApp
|
|
62
|
-
? remsToPixels(button.borderWidthApp)
|
|
63
|
-
: remsToPixels(button.borderWidth), fontSize: button.fontSize ? remsToPixels(button.fontSize, true) : null, letterSpacing: button.letterSpacing
|
|
64
|
-
? remsToPixels(button.letterSpacing)
|
|
65
|
-
: null, minHeightMobile: button.minHeightMobile
|
|
66
|
-
? paddingToPixels(button.minHeightMobile)
|
|
67
|
-
: null, padding: button.padding ? paddingToPixels(button.padding) : null, subtitleFontSizeMobile: button.subtitleFontSizeMobile
|
|
68
|
-
? remsToPixels(button.subtitleFontSizeMobile)
|
|
69
|
-
: null, subtitleMarginTopMobile: button.subtitleMarginTopMobile
|
|
70
|
-
? remsToPixels(button.subtitleMarginTopMobile)
|
|
71
|
-
: null, titleFontSizeMobile: button.titleFontSizeMobile
|
|
72
|
-
? remsToPixels(button.titleFontSizeMobile)
|
|
73
|
-
: null, titleMarginTopMobile: button.titleMarginTopMobile
|
|
74
|
-
? remsToPixels(button.titleMarginTopMobile)
|
|
75
|
-
: null, titleMarginLeftMobile: button.titleMarginLeftMobile
|
|
76
|
-
? remsToPixels(button.titleMarginLeftMobile)
|
|
77
|
-
: null });
|
|
78
|
-
};
|
|
79
|
-
const makeButtons = (buttons) => {
|
|
80
|
-
const sizes = Object.entries(buttons.sizes).reduce((obj, [key, value]) => {
|
|
81
|
-
return Object.assign(Object.assign({}, obj), { [key]: buttonToPixels(value) });
|
|
82
|
-
}, {});
|
|
83
|
-
return Object.assign(Object.assign({}, buttons), { sizes });
|
|
84
|
-
};
|
|
85
|
-
const makeLineHeights = (sizes, lineHeight) => {
|
|
86
|
-
return Object.entries(sizes).reduce((obj, [size, fontSize]) => {
|
|
87
|
-
return Object.assign(Object.assign({}, obj), { [size]: makeLineHeight(lineHeight, fontSize) });
|
|
88
|
-
}, {});
|
|
89
|
-
};
|
|
90
|
-
const makeFont = (font, sizes) => {
|
|
91
|
-
const fontStyle = Object.assign(Object.assign({}, font), { letterSpacing: remsToPixels(font.letterSpacing), lineHeights: makeLineHeights(sizes, `${font.lineHeight}`) });
|
|
92
|
-
if (!font.fontSize)
|
|
93
|
-
return fontStyle;
|
|
94
|
-
const fontSize = remsToPixels(font.fontSize, true);
|
|
95
|
-
const lineHeight = makeLineHeight(`${font.lineHeight}`, fontSize);
|
|
96
|
-
return Object.assign(Object.assign({}, fontStyle), { fontSize, lineHeight });
|
|
97
|
-
};
|
|
98
|
-
const makeFonts = (fonts, lineHeight) => {
|
|
99
|
-
const sizes = objRemsToPixels(fonts.sizesMobile, true);
|
|
100
|
-
const lineHeights = makeLineHeights(sizes, lineHeight);
|
|
101
|
-
const headline = makeFont(fonts.headline, sizes);
|
|
102
|
-
const headings = makeFont(fonts.headings, sizes);
|
|
103
|
-
const body = makeFont(fonts.body, sizes);
|
|
104
|
-
const preface = makeFont(fonts.preface, sizes);
|
|
105
|
-
return Object.assign(Object.assign({}, fonts), { headline, headings, body, preface, sizes, lineHeights });
|
|
106
|
-
};
|
|
107
|
-
const makeBorder = (border) => {
|
|
108
|
-
return Object.assign(Object.assign({}, border), { radius: remsToPixels(border.radius), radiusSmall: remsToPixels(border.radiusSmall), width: remsToPixels(border.width), widthApp: remsToPixels(border.widthApp) });
|
|
109
|
-
};
|
|
110
|
-
const makeLabel = (label, lineHeight) => {
|
|
111
|
-
const [vertical, horizontal] = label.padding.split(' ');
|
|
112
|
-
const fs = parseFloat(label.fontSizeMobile.replace('rem', '')) * 10.0;
|
|
113
|
-
const lh = parseFloat(lineHeight);
|
|
114
|
-
return {
|
|
115
|
-
fontSize: remsToPixels(label.fontSizeMobile, true),
|
|
116
|
-
lineHeight: `${fs * lh}px`,
|
|
117
|
-
offset: remsToPixels(label.offset),
|
|
118
|
-
padding: `${remsToPixels(vertical)} ${remsToPixels(horizontal)}`,
|
|
119
|
-
top: remsToPixels(label.top),
|
|
120
|
-
left: remsToPixels(label.left)
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
const makeInputs = (inputs) => {
|
|
124
|
-
const [vertical, horizontal] = inputs.padding.split(' ');
|
|
125
|
-
const fs = parseFloat(inputs.fontSizeMobile.replace('rem', '')) * 10.0;
|
|
126
|
-
const lh = parseFloat(inputs.lineHeight);
|
|
127
|
-
return Object.assign(Object.assign({}, inputs), { lineHeight: `${fs * lh}px`, letterSpacing: remsToPixels(inputs.letterSpacing), fontSize: remsToPixels(inputs.fontSizeMobile, true), radius: remsToPixels(inputs.radius), borderWidth: remsToPixels(inputs.borderWidth), borderWidthApp: remsToPixels(inputs.borderWidthApp), padding: `${remsToPixels(vertical)} ${remsToPixels(horizontal)}`, paddingHorizontal: remsToPixels(inputs.paddingHorizontal), paddingVertical: remsToPixels(inputs.paddingVertical), paddingTop: remsToPixels(inputs.paddingTop), paddingTopActive: remsToPixels(inputs.paddingTopActive), paddingBottom: remsToPixels(inputs.paddingBottom), paddingBottomActive: remsToPixels(inputs.paddingBottomActive), label: makeLabel(inputs.label, inputs.lineHeight) });
|
|
128
|
-
};
|
|
129
|
-
const makeCounts = (counts) => {
|
|
130
|
-
const { alerts, quantity } = counts;
|
|
131
|
-
return {
|
|
132
|
-
alerts: Object.assign(Object.assign({}, alerts), { borderWidth: remsToPixels(alerts.borderWidth), borderWidthApp: remsToPixels(alerts.borderWidthApp), fontSize: remsToPixels(alerts.fontSize, true), fontSizeMobile: remsToPixels(alerts.fontSizeMobile, true), paddingBottom: remsToPixels(alerts.paddingBottom), paddingTop: remsToPixels(alerts.paddingTop) }),
|
|
133
|
-
quantity: Object.assign(Object.assign({}, quantity), { fontSize: remsToPixels(quantity.fontSize, true), fontSizeMobile: remsToPixels(quantity.fontSizeMobile, true), paddingBottom: remsToPixels(quantity.paddingBottom), paddingTop: remsToPixels(quantity.paddingTop) })
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
const makeCards = (cards) => {
|
|
137
|
-
const { default: box, form, menuItem, modifier } = cards;
|
|
138
|
-
return {
|
|
139
|
-
default: Object.assign(Object.assign({}, box), { borderWidth: remsToPixels(box.borderWidth), borderWidthApp: remsToPixels(box.borderWidthApp), borderRadius: remsToPixels(box.borderRadius) }),
|
|
140
|
-
form: Object.assign(Object.assign({}, form), { borderWidth: remsToPixels(form.borderWidth), borderWidthApp: remsToPixels(form.borderWidthApp), borderRadius: remsToPixels(form.borderRadius) }),
|
|
141
|
-
menuItem: Object.assign(Object.assign({}, menuItem), { borderWidth: remsToPixels(menuItem.borderWidth), borderWidthApp: remsToPixels(menuItem.borderWidthApp), borderRadius: remsToPixels(menuItem.borderRadius) }),
|
|
142
|
-
modifier: Object.assign(Object.assign({}, modifier), { borderWidth: remsToPixels(modifier.borderWidth), borderWidthApp: remsToPixels(modifier.borderWidthApp), borderRadius: remsToPixels(modifier.borderRadius) })
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
const makeWelcome = (welcome) => {
|
|
146
|
-
const { mobile } = welcome;
|
|
147
|
-
const titleSize = remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.titleSize);
|
|
148
|
-
const subtitleSize = remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.subtitleSize);
|
|
149
|
-
return {
|
|
150
|
-
textAlign: mobile === null || mobile === void 0 ? void 0 : mobile.textAlign,
|
|
151
|
-
marginTop: remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.marginTop),
|
|
152
|
-
marginBottom: remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.marginBottom),
|
|
153
|
-
titleMarginLeft: remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.titleMarginLeft),
|
|
154
|
-
titleSize,
|
|
155
|
-
titleLineHeight: makeLineHeight(mobile === null || mobile === void 0 ? void 0 : mobile.titleLineHeight.toFixed(5), titleSize),
|
|
156
|
-
subtitleSize,
|
|
157
|
-
subtitleLineHeight: makeLineHeight(mobile === null || mobile === void 0 ? void 0 : mobile.subtitleLineHeight.toFixed(5), subtitleSize),
|
|
158
|
-
subtitleMarginTop: remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.subtitleMarginTop)
|
|
159
|
-
};
|
|
160
|
-
};
|
|
161
|
-
const makeItem = (item) => {
|
|
162
|
-
const { mobile } = item;
|
|
163
|
-
return Object.assign(Object.assign({}, mobile), { imageMargin: boxRemsToPixels(mobile.imageMargin), imageMaxHeight: remsToPixels(mobile.imageMaxHeight), imageMinHeight: remsToPixels(mobile.imageMinHeight), imagePadding: remsToPixels(mobile.imagePadding), imagePaddingAll: boxRemsToPixels(mobile.imagePaddingAll), maxWidth: remsToPixels(mobile.maxWidth), padding: remsToPixels(mobile.padding) });
|
|
164
|
-
};
|
|
165
|
-
const makeCategories = (categories) => {
|
|
166
|
-
const { mobile } = categories;
|
|
167
|
-
return Object.assign(Object.assign({}, mobile), { borderRadius: remsToPixels(mobile.borderRadius), containerMaxWidth: remsToPixels(mobile.containerMaxWidth), gap: remsToPixels(mobile.gap), gapDouble: remsToPixels(mobile.gapDouble), gapHalf: remsToPixels(mobile.gapHalf), imageBorderRadius: remsToPixels(mobile.imageBorderRadius), lineHeight: remsToPixels(mobile.lineHeight), lineMargin: remsToPixels(mobile.lineMargin), lineWidth: remsToPixels(mobile.lineWidth), maxWidth: remsToPixels(mobile.maxWidth), minWidth: remsToPixels(mobile.minWidth), paddingBottom: remsToPixels(mobile.paddingBottom), paddingHorizontal: remsToPixels(mobile.paddingHorizontal), paddingTop: remsToPixels(mobile.paddingTop), subtitleSize: remsToPixels(mobile.subtitleSize), titleSize: remsToPixels(mobile.titleSize) });
|
|
168
|
-
};
|
|
169
|
-
const fontSizeToLineHeight = (lineHeight, fontSize) => {
|
|
170
|
-
var _a;
|
|
171
|
-
const lineHt = (_a = parseFloat(lineHeight)) !== null && _a !== void 0 ? _a : 1;
|
|
172
|
-
const textFontSize = remsToPixels(fontSize);
|
|
173
|
-
return `${(lineHt * pixelsToFloat(textFontSize)).toFixed(2)}px`;
|
|
174
|
-
};
|
|
175
|
-
const makeMenuItems = (menuItems, lineHeight) => {
|
|
176
|
-
const { allergens, box, calories, container, content, buttons, image, price, tags, tagsAllergens, text, title } = menuItems;
|
|
177
|
-
return {
|
|
178
|
-
allergens: Object.assign(Object.assign({}, allergens), { fontSize: remsToPixels(allergens.fontSize), fontSizeMobile: remsToPixels(allergens.fontSizeMobile), letterSpacing: remsToPixels(allergens.letterSpacing), lineHeight: fontSizeToLineHeight(lineHeight, allergens.fontSizeMobile), gap: remsToPixels(allergens.gap), gapMobile: remsToPixels(allergens.gapMobile), width: remsToPixels(allergens.width), widthMobile: remsToPixels(allergens.widthMobile) }),
|
|
179
|
-
box: Object.assign(Object.assign({}, box), { border: boxRemsToPixels(box.border), borderMobile: boxRemsToPixels(box.borderMobile), borderRadius: remsToPixels(box.borderRadius), borderRadiusMobile: remsToPixels(box.borderRadiusMobile), margin: boxRemsToPixels(box.margin), marginMobile: boxRemsToPixels(box.marginMobile), minWidth: remsToPixels(box.minWidth), minWidthMobile: remsToPixels(box.minWidthMobile), padding: boxRemsToPixels(box.padding), paddingMobile: boxRemsToPixels(box.paddingMobile) }),
|
|
180
|
-
calories: Object.assign(Object.assign({}, calories), { fontSize: remsToPixels(calories.fontSize), fontSizeMobile: remsToPixels(calories.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, calories.fontSizeMobile), padding: boxRemsToPixels(calories.padding), paddingMobile: boxRemsToPixels(calories.paddingMobile) }),
|
|
181
|
-
container: Object.assign(Object.assign({}, container), { gap: remsToPixels(container.gap), gapHalf: remsToPixels(container.gapHalf), gapHalfMobile: remsToPixels(container.gapHalfMobile), gapMobile: remsToPixels(container.gapMobile), margin: boxRemsToPixels(container.margin), marginMobile: boxRemsToPixels(container.marginMobile), maxWidth: remsToPixels(container.maxWidth), padding: boxRemsToPixels(container.padding), paddingMobile: boxRemsToPixels(container.paddingMobile) }),
|
|
182
|
-
content: Object.assign(Object.assign({}, content), { padding: boxRemsToPixels(content.padding), paddingMobile: boxRemsToPixels(content.paddingMobile) }),
|
|
183
|
-
buttons: Object.assign(Object.assign({}, buttons), { gap: remsToPixels(buttons.gap), gapMobile: remsToPixels(buttons.gapMobile), padding: boxRemsToPixels(buttons.padding), paddingMobile: boxRemsToPixels(buttons.paddingMobile) }),
|
|
184
|
-
image: Object.assign(Object.assign({}, image), { border: boxRemsToPixels(image.border), borderMobile: boxRemsToPixels(image.borderMobile), borderRadius: remsToPixels(image.borderRadius), borderRadiusMobile: remsToPixels(image.borderRadiusMobile), margin: boxRemsToPixels(image.margin), marginMobile: boxRemsToPixels(image.marginMobile), minWidth: remsToPixels(image.minWidth), minWidthMobile: remsToPixels(image.minWidthMobile), padding: boxRemsToPixels(image.padding), paddingMobile: boxRemsToPixels(image.paddingMobile) }),
|
|
185
|
-
price: Object.assign(Object.assign({}, price), { fontSize: remsToPixels(price.fontSize), fontSizeMobile: remsToPixels(price.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, price.fontSizeMobile), padding: boxRemsToPixels(price.padding), paddingMobile: boxRemsToPixels(price.paddingMobile) }),
|
|
186
|
-
tags: Object.assign(Object.assign({}, tags), { fontSize: remsToPixels(tags.fontSize), fontSizeMobile: remsToPixels(tags.fontSizeMobile), letterSpacing: remsToPixels(tags.letterSpacing), lineHeight: fontSizeToLineHeight(lineHeight, tags.fontSizeMobile), gap: remsToPixels(tags.gap), gapMobile: remsToPixels(tags.gapMobile), width: remsToPixels(tags.width), widthMobile: remsToPixels(tags.widthMobile) }),
|
|
187
|
-
tagsAllergens: Object.assign(Object.assign({}, tagsAllergens), { gap: remsToPixels(tagsAllergens.gap), gapMobile: remsToPixels(tagsAllergens.gapMobile), padding: boxRemsToPixels(tagsAllergens.padding), paddingMobile: boxRemsToPixels(tagsAllergens.paddingMobile) }),
|
|
188
|
-
text: Object.assign(Object.assign({}, text), { fontSize: remsToPixels(text.fontSize), fontSizeMobile: remsToPixels(text.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, text.fontSizeMobile), padding: boxRemsToPixels(text.padding), paddingMobile: boxRemsToPixels(text.paddingMobile) }),
|
|
189
|
-
title: Object.assign(Object.assign({}, title), { fontSize: remsToPixels(title.fontSize), fontSizeMobile: remsToPixels(title.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, title.fontSizeMobile), padding: boxRemsToPixels(title.padding), paddingMobile: boxRemsToPixels(title.paddingMobile) })
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
const makeModifiers = (modifiers, lineHeight) => {
|
|
193
|
-
const { box, calories, content, image, price, text, title } = modifiers;
|
|
194
|
-
return Object.assign(Object.assign({}, modifiers), { box: Object.assign(Object.assign({}, box), { border: boxRemsToPixels(box.border), borderMobile: boxRemsToPixels(box.borderMobile), borderRadius: remsToPixels(box.borderRadius), gap: remsToPixels(box.gap), gapHalf: remsToPixels(box.gapHalf), margin: boxRemsToPixels(box.margin), marginMobile: boxRemsToPixels(box.marginMobile), minHeight: remsToPixels(box.minHeight), minHeightWithGap: remsToPixels(box.minHeightWithGap), minWidth: remsToPixels(box.minWidth), padding: boxRemsToPixels(box.padding), paddingMobile: boxRemsToPixels(box.paddingMobile) }), calories: Object.assign(Object.assign({}, calories), { fontSize: remsToPixels(calories.fontSize), lineHeight: fontSizeToLineHeight(calories.fontSize, lineHeight) }), content: Object.assign(Object.assign({}, content), { padding: boxRemsToPixels(content.padding) }), image: Object.assign(Object.assign({}, image), { border: boxRemsToPixels(image.border), borderRadius: remsToPixels(image.borderRadius), height: remsToPixels(image.height), margin: boxRemsToPixels(image.margin), padding: boxRemsToPixels(image.padding), width: remsToPixels(image.width) }), price: Object.assign(Object.assign({}, price), { fontSize: remsToPixels(price.fontSize), lineHeight: fontSizeToLineHeight(price.fontSize, lineHeight) }), text: Object.assign(Object.assign({}, text), { fontSize: remsToPixels(text.fontSize), lineHeight: fontSizeToLineHeight(text.fontSize, lineHeight) }), title: Object.assign(Object.assign({}, title), { fontSize: remsToPixels(title.fontSize), lineHeight: fontSizeToLineHeight(title.fontSize, lineHeight) }) });
|
|
195
|
-
};
|
|
196
|
-
const makeTags = (tags) => {
|
|
197
|
-
return Object.assign(Object.assign({}, tags), { image: Object.assign(Object.assign({}, tags.image), { padding: remsToPixels(tags.container.padding), paddingMobile: remsToPixels(tags.container.paddingMobile), margin: remsToPixels(tags.container.margin), marginMobile: remsToPixels(tags.container.marginMobile) }), container: Object.assign(Object.assign({}, tags.container), { padding: remsToPixels(tags.container.padding), paddingMobile: remsToPixels(tags.container.paddingMobile), margin: remsToPixels(tags.container.margin), marginMobile: remsToPixels(tags.container.marginMobile) }), box: Object.assign(Object.assign({}, tags.box), { padding: remsToPixels(tags.box.padding), paddingMobile: remsToPixels(tags.box.paddingMobile), margin: remsToPixels(tags.box.margin), marginMobile: remsToPixels(tags.box.marginMobile) }), text: Object.assign(Object.assign({}, tags.text), { fontSize: remsToPixels(tags.text.fontSize), fontSizeMobile: remsToPixels(tags.text.fontSizeMobile) }) });
|
|
198
|
-
};
|
|
199
|
-
const makeLogo = (logo) => {
|
|
200
|
-
return {
|
|
201
|
-
marginTop: remsToPixels(logo.marginTop),
|
|
202
|
-
marginTopMobile: remsToPixels(logo.marginTopMobile),
|
|
203
|
-
width: remsToPixels(logo.width),
|
|
204
|
-
widthMobile: remsToPixels(logo.widthMobile)
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
export const makeBottomTabs = (bottomTabs) => {
|
|
208
|
-
const fontSize = remsToPixels(bottomTabs.buttons.fontSize);
|
|
209
|
-
return {
|
|
210
|
-
box: Object.assign(Object.assign({}, bottomTabs.box), { borderRadius: remsToPixels(bottomTabs.box.borderRadius), borderWidth: remsToPixels(bottomTabs.box.borderWidth), gap: remsToPixels(bottomTabs.box.gap), padding: remsToPixels(bottomTabs.box.padding) }),
|
|
211
|
-
buttons: Object.assign(Object.assign({}, bottomTabs.buttons), { fontSize: fontSize, letterSpacing: remsToPixels(bottomTabs.buttons.letterSpacing), lineHeight: makeLineHeight(`${bottomTabs.buttons.lineHeight}`, fontSize), padding: remsToPixels(bottomTabs.buttons.padding) }),
|
|
212
|
-
icons: Object.assign(Object.assign({}, bottomTabs.icons), { padding: remsToPixels(bottomTabs.icons.padding) })
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
export const decorateTheme = (theme) => {
|
|
216
|
-
const logo = makeLogo(theme.logo);
|
|
217
|
-
const logoFooter = makeLogo(theme.logoFooter);
|
|
218
|
-
const fonts = makeFonts(theme.fonts, theme.lineHeight);
|
|
219
|
-
const lineHeight = makeLineHeight(theme.lineHeight, fonts.sizes.main);
|
|
220
|
-
const layout = objRemsToPixels(theme.layout);
|
|
221
|
-
const buttons = makeButtons(theme.buttons);
|
|
222
|
-
const border = makeBorder(theme.border);
|
|
223
|
-
const inputs = makeInputs(theme.inputs);
|
|
224
|
-
const counts = makeCounts(theme.counts);
|
|
225
|
-
const cards = makeCards(theme.cards);
|
|
226
|
-
const welcome = makeWelcome(theme.welcome);
|
|
227
|
-
const item = makeItem(theme.item);
|
|
228
|
-
const categories = makeCategories(theme.categories);
|
|
229
|
-
const menuItems = makeMenuItems(theme.menuItems, theme.lineHeight);
|
|
230
|
-
const modifiers = makeModifiers(theme.modifiers, theme.lineHeight);
|
|
231
|
-
const tags = makeTags(theme.tags);
|
|
232
|
-
const bottomTabs = makeBottomTabs(theme.bottomTabs);
|
|
233
|
-
return Object.assign(Object.assign({}, theme), { logo,
|
|
234
|
-
logoFooter, fonts: fonts, lineHeight, layout: layout, buttons: buttons, border, inputs: inputs, counts,
|
|
235
|
-
cards, welcome: welcome, item: item, categories,
|
|
236
|
-
menuItems,
|
|
237
|
-
modifiers,
|
|
238
|
-
tags,
|
|
239
|
-
bottomTabs });
|
|
240
|
-
};
|
|
241
|
-
export const hexToRgbA = (hex, opacity) => {
|
|
242
|
-
let c;
|
|
243
|
-
if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)) {
|
|
244
|
-
c = hex.substring(1).split('');
|
|
245
|
-
if (c.length === 3) {
|
|
246
|
-
c = [c[0], c[0], c[1], c[1], c[2], c[2]];
|
|
247
|
-
}
|
|
248
|
-
c = '0x' + c.join('');
|
|
249
|
-
return ('rgba(' +
|
|
250
|
-
[(c >> 16) & 255, (c >> 8) & 255, c & 255].join(',') +
|
|
251
|
-
`,${opacity})`);
|
|
252
|
-
}
|
|
253
|
-
return null;
|
|
254
|
-
};
|
|
1
|
+
export const makeLineHeight = (lineHeight, fontSize) => {
|
|
2
|
+
var _a;
|
|
3
|
+
const size = parseInt((_a = fontSize === null || fontSize === void 0 ? void 0 : fontSize.replace('px', '')) !== null && _a !== void 0 ? _a : '0');
|
|
4
|
+
return `${(parseFloat(lineHeight !== null && lineHeight !== void 0 ? lineHeight : '0') * size).toFixed(3)}px`;
|
|
5
|
+
};
|
|
6
|
+
// TODO: remove responsive option
|
|
7
|
+
export const remsToPixels = (rems, responsive = false) => {
|
|
8
|
+
const cleanedUpRems = rems === null || rems === void 0 ? void 0 : rems.trim().replace(/\s+/g, ' ');
|
|
9
|
+
if (!cleanedUpRems)
|
|
10
|
+
return '0';
|
|
11
|
+
const remsToPixelsSingleValue = (remsValue) => {
|
|
12
|
+
const pixels = parseFloat(remsValue.replace('rem', '')) * 10;
|
|
13
|
+
const adjustedPixels = responsive ? pixels : pixels;
|
|
14
|
+
const noZeroes = parseFloat(adjustedPixels.toFixed(2)).toString();
|
|
15
|
+
return noZeroes === '0' ? '0' : `${noZeroes}px`;
|
|
16
|
+
};
|
|
17
|
+
return cleanedUpRems
|
|
18
|
+
.split(' ')
|
|
19
|
+
.map(i => remsToPixelsSingleValue(i))
|
|
20
|
+
.join(' ');
|
|
21
|
+
};
|
|
22
|
+
export const remsToNumber = (rems) => {
|
|
23
|
+
return parseFloat(rems.replace('rem', '')) * 10;
|
|
24
|
+
};
|
|
25
|
+
export const objRemsToPixels = (object, responsive = false) => {
|
|
26
|
+
return Object.entries(object).reduce((obj, [key, value]) => {
|
|
27
|
+
return Object.assign(Object.assign({}, obj), { [key]: remsToPixels(value, responsive) });
|
|
28
|
+
}, {});
|
|
29
|
+
};
|
|
30
|
+
export const pixelsToInt = (pixels) => {
|
|
31
|
+
try {
|
|
32
|
+
return parseInt(pixels.replace('px', ''));
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export const pixelsToFloat = (pixels) => {
|
|
39
|
+
try {
|
|
40
|
+
return parseFloat(pixels.replace('px', ''));
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
return 0.0;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const paddingToPixels = (padding) => {
|
|
47
|
+
const [top, horizontal, bottom] = padding.split(' ');
|
|
48
|
+
return `${remsToPixels(top)} ${remsToPixels(horizontal)} ${remsToPixels(bottom)}`;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated use remsToPixels instead
|
|
52
|
+
*/
|
|
53
|
+
const boxRemsToPixels = (box) => {
|
|
54
|
+
const pixels = box
|
|
55
|
+
.split(' ')
|
|
56
|
+
.map(i => remsToPixels(i))
|
|
57
|
+
.join(' ');
|
|
58
|
+
return pixels === '0 0 0 0' ? '0px' : pixels;
|
|
59
|
+
};
|
|
60
|
+
const buttonToPixels = (button) => {
|
|
61
|
+
return Object.assign(Object.assign({}, button), { borderRadius: remsToPixels(button.borderRadius), borderWidth: remsToPixels(button.borderWidth), borderWidthApp: button.borderWidthApp
|
|
62
|
+
? remsToPixels(button.borderWidthApp)
|
|
63
|
+
: remsToPixels(button.borderWidth), fontSize: button.fontSize ? remsToPixels(button.fontSize, true) : null, letterSpacing: button.letterSpacing
|
|
64
|
+
? remsToPixels(button.letterSpacing)
|
|
65
|
+
: null, minHeightMobile: button.minHeightMobile
|
|
66
|
+
? paddingToPixels(button.minHeightMobile)
|
|
67
|
+
: null, padding: button.padding ? paddingToPixels(button.padding) : null, subtitleFontSizeMobile: button.subtitleFontSizeMobile
|
|
68
|
+
? remsToPixels(button.subtitleFontSizeMobile)
|
|
69
|
+
: null, subtitleMarginTopMobile: button.subtitleMarginTopMobile
|
|
70
|
+
? remsToPixels(button.subtitleMarginTopMobile)
|
|
71
|
+
: null, titleFontSizeMobile: button.titleFontSizeMobile
|
|
72
|
+
? remsToPixels(button.titleFontSizeMobile)
|
|
73
|
+
: null, titleMarginTopMobile: button.titleMarginTopMobile
|
|
74
|
+
? remsToPixels(button.titleMarginTopMobile)
|
|
75
|
+
: null, titleMarginLeftMobile: button.titleMarginLeftMobile
|
|
76
|
+
? remsToPixels(button.titleMarginLeftMobile)
|
|
77
|
+
: null });
|
|
78
|
+
};
|
|
79
|
+
const makeButtons = (buttons) => {
|
|
80
|
+
const sizes = Object.entries(buttons.sizes).reduce((obj, [key, value]) => {
|
|
81
|
+
return Object.assign(Object.assign({}, obj), { [key]: buttonToPixels(value) });
|
|
82
|
+
}, {});
|
|
83
|
+
return Object.assign(Object.assign({}, buttons), { sizes });
|
|
84
|
+
};
|
|
85
|
+
const makeLineHeights = (sizes, lineHeight) => {
|
|
86
|
+
return Object.entries(sizes).reduce((obj, [size, fontSize]) => {
|
|
87
|
+
return Object.assign(Object.assign({}, obj), { [size]: makeLineHeight(lineHeight, fontSize) });
|
|
88
|
+
}, {});
|
|
89
|
+
};
|
|
90
|
+
const makeFont = (font, sizes) => {
|
|
91
|
+
const fontStyle = Object.assign(Object.assign({}, font), { letterSpacing: remsToPixels(font.letterSpacing), lineHeights: makeLineHeights(sizes, `${font.lineHeight}`) });
|
|
92
|
+
if (!font.fontSize)
|
|
93
|
+
return fontStyle;
|
|
94
|
+
const fontSize = remsToPixels(font.fontSize, true);
|
|
95
|
+
const lineHeight = makeLineHeight(`${font.lineHeight}`, fontSize);
|
|
96
|
+
return Object.assign(Object.assign({}, fontStyle), { fontSize, lineHeight });
|
|
97
|
+
};
|
|
98
|
+
const makeFonts = (fonts, lineHeight) => {
|
|
99
|
+
const sizes = objRemsToPixels(fonts.sizesMobile, true);
|
|
100
|
+
const lineHeights = makeLineHeights(sizes, lineHeight);
|
|
101
|
+
const headline = makeFont(fonts.headline, sizes);
|
|
102
|
+
const headings = makeFont(fonts.headings, sizes);
|
|
103
|
+
const body = makeFont(fonts.body, sizes);
|
|
104
|
+
const preface = makeFont(fonts.preface, sizes);
|
|
105
|
+
return Object.assign(Object.assign({}, fonts), { headline, headings, body, preface, sizes, lineHeights });
|
|
106
|
+
};
|
|
107
|
+
const makeBorder = (border) => {
|
|
108
|
+
return Object.assign(Object.assign({}, border), { radius: remsToPixels(border.radius), radiusSmall: remsToPixels(border.radiusSmall), width: remsToPixels(border.width), widthApp: remsToPixels(border.widthApp) });
|
|
109
|
+
};
|
|
110
|
+
const makeLabel = (label, lineHeight) => {
|
|
111
|
+
const [vertical, horizontal] = label.padding.split(' ');
|
|
112
|
+
const fs = parseFloat(label.fontSizeMobile.replace('rem', '')) * 10.0;
|
|
113
|
+
const lh = parseFloat(lineHeight);
|
|
114
|
+
return {
|
|
115
|
+
fontSize: remsToPixels(label.fontSizeMobile, true),
|
|
116
|
+
lineHeight: `${fs * lh}px`,
|
|
117
|
+
offset: remsToPixels(label.offset),
|
|
118
|
+
padding: `${remsToPixels(vertical)} ${remsToPixels(horizontal)}`,
|
|
119
|
+
top: remsToPixels(label.top),
|
|
120
|
+
left: remsToPixels(label.left)
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
const makeInputs = (inputs) => {
|
|
124
|
+
const [vertical, horizontal] = inputs.padding.split(' ');
|
|
125
|
+
const fs = parseFloat(inputs.fontSizeMobile.replace('rem', '')) * 10.0;
|
|
126
|
+
const lh = parseFloat(inputs.lineHeight);
|
|
127
|
+
return Object.assign(Object.assign({}, inputs), { lineHeight: `${fs * lh}px`, letterSpacing: remsToPixels(inputs.letterSpacing), fontSize: remsToPixels(inputs.fontSizeMobile, true), radius: remsToPixels(inputs.radius), borderWidth: remsToPixels(inputs.borderWidth), borderWidthApp: remsToPixels(inputs.borderWidthApp), padding: `${remsToPixels(vertical)} ${remsToPixels(horizontal)}`, paddingHorizontal: remsToPixels(inputs.paddingHorizontal), paddingVertical: remsToPixels(inputs.paddingVertical), paddingTop: remsToPixels(inputs.paddingTop), paddingTopActive: remsToPixels(inputs.paddingTopActive), paddingBottom: remsToPixels(inputs.paddingBottom), paddingBottomActive: remsToPixels(inputs.paddingBottomActive), label: makeLabel(inputs.label, inputs.lineHeight) });
|
|
128
|
+
};
|
|
129
|
+
const makeCounts = (counts) => {
|
|
130
|
+
const { alerts, quantity } = counts;
|
|
131
|
+
return {
|
|
132
|
+
alerts: Object.assign(Object.assign({}, alerts), { borderWidth: remsToPixels(alerts.borderWidth), borderWidthApp: remsToPixels(alerts.borderWidthApp), fontSize: remsToPixels(alerts.fontSize, true), fontSizeMobile: remsToPixels(alerts.fontSizeMobile, true), paddingBottom: remsToPixels(alerts.paddingBottom), paddingTop: remsToPixels(alerts.paddingTop) }),
|
|
133
|
+
quantity: Object.assign(Object.assign({}, quantity), { fontSize: remsToPixels(quantity.fontSize, true), fontSizeMobile: remsToPixels(quantity.fontSizeMobile, true), paddingBottom: remsToPixels(quantity.paddingBottom), paddingTop: remsToPixels(quantity.paddingTop) })
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
const makeCards = (cards) => {
|
|
137
|
+
const { default: box, form, menuItem, modifier } = cards;
|
|
138
|
+
return {
|
|
139
|
+
default: Object.assign(Object.assign({}, box), { borderWidth: remsToPixels(box.borderWidth), borderWidthApp: remsToPixels(box.borderWidthApp), borderRadius: remsToPixels(box.borderRadius) }),
|
|
140
|
+
form: Object.assign(Object.assign({}, form), { borderWidth: remsToPixels(form.borderWidth), borderWidthApp: remsToPixels(form.borderWidthApp), borderRadius: remsToPixels(form.borderRadius) }),
|
|
141
|
+
menuItem: Object.assign(Object.assign({}, menuItem), { borderWidth: remsToPixels(menuItem.borderWidth), borderWidthApp: remsToPixels(menuItem.borderWidthApp), borderRadius: remsToPixels(menuItem.borderRadius) }),
|
|
142
|
+
modifier: Object.assign(Object.assign({}, modifier), { borderWidth: remsToPixels(modifier.borderWidth), borderWidthApp: remsToPixels(modifier.borderWidthApp), borderRadius: remsToPixels(modifier.borderRadius) })
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
const makeWelcome = (welcome) => {
|
|
146
|
+
const { mobile } = welcome;
|
|
147
|
+
const titleSize = remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.titleSize);
|
|
148
|
+
const subtitleSize = remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.subtitleSize);
|
|
149
|
+
return {
|
|
150
|
+
textAlign: mobile === null || mobile === void 0 ? void 0 : mobile.textAlign,
|
|
151
|
+
marginTop: remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.marginTop),
|
|
152
|
+
marginBottom: remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.marginBottom),
|
|
153
|
+
titleMarginLeft: remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.titleMarginLeft),
|
|
154
|
+
titleSize,
|
|
155
|
+
titleLineHeight: makeLineHeight(mobile === null || mobile === void 0 ? void 0 : mobile.titleLineHeight.toFixed(5), titleSize),
|
|
156
|
+
subtitleSize,
|
|
157
|
+
subtitleLineHeight: makeLineHeight(mobile === null || mobile === void 0 ? void 0 : mobile.subtitleLineHeight.toFixed(5), subtitleSize),
|
|
158
|
+
subtitleMarginTop: remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.subtitleMarginTop)
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
const makeItem = (item) => {
|
|
162
|
+
const { mobile } = item;
|
|
163
|
+
return Object.assign(Object.assign({}, mobile), { imageMargin: boxRemsToPixels(mobile.imageMargin), imageMaxHeight: remsToPixels(mobile.imageMaxHeight), imageMinHeight: remsToPixels(mobile.imageMinHeight), imagePadding: remsToPixels(mobile.imagePadding), imagePaddingAll: boxRemsToPixels(mobile.imagePaddingAll), maxWidth: remsToPixels(mobile.maxWidth), padding: remsToPixels(mobile.padding) });
|
|
164
|
+
};
|
|
165
|
+
const makeCategories = (categories) => {
|
|
166
|
+
const { mobile } = categories;
|
|
167
|
+
return Object.assign(Object.assign({}, mobile), { borderRadius: remsToPixels(mobile.borderRadius), containerMaxWidth: remsToPixels(mobile.containerMaxWidth), gap: remsToPixels(mobile.gap), gapDouble: remsToPixels(mobile.gapDouble), gapHalf: remsToPixels(mobile.gapHalf), imageBorderRadius: remsToPixels(mobile.imageBorderRadius), lineHeight: remsToPixels(mobile.lineHeight), lineMargin: remsToPixels(mobile.lineMargin), lineWidth: remsToPixels(mobile.lineWidth), maxWidth: remsToPixels(mobile.maxWidth), minWidth: remsToPixels(mobile.minWidth), paddingBottom: remsToPixels(mobile.paddingBottom), paddingHorizontal: remsToPixels(mobile.paddingHorizontal), paddingTop: remsToPixels(mobile.paddingTop), subtitleSize: remsToPixels(mobile.subtitleSize), titleSize: remsToPixels(mobile.titleSize) });
|
|
168
|
+
};
|
|
169
|
+
const fontSizeToLineHeight = (lineHeight, fontSize) => {
|
|
170
|
+
var _a;
|
|
171
|
+
const lineHt = (_a = parseFloat(lineHeight)) !== null && _a !== void 0 ? _a : 1;
|
|
172
|
+
const textFontSize = remsToPixels(fontSize);
|
|
173
|
+
return `${(lineHt * pixelsToFloat(textFontSize)).toFixed(2)}px`;
|
|
174
|
+
};
|
|
175
|
+
const makeMenuItems = (menuItems, lineHeight) => {
|
|
176
|
+
const { allergens, box, calories, container, content, buttons, image, price, tags, tagsAllergens, text, title } = menuItems;
|
|
177
|
+
return {
|
|
178
|
+
allergens: Object.assign(Object.assign({}, allergens), { fontSize: remsToPixels(allergens.fontSize), fontSizeMobile: remsToPixels(allergens.fontSizeMobile), letterSpacing: remsToPixels(allergens.letterSpacing), lineHeight: fontSizeToLineHeight(lineHeight, allergens.fontSizeMobile), gap: remsToPixels(allergens.gap), gapMobile: remsToPixels(allergens.gapMobile), width: remsToPixels(allergens.width), widthMobile: remsToPixels(allergens.widthMobile) }),
|
|
179
|
+
box: Object.assign(Object.assign({}, box), { border: boxRemsToPixels(box.border), borderMobile: boxRemsToPixels(box.borderMobile), borderRadius: remsToPixels(box.borderRadius), borderRadiusMobile: remsToPixels(box.borderRadiusMobile), margin: boxRemsToPixels(box.margin), marginMobile: boxRemsToPixels(box.marginMobile), minWidth: remsToPixels(box.minWidth), minWidthMobile: remsToPixels(box.minWidthMobile), padding: boxRemsToPixels(box.padding), paddingMobile: boxRemsToPixels(box.paddingMobile) }),
|
|
180
|
+
calories: Object.assign(Object.assign({}, calories), { fontSize: remsToPixels(calories.fontSize), fontSizeMobile: remsToPixels(calories.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, calories.fontSizeMobile), padding: boxRemsToPixels(calories.padding), paddingMobile: boxRemsToPixels(calories.paddingMobile) }),
|
|
181
|
+
container: Object.assign(Object.assign({}, container), { gap: remsToPixels(container.gap), gapHalf: remsToPixels(container.gapHalf), gapHalfMobile: remsToPixels(container.gapHalfMobile), gapMobile: remsToPixels(container.gapMobile), margin: boxRemsToPixels(container.margin), marginMobile: boxRemsToPixels(container.marginMobile), maxWidth: remsToPixels(container.maxWidth), padding: boxRemsToPixels(container.padding), paddingMobile: boxRemsToPixels(container.paddingMobile) }),
|
|
182
|
+
content: Object.assign(Object.assign({}, content), { padding: boxRemsToPixels(content.padding), paddingMobile: boxRemsToPixels(content.paddingMobile) }),
|
|
183
|
+
buttons: Object.assign(Object.assign({}, buttons), { gap: remsToPixels(buttons.gap), gapMobile: remsToPixels(buttons.gapMobile), padding: boxRemsToPixels(buttons.padding), paddingMobile: boxRemsToPixels(buttons.paddingMobile) }),
|
|
184
|
+
image: Object.assign(Object.assign({}, image), { border: boxRemsToPixels(image.border), borderMobile: boxRemsToPixels(image.borderMobile), borderRadius: remsToPixels(image.borderRadius), borderRadiusMobile: remsToPixels(image.borderRadiusMobile), margin: boxRemsToPixels(image.margin), marginMobile: boxRemsToPixels(image.marginMobile), minWidth: remsToPixels(image.minWidth), minWidthMobile: remsToPixels(image.minWidthMobile), padding: boxRemsToPixels(image.padding), paddingMobile: boxRemsToPixels(image.paddingMobile) }),
|
|
185
|
+
price: Object.assign(Object.assign({}, price), { fontSize: remsToPixels(price.fontSize), fontSizeMobile: remsToPixels(price.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, price.fontSizeMobile), padding: boxRemsToPixels(price.padding), paddingMobile: boxRemsToPixels(price.paddingMobile) }),
|
|
186
|
+
tags: Object.assign(Object.assign({}, tags), { fontSize: remsToPixels(tags.fontSize), fontSizeMobile: remsToPixels(tags.fontSizeMobile), letterSpacing: remsToPixels(tags.letterSpacing), lineHeight: fontSizeToLineHeight(lineHeight, tags.fontSizeMobile), gap: remsToPixels(tags.gap), gapMobile: remsToPixels(tags.gapMobile), width: remsToPixels(tags.width), widthMobile: remsToPixels(tags.widthMobile) }),
|
|
187
|
+
tagsAllergens: Object.assign(Object.assign({}, tagsAllergens), { gap: remsToPixels(tagsAllergens.gap), gapMobile: remsToPixels(tagsAllergens.gapMobile), padding: boxRemsToPixels(tagsAllergens.padding), paddingMobile: boxRemsToPixels(tagsAllergens.paddingMobile) }),
|
|
188
|
+
text: Object.assign(Object.assign({}, text), { fontSize: remsToPixels(text.fontSize), fontSizeMobile: remsToPixels(text.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, text.fontSizeMobile), padding: boxRemsToPixels(text.padding), paddingMobile: boxRemsToPixels(text.paddingMobile) }),
|
|
189
|
+
title: Object.assign(Object.assign({}, title), { fontSize: remsToPixels(title.fontSize), fontSizeMobile: remsToPixels(title.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, title.fontSizeMobile), padding: boxRemsToPixels(title.padding), paddingMobile: boxRemsToPixels(title.paddingMobile) })
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
const makeModifiers = (modifiers, lineHeight) => {
|
|
193
|
+
const { box, calories, content, image, price, text, title } = modifiers;
|
|
194
|
+
return Object.assign(Object.assign({}, modifiers), { box: Object.assign(Object.assign({}, box), { border: boxRemsToPixels(box.border), borderMobile: boxRemsToPixels(box.borderMobile), borderRadius: remsToPixels(box.borderRadius), gap: remsToPixels(box.gap), gapHalf: remsToPixels(box.gapHalf), margin: boxRemsToPixels(box.margin), marginMobile: boxRemsToPixels(box.marginMobile), minHeight: remsToPixels(box.minHeight), minHeightWithGap: remsToPixels(box.minHeightWithGap), minWidth: remsToPixels(box.minWidth), padding: boxRemsToPixels(box.padding), paddingMobile: boxRemsToPixels(box.paddingMobile) }), calories: Object.assign(Object.assign({}, calories), { fontSize: remsToPixels(calories.fontSize), lineHeight: fontSizeToLineHeight(calories.fontSize, lineHeight) }), content: Object.assign(Object.assign({}, content), { padding: boxRemsToPixels(content.padding) }), image: Object.assign(Object.assign({}, image), { border: boxRemsToPixels(image.border), borderRadius: remsToPixels(image.borderRadius), height: remsToPixels(image.height), margin: boxRemsToPixels(image.margin), padding: boxRemsToPixels(image.padding), width: remsToPixels(image.width) }), price: Object.assign(Object.assign({}, price), { fontSize: remsToPixels(price.fontSize), lineHeight: fontSizeToLineHeight(price.fontSize, lineHeight) }), text: Object.assign(Object.assign({}, text), { fontSize: remsToPixels(text.fontSize), lineHeight: fontSizeToLineHeight(text.fontSize, lineHeight) }), title: Object.assign(Object.assign({}, title), { fontSize: remsToPixels(title.fontSize), lineHeight: fontSizeToLineHeight(title.fontSize, lineHeight) }) });
|
|
195
|
+
};
|
|
196
|
+
const makeTags = (tags) => {
|
|
197
|
+
return Object.assign(Object.assign({}, tags), { image: Object.assign(Object.assign({}, tags.image), { padding: remsToPixels(tags.container.padding), paddingMobile: remsToPixels(tags.container.paddingMobile), margin: remsToPixels(tags.container.margin), marginMobile: remsToPixels(tags.container.marginMobile) }), container: Object.assign(Object.assign({}, tags.container), { padding: remsToPixels(tags.container.padding), paddingMobile: remsToPixels(tags.container.paddingMobile), margin: remsToPixels(tags.container.margin), marginMobile: remsToPixels(tags.container.marginMobile) }), box: Object.assign(Object.assign({}, tags.box), { padding: remsToPixels(tags.box.padding), paddingMobile: remsToPixels(tags.box.paddingMobile), margin: remsToPixels(tags.box.margin), marginMobile: remsToPixels(tags.box.marginMobile) }), text: Object.assign(Object.assign({}, tags.text), { fontSize: remsToPixels(tags.text.fontSize), fontSizeMobile: remsToPixels(tags.text.fontSizeMobile) }) });
|
|
198
|
+
};
|
|
199
|
+
const makeLogo = (logo) => {
|
|
200
|
+
return {
|
|
201
|
+
marginTop: remsToPixels(logo.marginTop),
|
|
202
|
+
marginTopMobile: remsToPixels(logo.marginTopMobile),
|
|
203
|
+
width: remsToPixels(logo.width),
|
|
204
|
+
widthMobile: remsToPixels(logo.widthMobile)
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
export const makeBottomTabs = (bottomTabs) => {
|
|
208
|
+
const fontSize = remsToPixels(bottomTabs.buttons.fontSize);
|
|
209
|
+
return {
|
|
210
|
+
box: Object.assign(Object.assign({}, bottomTabs.box), { borderRadius: remsToPixels(bottomTabs.box.borderRadius), borderWidth: remsToPixels(bottomTabs.box.borderWidth), gap: remsToPixels(bottomTabs.box.gap), padding: remsToPixels(bottomTabs.box.padding) }),
|
|
211
|
+
buttons: Object.assign(Object.assign({}, bottomTabs.buttons), { fontSize: fontSize, letterSpacing: remsToPixels(bottomTabs.buttons.letterSpacing), lineHeight: makeLineHeight(`${bottomTabs.buttons.lineHeight}`, fontSize), padding: remsToPixels(bottomTabs.buttons.padding) }),
|
|
212
|
+
icons: Object.assign(Object.assign({}, bottomTabs.icons), { padding: remsToPixels(bottomTabs.icons.padding) })
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
export const decorateTheme = (theme) => {
|
|
216
|
+
const logo = makeLogo(theme.logo);
|
|
217
|
+
const logoFooter = makeLogo(theme.logoFooter);
|
|
218
|
+
const fonts = makeFonts(theme.fonts, theme.lineHeight);
|
|
219
|
+
const lineHeight = makeLineHeight(theme.lineHeight, fonts.sizes.main);
|
|
220
|
+
const layout = objRemsToPixels(theme.layout);
|
|
221
|
+
const buttons = makeButtons(theme.buttons);
|
|
222
|
+
const border = makeBorder(theme.border);
|
|
223
|
+
const inputs = makeInputs(theme.inputs);
|
|
224
|
+
const counts = makeCounts(theme.counts);
|
|
225
|
+
const cards = makeCards(theme.cards);
|
|
226
|
+
const welcome = makeWelcome(theme.welcome);
|
|
227
|
+
const item = makeItem(theme.item);
|
|
228
|
+
const categories = makeCategories(theme.categories);
|
|
229
|
+
const menuItems = makeMenuItems(theme.menuItems, theme.lineHeight);
|
|
230
|
+
const modifiers = makeModifiers(theme.modifiers, theme.lineHeight);
|
|
231
|
+
const tags = makeTags(theme.tags);
|
|
232
|
+
const bottomTabs = makeBottomTabs(theme.bottomTabs);
|
|
233
|
+
return Object.assign(Object.assign({}, theme), { logo,
|
|
234
|
+
logoFooter, fonts: fonts, lineHeight, layout: layout, buttons: buttons, border, inputs: inputs, counts,
|
|
235
|
+
cards, welcome: welcome, item: item, categories,
|
|
236
|
+
menuItems,
|
|
237
|
+
modifiers,
|
|
238
|
+
tags,
|
|
239
|
+
bottomTabs });
|
|
240
|
+
};
|
|
241
|
+
export const hexToRgbA = (hex, opacity) => {
|
|
242
|
+
let c;
|
|
243
|
+
if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)) {
|
|
244
|
+
c = hex.substring(1).split('');
|
|
245
|
+
if (c.length === 3) {
|
|
246
|
+
c = [c[0], c[0], c[1], c[1], c[2], c[2]];
|
|
247
|
+
}
|
|
248
|
+
c = '0x' + c.join('');
|
|
249
|
+
return ('rgba(' +
|
|
250
|
+
[(c >> 16) & 255, (c >> 8) & 255, c & 255].join(',') +
|
|
251
|
+
`,${opacity})`);
|
|
252
|
+
}
|
|
253
|
+
return null;
|
|
254
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const maybeRefreshVersion: (open: (args: {
|
|
2
|
-
type: string;
|
|
3
|
-
args: Record<string, unknown>;
|
|
4
|
-
}) => void) => void;
|
|
1
|
+
export declare const maybeRefreshVersion: (open: (args: {
|
|
2
|
+
type: string;
|
|
3
|
+
args: Record<string, unknown>;
|
|
4
|
+
}) => void) => void;
|