@hero-design/rn 6.7.4-1 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.eslintrc.json +11 -2
  2. package/app.json +4 -0
  3. package/babel.config.js +15 -1
  4. package/es/index.js +96 -50
  5. package/jest.config.js +4 -0
  6. package/lib/index.js +96 -49
  7. package/package.json +16 -6
  8. package/playground/components/Card.tsx +52 -0
  9. package/playground/components/Divider.tsx +13 -0
  10. package/playground/index.tsx +4 -2
  11. package/src/components/Card/StyledCard.tsx +9 -0
  12. package/src/components/Card/__tests__/Card.spec.tsx +36 -0
  13. package/src/components/{ExampleComponent/__tests__/StyledView.spec.tsx → Card/__tests__/StyledCard.spec.tsx} +4 -9
  14. package/src/components/Card/__tests__/__snapshots__/Card.spec.tsx.snap +39 -0
  15. package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +18 -0
  16. package/src/components/Card/index.tsx +9 -0
  17. package/src/components/Divider/StyledDivider.tsx +70 -0
  18. package/src/components/Divider/__tests__/StyledDivider.spec.tsx +42 -0
  19. package/src/components/Divider/__tests__/__snapshots__/StyledDivider.spec.tsx.snap +165 -0
  20. package/src/components/Divider/index.tsx +22 -0
  21. package/src/index.ts +4 -4
  22. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +89 -0
  23. package/src/theme/__tests__/index.spec.ts +7 -0
  24. package/src/theme/components/card.ts +15 -0
  25. package/src/theme/components/divider.ts +23 -0
  26. package/src/theme/global/borders.ts +3 -0
  27. package/src/theme/global/colors.ts +3 -1
  28. package/src/theme/global/index.ts +2 -0
  29. package/src/theme/index.ts +6 -3
  30. package/tsconfig.json +4 -0
  31. package/types/components/Card/StyledCard.d.ts +3 -0
  32. package/types/components/Card/__tests__/Card.spec.d.ts +1 -0
  33. package/types/components/Card/__tests__/StyledCard.spec.d.ts +1 -0
  34. package/types/components/Card/index.d.ts +5 -0
  35. package/types/components/Divider/StyledDivider.d.ts +7 -0
  36. package/types/components/Divider/__tests__/StyledDivider.spec.d.ts +1 -0
  37. package/types/components/Divider/index.d.ts +12 -0
  38. package/types/index.d.ts +4 -3
  39. package/types/theme/__tests__/index.spec.d.ts +1 -0
  40. package/types/theme/components/card.d.ts +10 -0
  41. package/types/theme/components/divider.d.ts +17 -0
  42. package/types/theme/global/borders.d.ts +4 -0
  43. package/types/theme/global/colors.d.ts +2 -0
  44. package/types/theme/global/index.d.ts +5 -0
  45. package/types/theme/index.d.ts +4 -2
  46. package/playground/components/ExampleComponent.tsx +0 -8
  47. package/src/components/ExampleComponent/StyledView.tsx +0 -68
  48. package/src/components/ExampleComponent/__tests__/__snapshots__/StyledView.spec.tsx.snap +0 -23
  49. package/src/components/ExampleComponent/index.tsx +0 -26
  50. package/src/theme/components/exampleComponent.ts +0 -19
@@ -0,0 +1,7 @@
1
+ import { View } from 'react-native';
2
+ declare type MarginSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
3
+ declare const StyledDivider: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {
4
+ themeMarginHorizontal?: MarginSize | undefined;
5
+ themeMarginVertical?: MarginSize | undefined;
6
+ }, never>;
7
+ export { StyledDivider };
@@ -0,0 +1,12 @@
1
+ interface DividerProps {
2
+ /**
3
+ * Horizontal margin size. There is no margin by default.
4
+ */
5
+ marginHorizontal?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
6
+ /**
7
+ * Vertical margin size. There is no margin by default.
8
+ */
9
+ marginVertical?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
10
+ }
11
+ declare const Divider: ({ marginHorizontal, marginVertical }: DividerProps) => JSX.Element;
12
+ export default Divider;
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { ThemeProvider, useTheme } from './styled-components';
1
+ import { ThemeProvider, useTheme } from 'styled-components-native';
2
2
  import theme, { getTheme } from './theme';
3
- import ExampleComponent from './components/ExampleComponent';
4
- export { theme, getTheme, useTheme, ThemeProvider, ExampleComponent };
3
+ import Divider from './components/Divider';
4
+ import Card from './components/Card';
5
+ export { theme, getTheme, useTheme, ThemeProvider, Divider, Card };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { GlobalTheme } from '../global';
2
+ declare const getCardTheme: (theme: GlobalTheme) => {
3
+ radii: {
4
+ default: string;
5
+ };
6
+ padding: {
7
+ default: string;
8
+ };
9
+ };
10
+ export default getCardTheme;
@@ -0,0 +1,17 @@
1
+ import { GlobalTheme } from '../global';
2
+ declare const getDividerTheme: (theme: GlobalTheme) => {
3
+ colors: {
4
+ default: string;
5
+ };
6
+ space: {
7
+ xsmall: string;
8
+ small: string;
9
+ medium: string;
10
+ large: string;
11
+ xlarge: string;
12
+ };
13
+ borderWiths: {
14
+ default: string;
15
+ };
16
+ };
17
+ export default getDividerTheme;
@@ -0,0 +1,4 @@
1
+ declare const borderWidths: {
2
+ base: number;
3
+ };
4
+ export { borderWidths };
@@ -16,9 +16,11 @@ declare const systemPalette: {
16
16
  warningDark: string;
17
17
  warningBackground: string;
18
18
  platformBackground: string;
19
+ backgroundLight: string;
19
20
  backgroundDark: string;
20
21
  text: string;
21
22
  disabledText: string;
22
23
  invertedText: string;
24
+ outline: string;
23
25
  };
24
26
  export { palette, systemPalette };
@@ -16,10 +16,12 @@ declare const globalTheme: {
16
16
  warningDark: string;
17
17
  warningBackground: string;
18
18
  platformBackground: string;
19
+ backgroundLight: string;
19
20
  backgroundDark: string;
20
21
  text: string;
21
22
  disabledText: string;
22
23
  invertedText: string;
24
+ outline: string;
23
25
  };
24
26
  space: {
25
27
  xxsmall: number;
@@ -52,6 +54,9 @@ declare const globalTheme: {
52
54
  small: number;
53
55
  xsmall: number;
54
56
  };
57
+ borderWidths: {
58
+ base: number;
59
+ };
55
60
  };
56
61
  declare type GlobalTheme = typeof globalTheme;
57
62
  export { GlobalTheme };
@@ -1,8 +1,10 @@
1
1
  import { GlobalTheme } from './global';
2
- import getExampleComponentTheme from './components/exampleComponent';
2
+ import getDividerTheme from './components/divider';
3
+ import getCardTheme from './components/card';
3
4
  declare type Theme = GlobalTheme & {
4
5
  __hd__: {
5
- exampleComponent: ReturnType<typeof getExampleComponentTheme>;
6
+ divider: ReturnType<typeof getDividerTheme>;
7
+ card: ReturnType<typeof getCardTheme>;
6
8
  };
7
9
  };
8
10
  declare const getTheme: (theme?: GlobalTheme) => Theme;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import { ExampleComponent } from '../../src/index';
