react-native-default-style

0.0.3 • Public • Published

react-native-default-style-version react-native-default-style-version

react-native-default-style

A React Native's module that allows you use all their components with predefined styles by default.

Installation

npm i -S react-native-default-style

Usage

Basic Usage

// src/configureDefaultStyles.js
 
import { setDefaultStyles, COMPONENT_TYPE } from 'react-native-default-style';
 
export const configureDefaultStyles = () => {
    const allDefaultStyles = {
        type: COMPONENT_TYPE.DEFAULT,
        styles: {
            backgroundColor: '#F00'
        }
    };
 
    const textDefaultStyles = {
        type: COMPONENT_TYPE.TEXT,
        styles: {
            color: '#FFF'
        }
    };
 
    setDefaultStyles([ allDefaultStyles, textDefaultStyles ]);
};
// src/app.js
 
import React, { Component } from 'react';
import { StyleSheet } from 'react-native';
import { configureDefaultStyles } from './configureDefaultStyles';
import { View, Text } from 'react-native-default-style';
 
configureDefaultStyles(); // You must only execute once.
 
const MyView = (props) => {
  return (<View><Text>This is my first test</Text></View>);
}
const MyOtherView = (props) => {
  return (<View><Text style={myStyles.myOtherView}>This is my second test.</Text></View>);
}
const myStyles = StyleSheet.create({
  myOtherView: {
    color: '#09F',
  }
});
 

Package Sidebar

Install

npm i react-native-default-style

Weekly Downloads

1

Version

0.0.3

License

GNU GPLv3

Last publish

Collaborators

  • fbadiola