Giter Site home page Giter Site logo

foxfl / react-native-design-system Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iamshadmirza/react-native-design-system

0.0 0.0 0.0 15.35 MB

A tiny design system

Home Page: https://www.npmjs.com/package/react-native-design-system

License: MIT License

JavaScript 99.20% HTML 0.80%

react-native-design-system's Introduction

Welcome to react-native-design-system ๐Ÿ‘‹

Documentation Maintenance License: MIT Twitter: iamshadmirza

react-native-react-system

React Native Design System is a set of design rules and component library that lets you prototype faster with easy to use cross-platform components. Let's get started!

๐Ÿ  Homepage

๐Ÿ“„ Documentation

Install

Simply go to the command line and run this command.

yarn add react-native-design-system

This library needs react-native-vector-icons so go on and install that too to get all the cool icons. Check out Install guide.

Usage

React Native Design System uses a centralized theme to provide consistency across all the components.

Step 1. Import ThemeProvider and theme then wrap your root component.

This step is important. We are passing theme as context value that each component will access.

//your root component
import { ThemeProvider, theme } from 'react-native-design-system';

function App(){
  return (
    <ThemeProvider value={theme}>
      <Root />
    </ThemeProvider>
  );
}

Step 2. Use component.

//inside any file
import { Button } from 'react-native-design-system';

function HomeScreen(){
  return (
    <Button>
      Press Me
    </Button>
  );
}

That's pretty much it. theme file contains configuration for all the components. Don't worry, you can easily customize it. Let me show how:

Customize

You just need to import theme, reassign the value you want to change and pass it to ThemeProvider. Example:
Default primary color is blue but you like orange so you can simply do:

import { ThemeProvider, theme } from 'react-native-design-system';

theme.brandColor.primary = "orange";

function App(){
  return (
    <ThemeProvider value={theme}>
      <Root />
    </ThemeProvider>
  );
}

And we are done!

You can see all the configurations available on the theme page.

If you have a lot of customizations

This is just a personal approach, you can do as you prefer. What I usually do is create a theme.config.js file and add all my customizations there.

//theme.config.js at root
import { theme } from 'react-native-design-system';

theme.textColor = {
    'default': '#000',
    'heading': '#999',
    'subtle': '#333',
    'grey': '#757575',
    'disabled': '#78909c',
    'white': '#f8f8f8',
};

export default theme;

Now, I will just import theme from here and pass it to my ThemeProvider.

import { ThemeProvider } from 'react-native-design-system';
import theme from './theme.config.js';

function App(){
  return (
    <ThemeProvider value={theme}>
      <Root />
    </ThemeProvider>
  );
}

Please make sure to pass all the keys while reassigning any object inside the theme.

Components included:

Author

๐Ÿ‘ค Shad Mirza

๐Ÿค Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page and contribution guidelines.

Show your support

Give a โญ๏ธ if this project helped you!

๐Ÿ“ License

Copyright ยฉ 2019 Shad Mirza.
This project is MIT licensed.


This README was generated with โค๏ธ by readme-md-generator

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.