3
-
4
- const ExampleComponentPlayground = () => (
5
- <ExampleComponent size="large" margin="large" bgColor="primary" />
6
- );
7
-
8
- export default ExampleComponentPlayground;
@@ -1,68 +0,0 @@
1
- import { View } from 'react-native';
2
- import styled, { css } from '../../styled-components';
3
-
4
- const Square = styled(View)<{
5
- themeSize: 'small' | 'medium' | 'large';
6
- themeMargin: 'small' | 'medium' | 'large';
7
- themeBgColor: 'primary' | 'danger' | 'warning';
8
- }>`
9
- display: flex;
10
- align-items: center;
11
- justify-content: center;
12
-
13
- ${({ themeSize }) => {
14
- switch (themeSize) {
15
- case 'small':
16
- return css`
17
- height: 50px;
18
- width: 200px;
19
- `;
20
- case 'medium':
21
- return css`
22
- height: 100px;
23
- width: 250px;
24
- `;
25
- case 'large':
26
- return css`
27
- height: 150px;
28
- width: 300px;
29
- `;
30
- }
31
- }}
32
-
33
- ${({ themeMargin, theme }) => {
34
- switch (themeMargin) {
35
- case 'small':
36
- return css`
37
- margin: ${theme.__hd__.exampleComponent.space.smallMargin}px;
38
- `;
39
- case 'medium':
40
- return css`
41
- margin: ${theme.__hd__.exampleComponent.space.mediumMargin}px;
42
- `;
43
- case 'large':
44
- return css`
45
- margin: ${theme.__hd__.exampleComponent.space.largeMargin}px;
46
- `;
47
- }
48
- }}
49
-
50
- ${({ themeBgColor, theme }) => {
51
- switch (themeBgColor) {
52
- case 'primary':
53
- return css`
54
- background-color: ${theme.__hd__.exampleComponent.colors.primaryBg};
55
- `;
56
- case 'danger':
57
- return css`
58
- background-color: ${theme.__hd__.exampleComponent.colors.dangerBg};
59
- `;
60
- case 'warning':
61
- return css`
62
- background-color: ${theme.__hd__.exampleComponent.colors.warningBg};
63
- `;
64
- }
65
- }}
66
- `;
67
-
68
- export { Square };
@@ -1,23 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`StyledView renders correct styling 1`] = `
4
- <View
5
- style={
6
- Object {
7
- "alignItems": "center",
8
- "backgroundColor": "#c8a7ef",
9
- "display": "flex",
10
- "height": 100,
11
- "justifyContent": "center",
12
- "marginBottom": 16,
13
- "marginLeft": 16,
14
- "marginRight": 16,
15
- "marginTop": 16,
16
- "width": 250,
17
- }
18
- }
19
- themeBgColor="primary"
20
- themeMargin="medium"
21
- themeSize="medium"
22
- />
23
- `;
@@ -1,26 +0,0 @@
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
- size?: 'small' | 'medium' | 'large';
10
- /**
11
- * Margin.
12
- */
13
- margin: 'small' | 'medium' | 'large';
14
- /**
15
- * Background color.
16
- */
17
- bgColor: 'primary' | 'danger' | 'warning';
18
- }
19
-
20
- const ExampleComponent = ({ size = 'small', margin, bgColor }: Props) => (
21
- <Square themeSize={size} themeMargin={margin} themeBgColor={bgColor}>
22
- <Text>{`Square with ${size} size, ${margin} margin and ${bgColor} background.`}</Text>
23
- </Square>
24
- );
25
-
26
- export default ExampleComponent;
@@ -1,19 +0,0 @@
1
- import { GlobalTheme } from '../global';
2
-
3
- const getExampleComponentTheme = (theme: GlobalTheme) => {
4
- const colors = {
5
- primaryBg: theme.colors.primaryLight,
6
- dangerBg: theme.colors.dangerBackground,
7
- warningBg: theme.colors.warningBackground,
8
- };
9
-
10
- const space = {
11
- smallMargin: theme.space.xxsmall,
12
- mediumMargin: theme.space.medium,
13
- largeMargin: theme.space.xxxxlarge,
14
- };
15
-
16
- return { colors, space };
17
- };
18
-
19
- export default getExampleComponentTheme;