@proximus/lavender-styling-native 0.1.0-alpha.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.
@@ -0,0 +1,69 @@
1
+ export declare const CommonSizes: {
2
+ AbsoluteBiggest: number;
3
+ Big: number;
4
+ Bigger: number;
5
+ Biggest: number;
6
+ Medium: number;
7
+ Small: number;
8
+ Smaller: number;
9
+ Smallest: number;
10
+ };
11
+ export declare const Sizes: {
12
+ NavigationBarHeight: number;
13
+ StatusHeight: number;
14
+ AlertPopupButton: number;
15
+ AlertPopupText: number;
16
+ AlertPopupTitle: number;
17
+ BubbleTitleSize: number;
18
+ ButtonTitleSize: number;
19
+ CardText: number;
20
+ CharLimitTextInput: number;
21
+ ContentMaxWidth: number;
22
+ ContentWidth: number;
23
+ CounterIconTextSize: number;
24
+ HeaderHeight: number;
25
+ HeaderSubtitleFontSize: number;
26
+ HeaderTitleFontSize: number;
27
+ IconSize: number;
28
+ InfoViewSize: number;
29
+ ListHeaderAndroid: number;
30
+ ListHeaderIOS: number;
31
+ ListItemInfoSubtitle: number;
32
+ ListItemInfoTitle: number;
33
+ ListItemNotificationTitle: number;
34
+ ListItemSecondSubtitle: number;
35
+ ListItemSubtitle: number;
36
+ ListItemSubtitleIOS: number;
37
+ ListItemTime: number;
38
+ ListItemTitle: number;
39
+ ListWithAvatarExplicitText: number;
40
+ NotificationMessage: number;
41
+ PromptPopupText: number;
42
+ PromptPopupTitle: number;
43
+ PxCompactPriceTextCurrencySize: number;
44
+ PxCompactPriceTextDigitsSize: number;
45
+ PxCompactPriceTextDurationSize: number;
46
+ PxCompactPriceTextUnitsSize: number;
47
+ PxMobilePricingPlanCardFirstLine: number;
48
+ PxMobilePricingPlanCardLine: number;
49
+ PxMobilePricingPlanCardTitle: number;
50
+ PxPriceButtonTextSize: number;
51
+ PxPriceTextSize: number;
52
+ PxPriceTextSizeMultiLine: number;
53
+ PxTextIconRightIconSize: number;
54
+ PxTextIconRightTextSize: number;
55
+ PxOptionCardIcon: number;
56
+ PxOptionCardSubtitle: number;
57
+ PxOptionCardTitle: number;
58
+ PxProgressBarText: number;
59
+ SmallInformativeSubtitleText: number;
60
+ SmallInformativeText: number;
61
+ TabBarIcon: number;
62
+ TextBodySize: number;
63
+ TextDisclaimerSize: number;
64
+ TextHeader2Size: number;
65
+ TextHeaderSize: number;
66
+ TopNotification: number;
67
+ UsageCardHeight: number;
68
+ };
69
+ //# sourceMappingURL=sizes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sizes.d.ts","sourceRoot":"","sources":["../src/sizes.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,WAAW;;;;;;;;;CASvB,CAAC;AAEF,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDjB,CAAC"}
@@ -0,0 +1,19 @@
1
+ export declare enum ThemeName {
2
+ MYPROXIMUS = "myproximus",
3
+ SCARLET = "scarlet"
4
+ }
5
+ export declare enum StatusType {
6
+ SUCCESS = "success",
7
+ ERROR = "error",
8
+ WARNING = "warning",
9
+ INFO = "info"
10
+ }
11
+ export interface ITheme {
12
+ name: ThemeName;
13
+ t: (key: string) => any;
14
+ }
15
+ export interface IThemeContext {
16
+ theme: ITheme;
17
+ setTheme?: (theme: ITheme) => void;
18
+ }
19
+ //# sourceMappingURL=themes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../src/themes.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,UAAU,eAAe;IACzB,OAAO,YAAY;CACpB;AAED,oBAAY,UAAU;IACpB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,IAAI,SAAS;CACd;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@proximus/lavender-styling-native",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "Commmon styling constants",
5
+ "main": "src/index.ts",
6
+ "type": "module",
7
+ "types": "dist/index.d.ts",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "scripts": {
12
+ "clean": "rm -rf dist",
13
+ "build": "npx tsc -p tsconfig.json",
14
+ "prepublish": "yarn clean && yarn build"
15
+ },
16
+ "dependencies": {
17
+ "@proximus/lavender-styling": "^1.1.0-alpha.14"
18
+ },
19
+ "lerna": {
20
+ "command": {
21
+ "publish": {
22
+ "assets": [
23
+ "dist",
24
+ "src",
25
+ "package.json"
26
+ ]
27
+ }
28
+ }
29
+ },
30
+ "gitHead": "59b3436b786cc1c73b4a20a98b2a85139e75b72e"
31
+ }
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+
3
+ export const AssetContainerContext = React.createContext<{
4
+ size?: number;
5
+ id?: string;
6
+ }>({});
7
+
8
+ export function useAssetContainer() {
9
+ const context = React.useContext(AssetContainerContext);
10
+
11
+ if (!context) {
12
+ throw new Error('useAssetContainer must be used within an AssetContainer');
13
+ }
14
+
15
+ return context;
16
+ }
17
+
18
+ export function AssetProvider({
19
+ children,
20
+ size,
21
+ id,
22
+ }: {
23
+ children: React.ReactNode;
24
+ size?: number;
25
+ id?: string;
26
+ }) {
27
+ return (
28
+ <AssetContainerContext.Provider value={{ size, id }}>
29
+ {children}
30
+ </AssetContainerContext.Provider>
31
+ );
32
+ }
@@ -0,0 +1,9 @@
1
+ import * as proximusTokens from '@proximus/lavender-styling/dist/js/proximus/themesTokens.js';
2
+ import { ITheme, ThemeName } from './themes';
3
+
4
+ export const myProximusTheme: ITheme = {
5
+ name: ThemeName.MYPROXIMUS,
6
+ t: (key: string) => {
7
+ return proximusTokens[key as keyof typeof proximusTokens];
8
+ },
9
+ };
@@ -0,0 +1,11 @@
1
+ import * as scarletTokens from '@proximus/lavender-styling/dist/js/scarlet/themesTokens.js';
2
+
3
+ //Added Proximus styles for scarlet also as most of the styles are inherited from proximus
4
+ import { ITheme, ThemeName } from './themes';
5
+
6
+ export const scarletTheme: ITheme = {
7
+ name: ThemeName.SCARLET,
8
+ t: (key: string) => {
9
+ return scarletTokens[key as keyof typeof scarletTokens];
10
+ },
11
+ };
@@ -0,0 +1,18 @@
1
+ import React, { useContext } from 'react';
2
+
3
+ import { type IThemeContext, ThemeName } from './themes';
4
+ import { myProximusTheme } from './ProximusTheme';
5
+
6
+ export const ThemeContext = React.createContext<IThemeContext>({
7
+ theme: myProximusTheme,
8
+ });
9
+
10
+ export function useTheme() {
11
+ const theme = useContext(ThemeContext);
12
+ return theme || {};
13
+ }
14
+
15
+ export function useIsThemeScarlet() {
16
+ const { theme } = useTheme();
17
+ return theme.name === ThemeName.SCARLET;
18
+ }
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { ComponentType, ReactElement, useState } from 'react';
3
+
4
+ import { ThemeContext, useTheme } from './ThemeContext';
5
+ import { ITheme } from './themes';
6
+
7
+ export function ThemeProvider({
8
+ theme,
9
+ children,
10
+ }: {
11
+ theme: ITheme;
12
+ children: ReactElement<any> | ReactElement<any>[];
13
+ }) {
14
+ const [themeValue, setTheme] = useState<ITheme>(theme);
15
+
16
+ return (
17
+ <ThemeContext.Provider
18
+ value={{
19
+ theme: themeValue,
20
+ setTheme,
21
+ }}
22
+ >
23
+ {children}
24
+ </ThemeContext.Provider>
25
+ );
26
+ }
27
+
28
+ export function withTheme<T>(WrappedComponent: ComponentType<T>) {
29
+ return (props: T) => {
30
+ const { theme, setTheme } = useTheme();
31
+ return (
32
+ <WrappedComponent {...props} theme={theme} onThemeChanged={setTheme} />
33
+ );
34
+ };
35
+ }
@@ -0,0 +1,168 @@
1
+ import {
2
+ IPHONE_SE_HEIGHT,
3
+ IPHONE_SE_WIDTH,
4
+ max,
5
+ media,
6
+ min,
7
+ MIN_HDPI,
8
+ MIN_IPHONE_4,
9
+ MIN_IPHONE_8,
10
+ MIN_IPHONE_PLUS,
11
+ MIN_IPHONE_SE,
12
+ MIN_IPHONE_XS,
13
+ MIN_IPHONE_XR,
14
+ MIN_MDPI,
15
+ MIN_XHDPI,
16
+ MIN_XXHDPI,
17
+ MIN_XXXHDPI,
18
+ MIN_GALAXY_S7,
19
+ MIN_GALAXY_S9,
20
+ MIN_GALAXY_S9_PLUS,
21
+ } from '../breakpoints';
22
+
23
+ describe('breakpoints test suite', () => {
24
+ let width: number;
25
+ let height: number;
26
+ let mediaquery: string;
27
+
28
+ it('should compute mediaquery properly', () => {
29
+ givenScreenResolution(IPHONE_SE_WIDTH, IPHONE_SE_HEIGHT);
30
+ whenComputingMediaQuery();
31
+ thenMediaQueryMustBe('@media (device-width: 320) and (device-height: 568)');
32
+ });
33
+
34
+ it('should compute minimum mediaquery properly', () => {
35
+ givenScreenResolution(IPHONE_SE_WIDTH, IPHONE_SE_HEIGHT);
36
+ whenComputingMinMediaQuery();
37
+ thenMediaQueryMustBe(
38
+ '@media (min-device-width: 320) and (min-device-height: 568)'
39
+ );
40
+ });
41
+
42
+ it('should compute maximum mediaquery properly', () => {
43
+ givenScreenResolution(IPHONE_SE_WIDTH, IPHONE_SE_HEIGHT);
44
+ whenComputingMaxMediaQuery();
45
+ thenMediaQueryMustBe(
46
+ '@media (max-device-width: 320) and (max-device-height: 568)'
47
+ );
48
+ });
49
+
50
+ it('should compute iphone SE mediaqueries properly', () => {
51
+ mediaquery = MIN_IPHONE_SE;
52
+ thenMediaQueryMustBe(
53
+ '@media (min-device-width: 320) and (min-device-height: 568)'
54
+ );
55
+ });
56
+
57
+ it('should compute iphone 4 mediaqueries properly', () => {
58
+ mediaquery = MIN_IPHONE_4;
59
+ thenMediaQueryMustBe(
60
+ '@media (min-device-width: 320) and (min-device-height: 480)'
61
+ );
62
+ });
63
+
64
+ it('should compute iphone 8 mediaqueries properly', () => {
65
+ mediaquery = MIN_IPHONE_8;
66
+ thenMediaQueryMustBe(
67
+ '@media (min-device-width: 375) and (min-device-height: 667)'
68
+ );
69
+ });
70
+
71
+ it('should compute iphone X mediaqueries properly', () => {
72
+ mediaquery = MIN_IPHONE_XS;
73
+ thenMediaQueryMustBe(
74
+ '@media (min-device-width: 375) and (min-device-height: 812)'
75
+ );
76
+ });
77
+
78
+ it('should compute iphone XR mediaqueries properly', () => {
79
+ mediaquery = MIN_IPHONE_XR;
80
+ thenMediaQueryMustBe(
81
+ '@media (min-device-width: 414) and (min-device-height: 896)'
82
+ );
83
+ });
84
+
85
+ it('should compute iphone Plus mediaqueries properly', () => {
86
+ mediaquery = MIN_IPHONE_PLUS;
87
+ thenMediaQueryMustBe(
88
+ '@media (min-device-width: 414) and (min-device-height: 736)'
89
+ );
90
+ });
91
+
92
+ it('should compute android MDPI mediaqueries properly', () => {
93
+ mediaquery = MIN_MDPI;
94
+ thenMediaQueryMustBe(
95
+ '@media (min-device-width: 320) and (min-device-height: 480)'
96
+ );
97
+ });
98
+
99
+ it('should compute android HDPI mediaqueries properly', () => {
100
+ mediaquery = MIN_HDPI;
101
+ thenMediaQueryMustBe(
102
+ '@media (min-device-width: 320) and (min-device-height: 533)'
103
+ );
104
+ });
105
+
106
+ it('should compute android XHDPI mediaqueries properly', () => {
107
+ mediaquery = MIN_XHDPI;
108
+ thenMediaQueryMustBe(
109
+ '@media (min-device-width: 360) and (min-device-height: 640)'
110
+ );
111
+ });
112
+
113
+ it('should compute android XXHDPI mediaqueries properly', () => {
114
+ mediaquery = MIN_XXHDPI;
115
+ thenMediaQueryMustBe(
116
+ '@media (min-device-width: 320) and (min-device-height: 533)'
117
+ );
118
+ });
119
+
120
+ it('should compute android XXXHDPI mediaqueries properly', () => {
121
+ mediaquery = MIN_XXXHDPI;
122
+ thenMediaQueryMustBe(
123
+ '@media (min-device-width: 360) and (min-device-height: 640)'
124
+ );
125
+ });
126
+
127
+ it('should compute iphone SE mediaqueries properly', () => {
128
+ mediaquery = MIN_GALAXY_S7;
129
+ thenMediaQueryMustBe(
130
+ '@media (min-device-width: 360) and (min-device-height: 640)'
131
+ );
132
+ });
133
+
134
+ it('should compute iphone SE mediaqueries properly', () => {
135
+ mediaquery = MIN_GALAXY_S9;
136
+ thenMediaQueryMustBe(
137
+ '@media (min-device-width: 360) and (min-device-height: 740)'
138
+ );
139
+ });
140
+
141
+ it('should compute iphone SE mediaqueries properly', () => {
142
+ mediaquery = MIN_GALAXY_S9_PLUS;
143
+ thenMediaQueryMustBe(
144
+ '@media (min-device-width: 412) and (min-device-height: 846)'
145
+ );
146
+ });
147
+
148
+ function givenScreenResolution(w: number, h: number) {
149
+ width = w;
150
+ height = h;
151
+ }
152
+
153
+ function whenComputingMediaQuery() {
154
+ mediaquery = media(width, height, '');
155
+ }
156
+
157
+ function whenComputingMinMediaQuery() {
158
+ mediaquery = min(width, height);
159
+ }
160
+
161
+ function whenComputingMaxMediaQuery() {
162
+ mediaquery = max(width, height);
163
+ }
164
+
165
+ function thenMediaQueryMustBe(mq: string) {
166
+ expect(mediaquery).toEqual(mq);
167
+ }
168
+ });
@@ -0,0 +1,96 @@
1
+ /* tslint:disable:max-line-length */
2
+ export const IPHONE_SE_WIDTH = 320;
3
+ export const IPHONE_SE_HEIGHT = 568;
4
+
5
+ export const IPHONE_4_WIDTH = 320;
6
+ export const IPHONE_4_HEIGHT = 480;
7
+
8
+ export const IPHONE_8_WIDTH = 375;
9
+ export const IPHONE_8_HEIGHT = 667;
10
+
11
+ export const IPHONE_XS_WIDTH = 375;
12
+ export const IPHONE_XS_HEIGHT = 812;
13
+
14
+ export const IPHONE_XR_WIDTH = 414;
15
+ export const IPHONE_XR_HEIGHT = 896;
16
+
17
+ export const IPHONE_PLUS_WIDTH = 414;
18
+ export const IPHONE_PLUS_HEIGHT = 736;
19
+
20
+ export const IPAD_MINI_WIDTH = 768;
21
+ export const IPAD_MINI_HEIGHT = 1024;
22
+
23
+ // https://stackoverflow.com/questions/28507609/image-resolution-for-mdpi-hdpi-xhdpi-and-xxhdpi
24
+ export const MDPI_WIDTH = 320;
25
+ export const MDPI_HEIGHT = 480;
26
+
27
+ export const HDPI_WIDTH = 320;
28
+ export const HDPI_HEIGHT = 533;
29
+
30
+ export const XHDPI_WIDTH = 360;
31
+ export const XHDPI_HEIGHT = 640;
32
+
33
+ export const XXHDPI_WIDTH = 320;
34
+ export const XXHDPI_HEIGHT = 533;
35
+
36
+ export const XXXHDPI_WIDTH = 360;
37
+ export const XXXHDPI_HEIGHT = 640;
38
+
39
+ // New sizes: Galaxy J3/J7/S6/S7 and Galaxy S8/S9 and Galaxy S8+/S9+
40
+
41
+ export const GALAXY_S7_WIDTH = 360;
42
+ export const GALAXY_S7_HEIGHT = 640;
43
+
44
+ export const GALAXY_S9_WIDTH = 360;
45
+ export const GALAXY_S9_HEIGHT = 740;
46
+
47
+ export const GALAXY_S9_PLUS_WIDTH = 412;
48
+ export const GALAXY_S9_PLUS_HEIGHT = 846;
49
+
50
+ export function media(width: number, height: number, fun: 'max' | 'min' | '') {
51
+ const deviceHeight = fun ? `${fun}-device-height` : 'device-height';
52
+ const deviceWidth = fun ? `${fun}-device-width` : 'device-width';
53
+ return `@media (${deviceWidth}: ${width}) and (${deviceHeight}: ${height})`;
54
+ }
55
+
56
+ export function max(width: number, height: number) {
57
+ return media(width, height, 'max');
58
+ }
59
+
60
+ export function min(width: number, height: number) {
61
+ return media(width, height, 'min');
62
+ }
63
+
64
+ export const MIN_IPHONE_SE = min(IPHONE_SE_WIDTH, IPHONE_SE_HEIGHT);
65
+ export const MIN_IPHONE_4 = min(IPHONE_4_WIDTH, IPHONE_4_HEIGHT);
66
+ export const MIN_IPHONE_8 = min(IPHONE_8_WIDTH, IPHONE_8_HEIGHT);
67
+ export const MIN_IPHONE_XS = min(IPHONE_XS_WIDTH, IPHONE_XS_HEIGHT);
68
+ export const MIN_IPHONE_XR = min(IPHONE_XR_WIDTH, IPHONE_XR_HEIGHT);
69
+ export const MIN_IPHONE_PLUS = min(IPHONE_PLUS_WIDTH, IPHONE_PLUS_HEIGHT);
70
+ export const MIN_IPAD_MINI = min(IPAD_MINI_WIDTH, IPAD_MINI_HEIGHT);
71
+
72
+ export const MIN_MDPI = min(MDPI_WIDTH, MDPI_HEIGHT);
73
+ export const MIN_HDPI = min(HDPI_WIDTH, HDPI_HEIGHT);
74
+ export const MIN_XHDPI = min(XHDPI_WIDTH, XHDPI_HEIGHT);
75
+ export const MIN_XXHDPI = min(XXHDPI_WIDTH, XXHDPI_HEIGHT);
76
+ export const MIN_XXXHDPI = min(XXXHDPI_WIDTH, XXXHDPI_HEIGHT);
77
+
78
+ export const MIN_GALAXY_S7 = min(GALAXY_S7_WIDTH, GALAXY_S7_HEIGHT);
79
+ export const MIN_GALAXY_S9 = min(GALAXY_S9_WIDTH, GALAXY_S9_HEIGHT);
80
+ export const MIN_GALAXY_S9_PLUS = min(
81
+ GALAXY_S9_PLUS_WIDTH,
82
+ GALAXY_S9_PLUS_HEIGHT
83
+ );
84
+
85
+ // We keep those one for backward compatibility
86
+ export const MEDIA_IPHONE_SE = max(IPHONE_SE_WIDTH, IPHONE_SE_HEIGHT);
87
+ export const MEDIA_IPHONE_4 = max(IPHONE_4_WIDTH, IPHONE_4_HEIGHT);
88
+ export const MEDIA_IPHONE_8 = max(IPHONE_8_WIDTH, IPHONE_8_HEIGHT);
89
+ export const MEDIA_IPHONE_XS = media(IPHONE_XS_WIDTH, IPHONE_XS_HEIGHT, '');
90
+ export const MEDIA_IPHONE_XR = media(IPHONE_XR_WIDTH, IPHONE_XR_HEIGHT, '');
91
+ export const MEDIA_IPHONE_PLUS = media(
92
+ IPHONE_PLUS_WIDTH,
93
+ IPHONE_PLUS_HEIGHT,
94
+ ''
95
+ );
96
+ export const MEDIA_IPHONE_X_PLUS = `@media (min-device-height: ${IPHONE_PLUS_HEIGHT})`;