@open-tender/utils 0.3.5 → 0.3.7
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/dist/cjs/__tests__/utils/theme.test.d.ts +1 -0
- package/dist/cjs/__tests__/utils/theme.test.js +37 -0
- package/dist/cjs/utils/maps.d.ts +12 -1
- package/dist/cjs/utils/maps.js +79 -1
- package/dist/cjs/utils/theme.js +22 -6
- package/dist/esm/__tests__/utils/helpers.test.js +1 -1
- package/dist/esm/__tests__/utils/theme.test.d.ts +1 -0
- package/dist/esm/__tests__/utils/theme.test.js +35 -0
- package/dist/esm/utils/maps.d.ts +12 -1
- package/dist/esm/utils/maps.js +77 -0
- package/dist/esm/utils/theme.js +22 -6
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../../utils");
|
|
4
|
+
describe('remsToPixels', () => {
|
|
5
|
+
it('should return 0 if rems is undefined', () => {
|
|
6
|
+
expect((0, utils_1.remsToPixels)()).toBe('0');
|
|
7
|
+
});
|
|
8
|
+
it('should return 0 without unit if rems is 0', () => {
|
|
9
|
+
expect((0, utils_1.remsToPixels)('0')).toBe('0');
|
|
10
|
+
});
|
|
11
|
+
it('should convert rems to pixels for single values without unit', () => {
|
|
12
|
+
expect((0, utils_1.remsToPixels)('1')).toBe('10px');
|
|
13
|
+
expect((0, utils_1.remsToPixels)('1.5')).toBe('15px');
|
|
14
|
+
expect((0, utils_1.remsToPixels)('2')).toBe('20px');
|
|
15
|
+
expect((0, utils_1.remsToPixels)('2.5')).toBe('25px');
|
|
16
|
+
});
|
|
17
|
+
it('should convert rems to pixels for single values', () => {
|
|
18
|
+
expect((0, utils_1.remsToPixels)('1rem')).toBe('10px');
|
|
19
|
+
expect((0, utils_1.remsToPixels)('1.5rem')).toBe('15px');
|
|
20
|
+
expect((0, utils_1.remsToPixels)('2rem')).toBe('20px');
|
|
21
|
+
expect((0, utils_1.remsToPixels)('2.5rem')).toBe('25px');
|
|
22
|
+
});
|
|
23
|
+
it('should preseve negative values', () => {
|
|
24
|
+
expect((0, utils_1.remsToPixels)('-1rem')).toBe('-10px');
|
|
25
|
+
expect((0, utils_1.remsToPixels)('-1.5rem')).toBe('-15px');
|
|
26
|
+
});
|
|
27
|
+
it('should convert multiple values rems to pixels', () => {
|
|
28
|
+
expect((0, utils_1.remsToPixels)('1rem 2rem')).toBe('10px 20px');
|
|
29
|
+
expect((0, utils_1.remsToPixels)('1rem 2rem 3rem')).toBe('10px 20px 30px');
|
|
30
|
+
expect((0, utils_1.remsToPixels)('1rem 2rem 3rem 4rem')).toBe('10px 20px 30px 40px');
|
|
31
|
+
});
|
|
32
|
+
it('should ignore whitespaces around the input', () => {
|
|
33
|
+
expect((0, utils_1.remsToPixels)(' ')).toBe('0');
|
|
34
|
+
expect((0, utils_1.remsToPixels)(' 1.5rem ')).toBe('15px');
|
|
35
|
+
expect((0, utils_1.remsToPixels)(' 1.5rem 2rem')).toBe('15px 20px');
|
|
36
|
+
});
|
|
37
|
+
});
|
package/dist/cjs/utils/maps.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address, LatLng, RevenueCenter, RevenueCenters, ServiceType } from '@open-tender/types';
|
|
1
|
+
import { Address, GoogleMapsStyles, LatLng, RevenueCenter, RevenueCenters, ServiceType } from '@open-tender/types';
|
|
2
2
|
export declare const getDistance: (pointA: LatLng, pointB: LatLng, inMiles?: boolean) => number;
|
|
3
3
|
export declare const inZone: (latLng: LatLng, polygon: number[][]) => boolean;
|
|
4
4
|
export declare const addDistance: (revenueCenters: RevenueCenters, latLng: LatLng) => RevenueCenters;
|
|
@@ -213,3 +213,14 @@ export declare const LOCATIONS_MESSAGES: {
|
|
|
213
213
|
};
|
|
214
214
|
};
|
|
215
215
|
export declare const renameLocation: (str: string, names: string[]) => string;
|
|
216
|
+
export declare const makeMapStyles: ({ labelColor, roadColor, featureColor, waterColor, backgroundColor }: GoogleMapsStyles) => {
|
|
217
|
+
featureType: string;
|
|
218
|
+
elementType: string;
|
|
219
|
+
stylers: ({
|
|
220
|
+
visibility: string;
|
|
221
|
+
color?: undefined;
|
|
222
|
+
} | {
|
|
223
|
+
color: string;
|
|
224
|
+
visibility?: undefined;
|
|
225
|
+
})[];
|
|
226
|
+
}[];
|
package/dist/cjs/utils/maps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renameLocation = exports.LOCATIONS_MESSAGES = exports.makeDisplayedRevenueCenters = exports.makeDeliveryMesssaging = exports.makeWalkinMessaging = exports.makePickupMesssaging = exports.makeDeliveryRevenueCenters = exports.makeWalkinRevenueCenters = exports.makePickupRevenueCenters = exports.checkServiceType = exports.calcMinDistance = exports.sortRevenueCenters = exports.addDistance = exports.inZone = exports.getDistance = void 0;
|
|
3
|
+
exports.makeMapStyles = exports.renameLocation = exports.LOCATIONS_MESSAGES = exports.makeDisplayedRevenueCenters = exports.makeDeliveryMesssaging = exports.makeWalkinMessaging = exports.makePickupMesssaging = exports.makeDeliveryRevenueCenters = exports.makeWalkinRevenueCenters = exports.makePickupRevenueCenters = exports.checkServiceType = exports.calcMinDistance = exports.sortRevenueCenters = exports.addDistance = exports.inZone = exports.getDistance = void 0;
|
|
4
4
|
const constants_1 = require("./constants");
|
|
5
5
|
const RADIUS_MILES = 3959; // radius of the earth in miles
|
|
6
6
|
const RADIUS_KM = 6371; // radius of the earth in kilometers
|
|
@@ -254,3 +254,81 @@ const renameLocation = (str, names) => {
|
|
|
254
254
|
.replace(' a u', ' an u');
|
|
255
255
|
};
|
|
256
256
|
exports.renameLocation = renameLocation;
|
|
257
|
+
const makeMapStyles = ({ labelColor, roadColor, featureColor, waterColor, backgroundColor }) => [
|
|
258
|
+
{
|
|
259
|
+
featureType: 'transit',
|
|
260
|
+
elementType: 'all',
|
|
261
|
+
stylers: [{ visibility: 'off' }]
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
featureType: 'administrative',
|
|
265
|
+
elementType: 'labels.text.fill',
|
|
266
|
+
stylers: [{ visibility: 'off' }]
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
featureType: 'administrative',
|
|
270
|
+
elementType: 'labels.text.stroke',
|
|
271
|
+
stylers: [{ visibility: 'off' }]
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
featureType: 'road',
|
|
275
|
+
elementType: 'labels.icon',
|
|
276
|
+
stylers: [{ visibility: 'off' }]
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
featureType: 'road',
|
|
280
|
+
elementType: 'geometry',
|
|
281
|
+
stylers: [{ visibility: 'simplified' }, { color: roadColor }]
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
featureType: 'road',
|
|
285
|
+
elementType: 'labels.text.fill',
|
|
286
|
+
stylers: [{ color: labelColor }]
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
featureType: 'road',
|
|
290
|
+
elementType: 'labels.text.stroke',
|
|
291
|
+
stylers: [{ visibility: 'off' }]
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
featureType: 'road.highway',
|
|
295
|
+
elementType: 'geometry',
|
|
296
|
+
stylers: [{ color: featureColor }]
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
featureType: 'road.highway',
|
|
300
|
+
elementType: 'labels',
|
|
301
|
+
stylers: [{ visibility: 'off' }]
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
featureType: 'water',
|
|
305
|
+
elementType: 'geometry',
|
|
306
|
+
stylers: [{ color: waterColor }]
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
featureType: 'water',
|
|
310
|
+
elementType: 'labels',
|
|
311
|
+
stylers: [{ visibility: 'off' }]
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
featureType: 'poi',
|
|
315
|
+
elementType: 'geometry',
|
|
316
|
+
stylers: [{ color: backgroundColor }]
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
featureType: 'poi',
|
|
320
|
+
elementType: 'labels',
|
|
321
|
+
stylers: [{ visibility: 'off' }]
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
featureType: 'landscape',
|
|
325
|
+
elementType: 'geometry',
|
|
326
|
+
stylers: [{ color: backgroundColor }]
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
featureType: 'landscape',
|
|
330
|
+
elementType: 'labels',
|
|
331
|
+
stylers: [{ visibility: 'off' }]
|
|
332
|
+
}
|
|
333
|
+
];
|
|
334
|
+
exports.makeMapStyles = makeMapStyles;
|
package/dist/cjs/utils/theme.js
CHANGED
|
@@ -7,13 +7,21 @@ const makeLineHeight = (lineHeight, fontSize) => {
|
|
|
7
7
|
return `${(parseFloat(lineHeight !== null && lineHeight !== void 0 ? lineHeight : '0') * size).toFixed(3)}px`;
|
|
8
8
|
};
|
|
9
9
|
exports.makeLineHeight = makeLineHeight;
|
|
10
|
+
// TODO: remove responsive option
|
|
10
11
|
const remsToPixels = (rems, responsive = false) => {
|
|
11
|
-
|
|
12
|
+
const cleanedUpRems = rems === null || rems === void 0 ? void 0 : rems.trim().replace(/\s+/g, ' ');
|
|
13
|
+
if (!cleanedUpRems)
|
|
12
14
|
return '0';
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const remsToPixelsSingleValue = (remsValue) => {
|
|
16
|
+
const pixels = parseFloat(remsValue.replace('rem', '')) * 10;
|
|
17
|
+
const adjustedPixels = responsive ? pixels : pixels;
|
|
18
|
+
const noZeroes = parseFloat(adjustedPixels.toFixed(2)).toString();
|
|
19
|
+
return noZeroes === '0' ? '0' : `${noZeroes}px`;
|
|
20
|
+
};
|
|
21
|
+
return cleanedUpRems
|
|
22
|
+
.split(' ')
|
|
23
|
+
.map(i => remsToPixelsSingleValue(i))
|
|
24
|
+
.join(' ');
|
|
17
25
|
};
|
|
18
26
|
exports.remsToPixels = remsToPixels;
|
|
19
27
|
const remsToNumber = (rems) => {
|
|
@@ -48,6 +56,9 @@ const paddingToPixels = (padding) => {
|
|
|
48
56
|
const [top, horizontal, bottom] = padding.split(' ');
|
|
49
57
|
return `${(0, exports.remsToPixels)(top)} ${(0, exports.remsToPixels)(horizontal)} ${(0, exports.remsToPixels)(bottom)}`;
|
|
50
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated use remsToPixels instead
|
|
61
|
+
*/
|
|
51
62
|
const boxRemsToPixels = (box) => {
|
|
52
63
|
const pixels = box
|
|
53
64
|
.split(' ')
|
|
@@ -191,6 +202,9 @@ const makeModifiers = (modifiers, lineHeight) => {
|
|
|
191
202
|
const { box, calories, content, image, price, text, title } = modifiers;
|
|
192
203
|
return Object.assign(Object.assign({}, modifiers), { box: Object.assign(Object.assign({}, box), { border: boxRemsToPixels(box.border), borderMobile: boxRemsToPixels(box.borderMobile), borderRadius: (0, exports.remsToPixels)(box.borderRadius), gap: (0, exports.remsToPixels)(box.gap), gapHalf: (0, exports.remsToPixels)(box.gapHalf), margin: boxRemsToPixels(box.margin), marginMobile: boxRemsToPixels(box.marginMobile), minHeight: (0, exports.remsToPixels)(box.minHeight), minHeightWithGap: (0, exports.remsToPixels)(box.minHeightWithGap), minWidth: (0, exports.remsToPixels)(box.minWidth), padding: boxRemsToPixels(box.padding), paddingMobile: boxRemsToPixels(box.paddingMobile) }), calories: Object.assign(Object.assign({}, calories), { fontSize: (0, exports.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: (0, exports.remsToPixels)(image.borderRadius), height: (0, exports.remsToPixels)(image.height), margin: boxRemsToPixels(image.margin), padding: boxRemsToPixels(image.padding), width: (0, exports.remsToPixels)(image.width) }), price: Object.assign(Object.assign({}, price), { fontSize: (0, exports.remsToPixels)(price.fontSize), lineHeight: fontSizeToLineHeight(price.fontSize, lineHeight) }), text: Object.assign(Object.assign({}, text), { fontSize: (0, exports.remsToPixels)(text.fontSize), lineHeight: fontSizeToLineHeight(text.fontSize, lineHeight) }), title: Object.assign(Object.assign({}, title), { fontSize: (0, exports.remsToPixels)(title.fontSize), lineHeight: fontSizeToLineHeight(title.fontSize, lineHeight) }) });
|
|
193
204
|
};
|
|
205
|
+
const makeTags = (tags) => {
|
|
206
|
+
return Object.assign(Object.assign({}, tags), { image: Object.assign(Object.assign({}, tags.image), { padding: (0, exports.remsToPixels)(tags.container.padding), paddingMobile: (0, exports.remsToPixels)(tags.container.paddingMobile), margin: (0, exports.remsToPixels)(tags.container.margin), marginMobile: (0, exports.remsToPixels)(tags.container.marginMobile) }), container: Object.assign(Object.assign({}, tags.container), { padding: (0, exports.remsToPixels)(tags.container.padding), paddingMobile: (0, exports.remsToPixels)(tags.container.paddingMobile), margin: (0, exports.remsToPixels)(tags.container.margin), marginMobile: (0, exports.remsToPixels)(tags.container.marginMobile) }), box: Object.assign(Object.assign({}, tags.box), { padding: (0, exports.remsToPixels)(tags.box.padding), paddingMobile: (0, exports.remsToPixels)(tags.box.paddingMobile), margin: (0, exports.remsToPixels)(tags.box.margin), marginMobile: (0, exports.remsToPixels)(tags.box.marginMobile) }), text: Object.assign(Object.assign({}, tags.text), { fontSize: (0, exports.remsToPixels)(tags.text.fontSize), fontSizeMobile: (0, exports.remsToPixels)(tags.text.fontSizeMobile) }) });
|
|
207
|
+
};
|
|
194
208
|
const makeLogo = (logo) => {
|
|
195
209
|
return {
|
|
196
210
|
marginTop: (0, exports.remsToPixels)(logo.marginTop),
|
|
@@ -215,11 +229,13 @@ const decorateTheme = (theme) => {
|
|
|
215
229
|
const categories = makeCategories(theme.categories);
|
|
216
230
|
const menuItems = makeMenuItems(theme.menuItems, theme.lineHeight);
|
|
217
231
|
const modifiers = makeModifiers(theme.modifiers, theme.lineHeight);
|
|
232
|
+
const tags = makeTags(theme.tags);
|
|
218
233
|
return Object.assign(Object.assign({}, theme), { logo,
|
|
219
234
|
logoFooter, fonts: fonts, lineHeight, layout: layout, buttons: buttons, border, inputs: inputs, counts,
|
|
220
235
|
cards, welcome: welcome, item: item, categories,
|
|
221
236
|
menuItems,
|
|
222
|
-
modifiers
|
|
237
|
+
modifiers,
|
|
238
|
+
tags });
|
|
223
239
|
};
|
|
224
240
|
exports.decorateTheme = decorateTheme;
|
|
225
241
|
const hexToRgbA = (hex, opacity) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatPercentage, formatQuantity } from
|
|
1
|
+
import { formatPercentage, formatQuantity } from '../../utils';
|
|
2
2
|
describe('formatPercentage', () => {
|
|
3
3
|
it('formats percentage when decimal is undefined', () => {
|
|
4
4
|
expect(formatPercentage('0')).toBe('0');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { remsToPixels } from '../../utils';
|
|
2
|
+
describe('remsToPixels', () => {
|
|
3
|
+
it('should return 0 if rems is undefined', () => {
|
|
4
|
+
expect(remsToPixels()).toBe('0');
|
|
5
|
+
});
|
|
6
|
+
it('should return 0 without unit if rems is 0', () => {
|
|
7
|
+
expect(remsToPixels('0')).toBe('0');
|
|
8
|
+
});
|
|
9
|
+
it('should convert rems to pixels for single values without unit', () => {
|
|
10
|
+
expect(remsToPixels('1')).toBe('10px');
|
|
11
|
+
expect(remsToPixels('1.5')).toBe('15px');
|
|
12
|
+
expect(remsToPixels('2')).toBe('20px');
|
|
13
|
+
expect(remsToPixels('2.5')).toBe('25px');
|
|
14
|
+
});
|
|
15
|
+
it('should convert rems to pixels for single values', () => {
|
|
16
|
+
expect(remsToPixels('1rem')).toBe('10px');
|
|
17
|
+
expect(remsToPixels('1.5rem')).toBe('15px');
|
|
18
|
+
expect(remsToPixels('2rem')).toBe('20px');
|
|
19
|
+
expect(remsToPixels('2.5rem')).toBe('25px');
|
|
20
|
+
});
|
|
21
|
+
it('should preseve negative values', () => {
|
|
22
|
+
expect(remsToPixels('-1rem')).toBe('-10px');
|
|
23
|
+
expect(remsToPixels('-1.5rem')).toBe('-15px');
|
|
24
|
+
});
|
|
25
|
+
it('should convert multiple values rems to pixels', () => {
|
|
26
|
+
expect(remsToPixels('1rem 2rem')).toBe('10px 20px');
|
|
27
|
+
expect(remsToPixels('1rem 2rem 3rem')).toBe('10px 20px 30px');
|
|
28
|
+
expect(remsToPixels('1rem 2rem 3rem 4rem')).toBe('10px 20px 30px 40px');
|
|
29
|
+
});
|
|
30
|
+
it('should ignore whitespaces around the input', () => {
|
|
31
|
+
expect(remsToPixels(' ')).toBe('0');
|
|
32
|
+
expect(remsToPixels(' 1.5rem ')).toBe('15px');
|
|
33
|
+
expect(remsToPixels(' 1.5rem 2rem')).toBe('15px 20px');
|
|
34
|
+
});
|
|
35
|
+
});
|
package/dist/esm/utils/maps.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address, LatLng, RevenueCenter, RevenueCenters, ServiceType } from '@open-tender/types';
|
|
1
|
+
import { Address, GoogleMapsStyles, LatLng, RevenueCenter, RevenueCenters, ServiceType } from '@open-tender/types';
|
|
2
2
|
export declare const getDistance: (pointA: LatLng, pointB: LatLng, inMiles?: boolean) => number;
|
|
3
3
|
export declare const inZone: (latLng: LatLng, polygon: number[][]) => boolean;
|
|
4
4
|
export declare const addDistance: (revenueCenters: RevenueCenters, latLng: LatLng) => RevenueCenters;
|
|
@@ -213,3 +213,14 @@ export declare const LOCATIONS_MESSAGES: {
|
|
|
213
213
|
};
|
|
214
214
|
};
|
|
215
215
|
export declare const renameLocation: (str: string, names: string[]) => string;
|
|
216
|
+
export declare const makeMapStyles: ({ labelColor, roadColor, featureColor, waterColor, backgroundColor }: GoogleMapsStyles) => {
|
|
217
|
+
featureType: string;
|
|
218
|
+
elementType: string;
|
|
219
|
+
stylers: ({
|
|
220
|
+
visibility: string;
|
|
221
|
+
color?: undefined;
|
|
222
|
+
} | {
|
|
223
|
+
color: string;
|
|
224
|
+
visibility?: undefined;
|
|
225
|
+
})[];
|
|
226
|
+
}[];
|
package/dist/esm/utils/maps.js
CHANGED
|
@@ -237,3 +237,80 @@ export const renameLocation = (str, names) => {
|
|
|
237
237
|
.replace(' a o', ' an o')
|
|
238
238
|
.replace(' a u', ' an u');
|
|
239
239
|
};
|
|
240
|
+
export const makeMapStyles = ({ labelColor, roadColor, featureColor, waterColor, backgroundColor }) => [
|
|
241
|
+
{
|
|
242
|
+
featureType: 'transit',
|
|
243
|
+
elementType: 'all',
|
|
244
|
+
stylers: [{ visibility: 'off' }]
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
featureType: 'administrative',
|
|
248
|
+
elementType: 'labels.text.fill',
|
|
249
|
+
stylers: [{ visibility: 'off' }]
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
featureType: 'administrative',
|
|
253
|
+
elementType: 'labels.text.stroke',
|
|
254
|
+
stylers: [{ visibility: 'off' }]
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
featureType: 'road',
|
|
258
|
+
elementType: 'labels.icon',
|
|
259
|
+
stylers: [{ visibility: 'off' }]
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
featureType: 'road',
|
|
263
|
+
elementType: 'geometry',
|
|
264
|
+
stylers: [{ visibility: 'simplified' }, { color: roadColor }]
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
featureType: 'road',
|
|
268
|
+
elementType: 'labels.text.fill',
|
|
269
|
+
stylers: [{ color: labelColor }]
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
featureType: 'road',
|
|
273
|
+
elementType: 'labels.text.stroke',
|
|
274
|
+
stylers: [{ visibility: 'off' }]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
featureType: 'road.highway',
|
|
278
|
+
elementType: 'geometry',
|
|
279
|
+
stylers: [{ color: featureColor }]
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
featureType: 'road.highway',
|
|
283
|
+
elementType: 'labels',
|
|
284
|
+
stylers: [{ visibility: 'off' }]
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
featureType: 'water',
|
|
288
|
+
elementType: 'geometry',
|
|
289
|
+
stylers: [{ color: waterColor }]
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
featureType: 'water',
|
|
293
|
+
elementType: 'labels',
|
|
294
|
+
stylers: [{ visibility: 'off' }]
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
featureType: 'poi',
|
|
298
|
+
elementType: 'geometry',
|
|
299
|
+
stylers: [{ color: backgroundColor }]
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
featureType: 'poi',
|
|
303
|
+
elementType: 'labels',
|
|
304
|
+
stylers: [{ visibility: 'off' }]
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
featureType: 'landscape',
|
|
308
|
+
elementType: 'geometry',
|
|
309
|
+
stylers: [{ color: backgroundColor }]
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
featureType: 'landscape',
|
|
313
|
+
elementType: 'labels',
|
|
314
|
+
stylers: [{ visibility: 'off' }]
|
|
315
|
+
}
|
|
316
|
+
];
|
package/dist/esm/utils/theme.js
CHANGED
|
@@ -3,13 +3,21 @@ export const makeLineHeight = (lineHeight, fontSize) => {
|
|
|
3
3
|
const size = parseInt((_a = fontSize === null || fontSize === void 0 ? void 0 : fontSize.replace('px', '')) !== null && _a !== void 0 ? _a : '0');
|
|
4
4
|
return `${(parseFloat(lineHeight !== null && lineHeight !== void 0 ? lineHeight : '0') * size).toFixed(3)}px`;
|
|
5
5
|
};
|
|
6
|
+
// TODO: remove responsive option
|
|
6
7
|
export const remsToPixels = (rems, responsive = false) => {
|
|
7
|
-
|
|
8
|
+
const cleanedUpRems = rems === null || rems === void 0 ? void 0 : rems.trim().replace(/\s+/g, ' ');
|
|
9
|
+
if (!cleanedUpRems)
|
|
8
10
|
return '0';
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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(' ');
|
|
13
21
|
};
|
|
14
22
|
export const remsToNumber = (rems) => {
|
|
15
23
|
return parseFloat(rems.replace('rem', '')) * 10;
|
|
@@ -39,6 +47,9 @@ const paddingToPixels = (padding) => {
|
|
|
39
47
|
const [top, horizontal, bottom] = padding.split(' ');
|
|
40
48
|
return `${remsToPixels(top)} ${remsToPixels(horizontal)} ${remsToPixels(bottom)}`;
|
|
41
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated use remsToPixels instead
|
|
52
|
+
*/
|
|
42
53
|
const boxRemsToPixels = (box) => {
|
|
43
54
|
const pixels = box
|
|
44
55
|
.split(' ')
|
|
@@ -182,6 +193,9 @@ const makeModifiers = (modifiers, lineHeight) => {
|
|
|
182
193
|
const { box, calories, content, image, price, text, title } = modifiers;
|
|
183
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) }) });
|
|
184
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
|
+
};
|
|
185
199
|
const makeLogo = (logo) => {
|
|
186
200
|
return {
|
|
187
201
|
marginTop: remsToPixels(logo.marginTop),
|
|
@@ -206,11 +220,13 @@ export const decorateTheme = (theme) => {
|
|
|
206
220
|
const categories = makeCategories(theme.categories);
|
|
207
221
|
const menuItems = makeMenuItems(theme.menuItems, theme.lineHeight);
|
|
208
222
|
const modifiers = makeModifiers(theme.modifiers, theme.lineHeight);
|
|
223
|
+
const tags = makeTags(theme.tags);
|
|
209
224
|
return Object.assign(Object.assign({}, theme), { logo,
|
|
210
225
|
logoFooter, fonts: fonts, lineHeight, layout: layout, buttons: buttons, border, inputs: inputs, counts,
|
|
211
226
|
cards, welcome: welcome, item: item, categories,
|
|
212
227
|
menuItems,
|
|
213
|
-
modifiers
|
|
228
|
+
modifiers,
|
|
229
|
+
tags });
|
|
214
230
|
};
|
|
215
231
|
export const hexToRgbA = (hex, opacity) => {
|
|
216
232
|
let c;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"private": false,
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@emotion/react": "^11.10.4",
|
|
39
|
+
"@open-tender/types": "^0.3.10",
|
|
39
40
|
"@reduxjs/toolkit": "^1.8.5",
|
|
40
41
|
"@types/google.maps": "^3.53.5",
|
|
41
42
|
"@types/jest": "^29.5.11",
|