@hero-design/rn 6.8.0 → 7.0.2
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/.eslintrc.json +1 -0
- package/.expo/README.md +15 -0
- package/.expo/packager-info.json +10 -0
- package/.expo/settings.json +10 -0
- package/app.json +4 -0
- package/assets/fonts/hero-icons.ttf +0 -0
- package/es/index.js +10053 -131
- package/jest.config.js +5 -0
- package/lib/index.js +10057 -130
- package/package.json +24 -4
- package/playground/components/Badge.tsx +50 -0
- package/playground/components/Card.tsx +52 -0
- package/playground/components/Icon.tsx +140 -0
- package/playground/components/Typography.tsx +21 -0
- package/playground/index.tsx +42 -9
- package/react-native.config.js +5 -0
- package/src/components/Badge/StyledBadge.tsx +34 -0
- package/src/components/Badge/__tests__/Badge.spec.tsx +50 -0
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +161 -0
- package/src/components/Badge/index.tsx +35 -0
- package/src/components/Card/StyledCard.tsx +9 -0
- package/src/components/Card/__tests__/Card.spec.tsx +36 -0
- package/src/components/Card/__tests__/StyledCard.spec.tsx +15 -0
- package/src/components/Card/__tests__/__snapshots__/Card.spec.tsx.snap +39 -0
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +18 -0
- package/src/components/Card/index.tsx +9 -0
- package/src/components/Icon/HeroIcon/index.tsx +30 -0
- package/src/components/Icon/HeroIcon/selection.json +1 -0
- package/src/components/Icon/IconList.ts +298 -0
- package/src/components/Icon/__tests__/Icon.spec.tsx +36 -0
- package/src/components/Icon/__tests__/__snapshots__/Icon.spec.tsx.snap +43 -0
- package/src/components/Icon/index.tsx +47 -0
- package/src/components/Typography/Text/StyledText.tsx +69 -0
- package/src/components/Typography/Text/__test__/StyledText.spec.tsx +62 -0
- package/src/components/Typography/Text/__test__/__snapshots__/StyledText.spec.tsx.snap +172 -0
- package/src/components/Typography/Text/__test__/index.spec.tsx +11 -0
- package/src/components/Typography/Text/index.tsx +41 -0
- package/src/components/Typography/index.tsx +11 -0
- package/src/index.ts +15 -1
- package/src/testHelpers/renderWithTheme.tsx +8 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +79 -0
- package/src/theme/components/badge.ts +38 -0
- package/src/theme/components/card.ts +15 -0
- package/src/theme/components/icon.ts +24 -0
- package/src/theme/components/typography.ts +32 -0
- package/src/theme/global/typography.ts +4 -0
- package/src/theme/index.ts +12 -0
- package/testUtils/setup.ts +3 -0
- package/tsconfig.json +2 -6
- package/types/components/ExampleComponent/StyledView.d.ts +7 -0
- package/types/components/{Divider/__tests__/StyledDivider.spec.d.ts → ExampleComponent/__tests__/StyledView.spec.d.ts} +0 -0
- package/types/components/ExampleComponent/index.d.ts +16 -0
- package/types/index.d.ts +3 -3
- package/types/playground/components/Badge.d.ts +2 -0
- package/types/playground/components/Card.d.ts +2 -0
- package/types/playground/components/Divider.d.ts +2 -0
- package/types/playground/components/Icon.d.ts +2 -0
- package/types/playground/components/Typography.d.ts +2 -0
- package/types/playground/index.d.ts +2 -0
- package/types/src/components/Badge/StyledBadge.d.ts +9 -0
- package/types/{theme/__tests__/index.spec.d.ts → src/components/Badge/__tests__/Badge.spec.d.ts} +0 -0
- package/types/src/components/Badge/index.d.ts +22 -0
- package/types/src/components/Card/StyledCard.d.ts +3 -0
- package/types/src/components/Card/__tests__/Card.spec.d.ts +1 -0
- package/types/src/components/Card/__tests__/StyledCard.spec.d.ts +1 -0
- package/types/src/components/Card/index.d.ts +5 -0
- package/types/{components → src/components}/Divider/StyledDivider.d.ts +0 -0
- package/types/src/components/Divider/__tests__/StyledDivider.spec.d.ts +1 -0
- package/types/{components → src/components}/Divider/index.d.ts +0 -0
- package/types/src/components/Icon/HeroIcon/index.d.ts +7 -0
- package/types/src/components/Icon/IconList.d.ts +2 -0
- package/types/src/components/Icon/__tests__/Icon.spec.d.ts +1 -0
- package/types/src/components/Icon/index.d.ts +27 -0
- package/types/src/components/Typography/Text/StyledText.d.ts +7 -0
- package/types/src/components/Typography/Text/__test__/StyledText.spec.d.ts +1 -0
- package/types/src/components/Typography/Text/__test__/index.spec.d.ts +1 -0
- package/types/src/components/Typography/Text/index.d.ts +22 -0
- package/types/src/components/Typography/index.d.ts +6 -0
- package/types/src/index.d.ts +8 -0
- package/types/src/styled-components.d.ts +6 -0
- package/types/src/testHelpers/renderWithTheme.d.ts +3 -0
- package/types/src/theme/__tests__/index.spec.d.ts +1 -0
- package/types/src/theme/components/badge.d.ts +29 -0
- package/types/src/theme/components/card.d.ts +10 -0
- package/types/{theme → src/theme}/components/divider.d.ts +0 -0
- package/types/src/theme/components/icon.d.ts +19 -0
- package/types/src/theme/components/typography.d.ts +25 -0
- package/types/{theme → src/theme}/global/borders.d.ts +0 -0
- package/types/src/theme/global/colors.d.ts +26 -0
- package/types/src/theme/global/index.d.ts +67 -0
- package/types/src/theme/global/space.d.ts +12 -0
- package/types/src/theme/global/typography.d.ts +25 -0
- package/types/src/theme/index.d.ts +19 -0
- package/types/theme/colors.d.ts +24 -0
- package/types/theme/components/demoStyle.d.ts +11 -0
- package/types/theme/components/exampleComponent.d.ts +14 -0
- package/types/theme/global/colors.d.ts +0 -2
- package/types/theme/global/index.d.ts +0 -5
- package/types/theme/index.d.ts +2 -2
- package/types/theme/space.d.ts +12 -0
- package/types/theme/typography.d.ts +21 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import React, { ReactElement } from 'react';
|
|
3
|
+
import { StyledView, StyledText } from './StyledBadge';
|
|
4
|
+
|
|
5
|
+
interface BadgeProps {
|
|
6
|
+
/**
|
|
7
|
+
* Content of the `Badge`.
|
|
8
|
+
*/
|
|
9
|
+
content: string;
|
|
10
|
+
/**
|
|
11
|
+
* Visual intent color to apply to `Badge`.
|
|
12
|
+
*/
|
|
13
|
+
intent?: 'success' | 'warning' | 'danger' | 'info';
|
|
14
|
+
/**
|
|
15
|
+
* Addditional style to be applied for `Badge`.
|
|
16
|
+
*/
|
|
17
|
+
style?: StyleProp<ViewStyle>;
|
|
18
|
+
/**
|
|
19
|
+
* Testing id of the component.
|
|
20
|
+
*/
|
|
21
|
+
testID?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const Badge = ({
|
|
25
|
+
content,
|
|
26
|
+
intent = 'info',
|
|
27
|
+
style,
|
|
28
|
+
testID,
|
|
29
|
+
}: BadgeProps): ReactElement => (
|
|
30
|
+
<StyledView testID={testID} themeIntent={intent} style={style}>
|
|
31
|
+
<StyledText themeIntent={intent}>{content}</StyledText>
|
|
32
|
+
</StyledView>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export default Badge;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
import styled from 'styled-components-native';
|
|
3
|
+
|
|
4
|
+
const StyledCard = styled(View)<{}>`
|
|
5
|
+
border-radius: ${({ theme }) => theme.__hd__.card.radii.default};
|
|
6
|
+
padding: ${({ theme }) => theme.__hd__.card.padding.default};
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
export { StyledCard };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, RenderAPI } from '@testing-library/react-native';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import Card from '..';
|
|
5
|
+
import { theme, ThemeProvider } from '../../../index';
|
|
6
|
+
|
|
7
|
+
describe('Card', () => {
|
|
8
|
+
let wrapper: RenderAPI;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
wrapper = render(
|
|
12
|
+
<ThemeProvider theme={theme}>
|
|
13
|
+
<Card
|
|
14
|
+
style={{ backgroundColor: theme.colors.backgroundDark }}
|
|
15
|
+
testID="card"
|
|
16
|
+
nativeID="card-native-id"
|
|
17
|
+
hitSlop={{ top: 1, left: 1, bottom: 1, right: 1 }}
|
|
18
|
+
pointerEvents="box-only"
|
|
19
|
+
removeClippedSubviews
|
|
20
|
+
>
|
|
21
|
+
<View testID="child-view" />
|
|
22
|
+
</Card>
|
|
23
|
+
</ThemeProvider>
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('renders correct', () => {
|
|
28
|
+
expect(wrapper.queryAllByTestId('card')).toHaveLength(1);
|
|
29
|
+
|
|
30
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('has child', () => {
|
|
34
|
+
expect(wrapper.queryAllByTestId('child-view')).toHaveLength(1);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { ThemeProvider, theme } from '../../../index';
|
|
4
|
+
import { StyledCard } from '../StyledCard';
|
|
5
|
+
|
|
6
|
+
describe('StyledCard', () => {
|
|
7
|
+
it('renders correct style', () => {
|
|
8
|
+
const { toJSON } = render(
|
|
9
|
+
<ThemeProvider theme={theme}>
|
|
10
|
+
<StyledCard />
|
|
11
|
+
</ThemeProvider>
|
|
12
|
+
);
|
|
13
|
+
expect(toJSON()).toMatchSnapshot();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Card renders correct 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
hitSlop={
|
|
6
|
+
Object {
|
|
7
|
+
"bottom": 1,
|
|
8
|
+
"left": 1,
|
|
9
|
+
"right": 1,
|
|
10
|
+
"top": 1,
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
nativeID="card-native-id"
|
|
14
|
+
pointerEvents="box-only"
|
|
15
|
+
removeClippedSubviews={true}
|
|
16
|
+
style={
|
|
17
|
+
Array [
|
|
18
|
+
Object {
|
|
19
|
+
"borderBottomLeftRadius": 12,
|
|
20
|
+
"borderBottomRightRadius": 12,
|
|
21
|
+
"borderTopLeftRadius": 12,
|
|
22
|
+
"borderTopRightRadius": 12,
|
|
23
|
+
"paddingBottom": 16,
|
|
24
|
+
"paddingLeft": 16,
|
|
25
|
+
"paddingRight": 16,
|
|
26
|
+
"paddingTop": 16,
|
|
27
|
+
},
|
|
28
|
+
Object {
|
|
29
|
+
"backgroundColor": "#292a2b",
|
|
30
|
+
},
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
testID="card"
|
|
34
|
+
>
|
|
35
|
+
<View
|
|
36
|
+
testID="child-view"
|
|
37
|
+
/>
|
|
38
|
+
</View>
|
|
39
|
+
`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`StyledCard renders correct style 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
Object {
|
|
7
|
+
"borderBottomLeftRadius": 12,
|
|
8
|
+
"borderBottomRightRadius": 12,
|
|
9
|
+
"borderTopLeftRadius": 12,
|
|
10
|
+
"borderTopRightRadius": 12,
|
|
11
|
+
"paddingBottom": 16,
|
|
12
|
+
"paddingLeft": 16,
|
|
13
|
+
"paddingRight": 16,
|
|
14
|
+
"paddingTop": 16,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/>
|
|
18
|
+
`;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
import { StyledCard } from './StyledCard';
|
|
4
|
+
|
|
5
|
+
interface CardProps extends ViewProps {}
|
|
6
|
+
|
|
7
|
+
const Card = (props: CardProps): JSX.Element => <StyledCard {...props} />;
|
|
8
|
+
|
|
9
|
+
export default Card;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createIconSetFromIcoMoon } from 'react-native-vector-icons';
|
|
2
|
+
import styled, { css } from 'styled-components-native';
|
|
3
|
+
import heroIconConfig from './selection.json';
|
|
4
|
+
|
|
5
|
+
type ThemeSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
|
|
6
|
+
type ThemeIntent =
|
|
7
|
+
| 'text'
|
|
8
|
+
| 'primary'
|
|
9
|
+
| 'info'
|
|
10
|
+
| 'danger'
|
|
11
|
+
| 'success'
|
|
12
|
+
| 'warning';
|
|
13
|
+
|
|
14
|
+
const HeroIcon = createIconSetFromIcoMoon(
|
|
15
|
+
heroIconConfig,
|
|
16
|
+
'hero-icons',
|
|
17
|
+
'hero-icons.ttf'
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const StyledHeroIcon = styled(HeroIcon)<{
|
|
21
|
+
themeSize: ThemeSize;
|
|
22
|
+
themeIntent: ThemeIntent;
|
|
23
|
+
}>`
|
|
24
|
+
${({ themeIntent, themeSize }) => css`
|
|
25
|
+
color: ${({ theme }) => theme.__hd__.icon.colors[themeIntent]};
|
|
26
|
+
font-size: ${({ theme }) => theme.__hd__.icon.sizes[themeSize]}px;
|
|
27
|
+
`};
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
export default StyledHeroIcon;
|