0.4.2 • Published 2 years ago

react-native-urbi-ui v0.4.2

Weekly downloads
104
License
Apache-2.0
Repository
github
Last release
2 years ago

react-native-urbi-ui

A set of React Native components that compose Urbi's Design System.

Warning

This is an alpha version of the release, use it at your own risk!

Installation

Install the library by running:

yarn add react-native-urbi-ui
# or npm install react-native-urbi-ui

Peer dependencies

Then, install all of its peer dependencies:

yarn add @react-native-community/slider date-fns formik react-native-dialogs react-native-formik react-native-gesture-handler react-native-linear-gradient react-native-modal-datetime-picker react-native-reanimated react-native-typography react-native-vector-icons react-native-svg
# or npm install the same things

Icon font

You need to add the icon font definition file to a folder named assets/json in your project's root folder. The file needs to be called urbi-font.json. This is used by the Icon component defined in the const.ts file, which is imported by many other components. You also need a file named urbi.ttf inside the native part of your project (see instructions below for Android and iOS). If you want to use our icon font, you can copy it from the Showcase App:

# from your project's root
mkdir -p assets/json
cp node_modules/react-native-urbi-ui/urbi-font.json assets/json
# then for Android
cp node_modules/react-native-urbi-ui/urbi.ttf android/app/src/main/assets/fonts

To add the font on iOS, copy our icon font file and add it as one of your project's resources. It's the same font that's used on Android, so you can find it inside:

node_modules/react-native-urbi-ui/urbi.ttf

Once copied to your project (e.g., inside the ios folder as a top-level file, like our showcase app does), update your XCode settings to include urbi.ttf in the Copy resources build phase.

Typescript

If you're using Typescript, you might want to add this to your tsconfig.json file:

{
    "compilerOptions": {
        /* the rest of your conf here */
        "paths": {
            /* your other mapped paths, if any */
            "react-native-urbi-ui/*": [
                "node_modules/react-native-urbi-ui/*",
                "node_modules/react-native-urbi-ui/*.android.d.ts",
                "node_modules/react-native-urbi-ui/*.ios.d.ts"
            ]
        }
    }
}

that way, tsc will look for platform-specific definition files, which it wouldn't otherwise.

Android fonts

The library relies on your app embedding Android's Roboto-Regular.ttf and Roboto-Medium.ttf (so that it looks the same regardless of what the device has set as system font).

If you don't have these 2 files in your project already, create an android/app/src/main/assets/fonts folder and save those files there. You can get the files from Google Fonts, or you can download them from our showcase app's own fonts folder.

Usage

Import components/molecules from their folders, e.g.:

import { ButtonCompact } from 'react-native-urbi-ui/molecules/buttons/ButtonCompact';

Every component is exported as either a React.PureComponent or as a memoized stateless component (using React.memo()). In some cases, unmemoized versions are available, and they're exported using the Unmemoized suffix, but you can generally use the component without the Unmemoized suffix.

Check out our showcase app for examples on how to use our molecules and components.

Development

Build

Run yarn install to install all dependencies, and yarn build to generate the dist folder which contains the module. If you want to generate a package with the same structure as the one published on https://www.npmjs.com, run yarn package, and find the react-native-urbi-ui-<version>.tgz package inside the dist folder.

Using the showcase app to preview changes to the library

Because the metro bundler doesn't support regular npm links (see this issue), we need to rely on wml (which in turn relies on watchman to actually copy all files from the library dist folder to showcase/node_modules/react-native-urbi-ui whenever they change.

The setup works as follows:

# from the repo top-level folder
watchman watch dist
cd showcase
yarn install
cd ..
yarn build
rm -rf showcase/node_modules/react-native-urbi-ui
wml add dist/ showcase/node_modules/react-native-urbi-ui
wml start

Then, launch the showcase app and (optionally) enable hot reload. Then, whenever you want to see your edits on the app, run yarn build from the top-level folder.

Running on VS Code

To run/debug in VS Code, create a configuration as usual, but also add a settings.json file inside the .vscode folder (which also contains your launch.json conf file).

Inside of it, add this:

{
  "react-native-tools": {
    "projectRoot": "/path/to/react-native-urbi-ui/showcase"
  }
}

Publish package

Done yarn package and next npm publish archive in dist folder

0.4.1

2 years ago

0.4.0

2 years ago

0.4.2

2 years ago

0.3.18

3 years ago

0.3.17

3 years ago

0.3.16

3 years ago

0.3.15

3 years ago

0.3.14

3 years ago

0.3.13

3 years ago

0.3.12

3 years ago

0.3.11

3 years ago

0.3.10

3 years ago

0.3.9

3 years ago

0.3.8

3 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.1.43

4 years ago

0.1.42

4 years ago

0.1.41

4 years ago

0.1.40

4 years ago

0.1.39

4 years ago

0.1.38

4 years ago

0.1.37

4 years ago

0.1.36

4 years ago

0.1.34

4 years ago

0.1.35

4 years ago

0.1.33

4 years ago

0.1.32

4 years ago

0.1.31

4 years ago

0.1.30

4 years ago

0.1.29

4 years ago

0.1.28

4 years ago

0.1.27

4 years ago

0.1.26

4 years ago

0.1.25

4 years ago

0.1.24

4 years ago

0.1.23

4 years ago

0.1.22

4 years ago

0.1.21

4 years ago

0.1.20

4 years ago

0.1.19

4 years ago

0.1.18

4 years ago

0.1.17

4 years ago

0.1.15

4 years ago

0.1.16

4 years ago

0.1.13

4 years ago

0.1.14

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.0.25

4 years ago

0.0.24

4 years ago

0.0.23

4 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago