Shared components to be used in HSL projects. React and styled components.
- Install Lerna
npm install --global lerna
lerna bootstrap
hooks/init-hooks
Launch watcher
cd packages/hsl-shared-components && yarn build:watch
cd storybooks/web && yarn storybook or
yarn storybook:web`
latter doesn't display debug information
cd storybooks/native && yarn storybook
or
yarn storybook:native
latter doesn't display debug information
IOS
- ?
Android
- launch emulator/device
yarn storybook
-
adb reverse tcp:8081 tcp:8081 adb reverse tcp:9001 tcp:9001 adb reverse tcp:7007 tcp:7007 yarn run android
yarn add hsl-shared-components
or
npm i --save hsl-shared-components
In the desired react class use named imports to get the components needed:
import {Button} from 'hsl-shared-components';
- Install react-native-svg peer dependency
react-native link react-native-svg
Make a folderstructure like src/ComponentX/ComponentX.js. (if it needs many files make the ComponentX.js the main one)
When finishing the component add it as an import and a named export to the src/index.js file.
Native components to src/native/index.js
yarn deploy-storybook
lerna publish
- Try running Android Studio in administrator mode or
- Delete .idea folder
- Reopen the project
- Configure the project when studio suggests it
- Example of mocking Touchable in a test
jest.mock('hsl-shared-components/lib/Touchable/Touchable', () => {
const View = require.requireActual('hsl-shared-components/lib/View/View');
return View;
});
- In native svg width and height are floats, so either of these
<Icon.someIcon width="123" height="123" fill="#123456" />
<Icon.someIcon width={number1} height={number2} fill="#123456" />