@hero-design/rn 6.7.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,16 @@
1
+ const { getDefaultConfig } = require('expo/metro-config');
2
+ const path = require('path');
3
+
4
+ const workspaceRoot = path.resolve(__dirname, '../..');
5
+ const projectRoot = __dirname;
6
+
7
+ const config = getDefaultConfig(projectRoot);
8
+
9
+ config.watchFolders = [workspaceRoot];
10
+
11
+ config.resolver.nodeModulesPaths = [
12
+ path.resolve(projectRoot, 'node_modules'),
13
+ path.resolve(workspaceRoot, 'node_modules'),
14
+ ];
15
+
16
+ module.exports = config;
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@hero-design/rn",
3
+ "version": "6.7.0",
4
+ "license": "MIT",
5
+ "main": "lib/index.js",
6
+ "module": "es/index.js",
7
+ "scripts": {
8
+ "lint": "eslint src --ext .js,.jsx,.ts,.tsx --ignore-path ../../.gitignore",
9
+ "type-check": "tsc --noEmit",
10
+ "dev": "expo start",
11
+ "test": "jest --runInBand",
12
+ "build:js": "rollup -c",
13
+ "build:types": "tsc --noEmit false --emitDeclarationOnly",
14
+ "build": "yarn build:js && yarn build:types"
15
+ },
16
+ "dependencies": {
17
+ "@hero-design/colors": "^6.7.0",
18
+ "styled-components": "6.0.0-alpha.5"
19
+ },
20
+ "peerDependencies": {
21
+ "react": "17.0.2",
22
+ "react-native": "0.65.1"
23
+ },
24
+ "devDependencies": {
25
+ "@babel/core": "^7.17.5",
26
+ "@babel/preset-env": "^7.16.11",
27
+ "@babel/preset-react": "^7.16.7",
28
+ "@babel/preset-typescript": "^7.16.7",
29
+ "@rollup/plugin-babel": "^5.3.1",
30
+ "@rollup/plugin-commonjs": "^21.0.1",
31
+ "@rollup/plugin-json": "^4.1.0",
32
+ "@rollup/plugin-node-resolve": "^13.1.3",
33
+ "@rollup/plugin-replace": "^4.0.0",
34
+ "@rollup/plugin-typescript": "^8.3.0",
35
+ "@testing-library/jest-native": "^4.0.4",
36
+ "@testing-library/react-native": "^9.1.0",
37
+ "@types/jest": "^27.0.2",
38
+ "@types/react": "^17.0.39",
39
+ "@types/react-native": "^0.66.16",
40
+ "@types/styled-components": "^5.1.24",
41
+ "@types/styled-components-react-native": "^5.1.3",
42
+ "@typescript-eslint/eslint-plugin": "^5.12.1",
43
+ "@typescript-eslint/parser": "^5.12.1",
44
+ "eslint": "^8.9.0",
45
+ "eslint-config-airbnb": "^19.0.4",
46
+ "eslint-config-prettier": "^8.5.0",
47
+ "eslint-plugin-import": "^2.25.4",
48
+ "eslint-plugin-jsx-a11y": "^6.5.1",
49
+ "eslint-plugin-react": "^7.28.0",
50
+ "eslint-plugin-react-hooks": "^4.3.0",
51
+ "expo": "^44.0.6",
52
+ "jest": "^27.3.1",
53
+ "jest-styled-components": "^7.0.6",
54
+ "prettier": "^2.5.1",
55
+ "react": "17.0.2",
56
+ "react-native": "0.65.1",
57
+ "react-test-renderer": "17.0.2",
58
+ "rollup": "^2.68.0",
59
+ "ts-jest": "^27.0.7",
60
+ "typescript": "^4.5.5"
61
+ },
62
+ "nx": {
63
+ "targets": {
64
+ "lint": {
65
+ "dependsOn": [
66
+ {
67
+ "target": "build",
68
+ "projects": "dependencies"
69
+ }
70
+ ]
71
+ },
72
+ "type-check": {
73
+ "dependsOn": [
74
+ {
75
+ "target": "build:types",
76
+ "projects": "dependencies"
77
+ }
78
+ ]
79
+ }
80
+ }
81
+ }
82
+ }
@@ -0,0 +1,25 @@
1
+ import { SafeAreaView, View } from 'react-native';
2
+ import React from 'react';
3
+ import { theme, ThemeProvider, ExampleComponent } from '../src/index';
4
+
5
+ const App = () => (
6
+ <ThemeProvider theme={theme}>
7
+ <SafeAreaView
8
+ style={{
9
+ flex: 1,
10
+ justifyContent: 'center',
11
+ alignItems: 'center',
12
+ }}
13
+ >
14
+ <View
15
+ style={{
16
+ borderWidth: 1,
17
+ }}
18
+ >
19
+ <ExampleComponent boxSize="medium" boxSpace="medium" bgColor="danger" />
20
+ </View>
21
+ </SafeAreaView>
22
+ </ThemeProvider>
23
+ );
24
+
25
+ export default App;
@@ -0,0 +1,35 @@
1
+ import commonjs from '@rollup/plugin-commonjs';
2
+ import { nodeResolve } from '@rollup/plugin-node-resolve';
3
+ import { babel } from '@rollup/plugin-babel';
4
+ import typescript from '@rollup/plugin-typescript';
5
+ import json from '@rollup/plugin-json';
6
+ import replace from '@rollup/plugin-replace';
7
+
8
+ import pkg from './package.json';
9
+
10
+ const extensions = ['.js', '.jsx', '.ts', '.tsx'];
11
+
12
+ export default {
13
+ input: 'src/index.ts',
14
+ output: [
15
+ {
16
+ file: pkg.main,
17
+ format: 'cjs',
18
+ },
19
+ {
20
+ file: pkg.module,
21
+ format: 'esm',
22
+ },
23
+ ],
24
+ external: ['react', 'react-native'],
25
+ plugins: [
26
+ replace(({
27
+ 'process.env.NODE_ENV': JSON.stringify('production'),
28
+ })),
29
+ nodeResolve({ extensions, browser: true }),
30
+ commonjs(),
31
+ json(),
32
+ typescript(),
33
+ babel({ extensions, babelHelpers: 'bundled' }),
34
+ ],
35
+ };
@@ -0,0 +1,74 @@
1
+ import { View } from 'react-native';
2
+ import styled, { css } from 'styled-components/native';
3
+
4
+ export interface Props {
5
+ boxSize: 'small' | 'medium' | 'large';
6
+ boxSpace: 'small' | 'medium' | 'large';
7
+ bgColor: 'primary' | 'danger' | 'warning';
8
+ }
9
+
10
+ const Square = styled(View)<{
11
+ boxSize: Props['boxSize'];
12
+ boxSpace: Props['boxSpace'];
13
+ bgColor: Props['bgColor'];
14
+ }>`
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+
19
+ ${({ boxSize }) => {
20
+ switch (boxSize) {
21
+ case 'small':
22
+ return css`
23
+ height: 50px;
24
+ width: 200px;
25
+ `;
26
+ case 'medium':
27
+ return css`
28
+ height: 100px;
29
+ width: 250px;
30
+ `;
31
+ case 'large':
32
+ return css`
33
+ height: 150px;
34
+ width: 300px;
35
+ `;
36
+ }
37
+ }}
38
+
39
+ ${({ boxSpace, theme }) => {
40
+ switch (boxSpace) {
41
+ case 'small':
42
+ return css`
43
+ margin: ${theme.space.demoStyle.smallMargin}px;
44
+ `;
45
+ case 'medium':
46
+ return css`
47
+ margin: ${theme.space.demoStyle.mediumMargin}px;
48
+ `;
49
+ case 'large':
50
+ return css`
51
+ margin: ${theme.space.demoStyle.largeMargin}px;
52
+ `;
53
+ }
54
+ }}
55
+
56
+ ${({ bgColor, theme }) => {
57
+ switch (bgColor) {
58
+ case 'primary':
59
+ return css`
60
+ background-color: ${theme.colors.demoStyle.primaryBg};
61
+ `;
62
+ case 'danger':
63
+ return css`
64
+ background-color: ${theme.colors.demoStyle.dangerBg};
65
+ `;
66
+ case 'warning':
67
+ return css`
68
+ background-color: ${theme.colors.demoStyle.warningBg};
69
+ `;
70
+ }
71
+ }}
72
+ `;
73
+
74
+ export { Square };
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react-native';
3
+ import { ThemeProvider } from 'styled-components/native';
4
+ import theme from '../../../theme';
5
+ import { Square } from '../StyledView';
6
+
7
+ describe('StyledView', () => {
8
+ it('renders correct styling', () => {
9
+ const { toJSON } = render(
10
+ <ThemeProvider theme={theme}>
11
+ <Square boxSize="medium" boxSpace="medium" bgColor="primary" />
12
+ </ThemeProvider>
13
+ );
14
+
15
+ expect(toJSON()).toMatchSnapshot();
16
+ });
17
+ });
@@ -0,0 +1,23 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`StyledView renders correct styling 1`] = `
4
+ <View
5
+ bgColor="primary"
6
+ boxSize="medium"
7
+ boxSpace="medium"
8
+ style={
9
+ Object {
10
+ "alignItems": "center",
11
+ "backgroundColor": "#f1e9fb",
12
+ "display": "flex",
13
+ "height": 100,
14
+ "justifyContent": "center",
15
+ "marginBottom": 16,
16
+ "marginLeft": 16,
17
+ "marginRight": 16,
18
+ "marginTop": 16,
19
+ "width": 250,
20
+ }
21
+ }
22
+ />
23
+ `;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { Text } from 'react-native';
3
+ import { Square } from './StyledView';
4
+
5
+ interface Props {
6
+ /**
7
+ * Size.
8
+ */
9
+ boxSize: 'small' | 'medium' | 'large';
10
+ /**
11
+ * Margin.
12
+ */
13
+ boxSpace: 'small' | 'medium' | 'large';
14
+ /**
15
+ * Background color.
16
+ */
17
+ bgColor: 'primary' | 'danger' | 'warning';
18
+ }
19
+
20
+ const ExampleComponent = ({ boxSize = "small", boxSpace, bgColor }: Props) => (
21
+ <Square boxSize={boxSize} boxSpace={boxSpace} bgColor={bgColor}>
22
+ <Text>{`Square with ${boxSize} size, ${boxSpace} margin and ${bgColor} background.`}</Text>
23
+ </Square>
24
+ );
25
+
26
+ export default ExampleComponent;
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { ThemeProvider, useTheme } from 'styled-components/native';
2
+ import theme from './theme';
3
+
4
+ // Example components
5
+ import ExampleComponent from './components/ExampleComponent';
6
+
7
+ export { theme, useTheme, ThemeProvider, ExampleComponent };
@@ -0,0 +1,8 @@
1
+ import 'styled-components';
2
+
3
+ import { Theme } from './theme/index';
4
+
5
+ declare module 'styled-components' {
6
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
7
+ export interface DefaultTheme extends Theme {}
8
+ }
@@ -0,0 +1,16 @@
1
+ import { systemPalette } from '../global/colors';
2
+ import { space } from '../global/space';
3
+
4
+ const demoStyleColors = {
5
+ primaryBg: systemPalette.primaryBackground,
6
+ dangerBg: systemPalette.dangerBackground,
7
+ warningBg: systemPalette.warningBackground,
8
+ };
9
+
10
+ const demoStyleSpace = {
11
+ smallMargin: space.xxsmall,
12
+ mediumMargin: space.medium,
13
+ largeMargin: space.xxxxlarge,
14
+ };
15
+
16
+ export { demoStyleColors, demoStyleSpace };
@@ -0,0 +1,3 @@
1
+ import { palette, systemPalette } from '@hero-design/colors';
2
+
3
+ export { palette, systemPalette };
@@ -0,0 +1,15 @@
1
+ const BASE = 8;
2
+
3
+ const space = {
4
+ xxsmall: BASE * 0.25,
5
+ xsmall: BASE * 0.5,
6
+ small: BASE,
7
+ medium: BASE * 2,
8
+ large: BASE * 3,
9
+ xlarge: BASE * 4,
10
+ xxlarge: BASE * 5,
11
+ xxxlarge: BASE * 6,
12
+ xxxxlarge: BASE * 7,
13
+ };
14
+
15
+ export { space };
@@ -0,0 +1,22 @@
1
+ import { palette, systemPalette } from './global/colors';
2
+ import { space } from './global/space';
3
+
4
+ import { demoStyleColors, demoStyleSpace } from './components/demoStyle';
5
+
6
+ const theme = {
7
+ colors: {
8
+ ...palette,
9
+ ...systemPalette,
10
+ demoStyle: demoStyleColors,
11
+ },
12
+ space: {
13
+ ...space,
14
+ demoStyle: demoStyleSpace,
15
+ },
16
+ };
17
+
18
+ type Theme = typeof theme;
19
+
20
+ export { Theme };
21
+
22
+ export default theme;
package/tsconfig.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "declaration": true,
5
+ "outDir": "types",
6
+ "moduleResolution": "node",
7
+ "esModuleInterop": true,
8
+ "jsx": "react-native",
9
+ "strict": true,
10
+ "allowUnreachableCode": false,
11
+ "noImplicitReturns": true,
12
+ "noImplicitThis": true,
13
+ "noUnusedLocals": true,
14
+ "skipLibCheck": true
15
+ },
16
+ "include": [
17
+ "src"
18
+ ],
19
+ "exclude": [
20
+ "node_modules"
21
+ ],
22
+ "extends": "expo/tsconfig.base"
23
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "jsx": "react"
5
+ }
6
+ }
@@ -0,0 +1,12 @@
1
+ import { View } from 'react-native';
2
+ export interface Props {
3
+ boxSize: 'small' | 'medium' | 'large';
4
+ boxSpace: 'small' | 'medium' | 'large';
5
+ bgColor: 'primary' | 'danger' | 'warning';
6
+ }
7
+ declare const Square: import("styled-components").StyledComponent<typeof View, any, {
8
+ boxSize: Props['boxSize'];
9
+ boxSpace: Props['boxSpace'];
10
+ bgColor: Props['bgColor'];
11
+ }, never>;
12
+ export { Square };
@@ -0,0 +1,16 @@
1
+ interface Props {
2
+ /**
3
+ * Size.
4
+ */
5
+ boxSize: 'small' | 'medium' | 'large';
6
+ /**
7
+ * Margin.
8
+ */
9
+ boxSpace: 'small' | 'medium' | 'large';
10
+ /**
11
+ * Background color.
12
+ */
13
+ bgColor: 'primary' | 'danger' | 'warning';
14
+ }
15
+ declare const ExampleComponent: ({ boxSize, boxSpace, bgColor }: Props) => JSX.Element;
16
+ export default ExampleComponent;
@@ -0,0 +1,4 @@
1
+ import { ThemeProvider, useTheme } from 'styled-components/native';
2
+ import theme from './theme';
3
+ import ExampleComponent from './components/ExampleComponent';
4
+ export { theme, useTheme, ThemeProvider, ExampleComponent };
@@ -0,0 +1,11 @@
1
+ declare const demoStyleColors: {
2
+ primaryBg: string;
3
+ dangerBg: string;
4
+ warningBg: string;
5
+ };
6
+ declare const demoStyleSpace: {
7
+ smallMargin: number;
8
+ mediumMargin: number;
9
+ largeMargin: number;
10
+ };
11
+ export { demoStyleColors, demoStyleSpace };
@@ -0,0 +1,2 @@
1
+ import { palette, systemPalette } from '@hero-design/colors';
2
+ export { palette, systemPalette };
@@ -0,0 +1,12 @@
1
+ declare const space: {
2
+ xxsmall: number;
3
+ xsmall: number;
4
+ small: number;
5
+ medium: number;
6
+ large: number;
7
+ xlarge: number;
8
+ xxlarge: number;
9
+ xxxlarge: number;
10
+ xxxxlarge: number;
11
+ };
12
+ export { space };
@@ -0,0 +1,137 @@
1
+ declare const theme: {
2
+ colors: {
3
+ demoStyle: {
4
+ primaryBg: string;
5
+ dangerBg: string;
6
+ warningBg: string;
7
+ };
8
+ primary: string;
9
+ primaryDark: string;
10
+ primaryLight: string;
11
+ primaryBackground: string;
12
+ platformBackground: string;
13
+ backgroundDark: string;
14
+ backgroundLight: string;
15
+ info: string;
16
+ infoDark: string;
17
+ infoLight: string;
18
+ infoBackground: string;
19
+ success: string;
20
+ successDark: string;
21
+ successLight: string;
22
+ successBackground: string;
23
+ danger: string;
24
+ dangerDark: string;
25
+ dangerLight: string;
26
+ dangerBackground: string;
27
+ warning: string;
28
+ warningDark: string;
29
+ warningLight: string;
30
+ warningBackground: string;
31
+ error: string;
32
+ errorDark: string;
33
+ errorLight: string;
34
+ errorBackground: string;
35
+ headingText: string;
36
+ text: string;
37
+ subduedText: string;
38
+ disabledText: string;
39
+ outline: string;
40
+ disabledBackground: string;
41
+ black: string;
42
+ blue: string;
43
+ blueDark30: string;
44
+ blueDark75: string;
45
+ blueLight30: string;
46
+ blueLight75: string;
47
+ blueLight90: string;
48
+ dodgerBlue: string;
49
+ dodgerBlueDark30: string;
50
+ dodgerBlueLight30: string;
51
+ dodgerBlueLight90: string;
52
+ green: string;
53
+ greenDark15: string;
54
+ greenDark30: string;
55
+ greenDark75: string;
56
+ greenLight30: string;
57
+ greenLight90: string;
58
+ grey: string;
59
+ greyDark30: string;
60
+ greyDark45: string;
61
+ greyDark60: string;
62
+ greyDark75: string;
63
+ greyLight45: string;
64
+ greyLight60: string;
65
+ greyLight75: string;
66
+ greyLight85: string;
67
+ greyLight90: string;
68
+ grotesqueGreen: string;
69
+ grotesqueGreenDark45: string;
70
+ grotesqueGreenLight60: string;
71
+ grotesqueGreenLight75: string;
72
+ grotesqueGreenLight90: string;
73
+ orange: string;
74
+ orangeDark15: string;
75
+ orangeDark30: string;
76
+ orangeDark75: string;
77
+ orangeLight30: string;
78
+ orangeLight75: string;
79
+ orangeLight90: string;
80
+ pink: string;
81
+ pinkDark15: string;
82
+ pinkDark30: string;
83
+ pinkDark45: string;
84
+ pinkDark75: string;
85
+ pinkLight30: string;
86
+ pinkLight45: string;
87
+ pinkLight75: string;
88
+ pinkLight90: string;
89
+ purple: string;
90
+ red: string;
91
+ redDark15: string;
92
+ redDark30: string;
93
+ redDark75: string;
94
+ redLight30: string;
95
+ redLight75: string;
96
+ redLight90: string;
97
+ smalt: string;
98
+ smaltDark75: string;
99
+ smaltLight30: string;
100
+ smaltLight45: string;
101
+ smaltLight90: string;
102
+ violet: string;
103
+ violetDark15: string;
104
+ violetDark30: string;
105
+ violetDark45: string;
106
+ violetDark75: string;
107
+ violetLight30: string;
108
+ violetLight60: string;
109
+ violetLight75: string;
110
+ violetLight90: string;
111
+ white: string;
112
+ yellow: string;
113
+ yellowDark15: string;
114
+ yellowDark75: string;
115
+ yellowLight60: string;
116
+ yellowLight90: string;
117
+ };
118
+ space: {
119
+ demoStyle: {
120
+ smallMargin: number;
121
+ mediumMargin: number;
122
+ largeMargin: number;
123
+ };
124
+ xxsmall: number;
125
+ xsmall: number;
126
+ small: number;
127
+ medium: number;
128
+ large: number;
129
+ xlarge: number;
130
+ xxlarge: number;
131
+ xxxlarge: number;
132
+ xxxxlarge: number;
133
+ };
134
+ };
135
+ declare type Theme = typeof theme;
136
+ export { Theme };
137
+ export default theme;