1.0.4 • Published 4 years ago

reactstrap-native-web v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

ReactstrapNativeWeb

This is project create support library bootstrap on react native and react native web

Table of contents

Installation

If using yarn:

yarn add reactstrap-native-web@beta

If using npm:

npm i reactstrap-native-web@beta

Global Style

Setup

  1. Create file styles any (recommended use name: theme.style.js or theme.style.ts if you use the typescript in a folder style)
  2. Load theme default or dynamic theme you want.

    import {buildTheme} from 'reactstrap-native-web';
    import {StyleSheet} from 'react-native'  
    const themes = buildTheme({
      lightTheme: {
        spacer: 30,  
        colors: {
          primary: 'red',
        },
      },
    });
    
    export const bootstrap = StyleSheet.create(themes.default.styleSheet);
    export const lightTheme = StyleSheet.create(themes.lightTheme.styleSheet);

    And then you can import global style anywhere Note: when we define colors variable for any theme will auto-generate text color, background color, and border color equivalent Beside about spacer variable will auto-generate margin and padding equivalent please reference spacing

  3. Theme defaults similar :root of bootstrap

    export default {
      spacer: 16,
      colors: {
        blue: '#007bff',
        indigo: '#6610f2',
        purple: '#6f42c1',
        pink: '#e83e8c',
        red: '#dc3545',
        orange: '#fd7e14',
        yellow: '#ffc107',
        green: '#28a745',
        teal: '#20c997',
        cyan: '#17a2b8',
        white: '#fff',
        gray: '#6c757d',
        grayDark: '#343a40',
        primary: '#007bff',
        secondary: '#6c757d',
        success: '#28a745',
        info: '#17a2b8',
        warning: '#ffc107',
        danger: '#dc3545',
        light: '#f8f9fa',
        dark: '#343a40',
      },
    };

Document Structure Dynamic Theme

NameDescriptionDefaultTypeRequired
colorsDefine color for your dynamic theme or override theme defaultNoneObjectfalse
spacerNumber present size please reference spacing16Numberfalse

Text Color

  • Generate when we setting colors
  • Example:

         import {buildTheme} from 'reactstrap-native-web';
         import {StyleSheet} from 'react-native'   
         const themes = buildTheme({
             lightTheme: {
                spacer: 30,  
                colors: {
                  primary: 'red',
                },
             },
         });
    
         export const bootstrap = StyleSheet.create(themes.default.styleSheet);
         export const lightTheme = StyleSheet.create(themes.lightTheme.styleSheet);
  • Auto generate text color for lightTheme:

       import {StyleSheet} from "react-native";
    
       StyleSheet.create({
         textPrimary: {
             color: 'red'        
         }   
       })  
  • we can access style in code the following:

         export const ExampleComponent = () => {
             return (
                 <View style={lightTheme.textPrimary}/>
             );   
         }   

Background Color

  • Generate when we setting colors
  • Example:
         import {buildTheme} from 'reactstrap-native-web';
         import {StyleSheet} from 'react-native'   
         const themes = buildTheme({
             lightTheme: {
                 spacer: 30,  
                 colors: {
                     primary: 'red',
                 },
             },
         });
        
         export const bootstrap = StyleSheet.create(themes.default.styleSheet);
         export const lightTheme = StyleSheet.create(themes.lightTheme.styleSheet);
  • Auto generate background color for lightTheme:
         import {StyleSheet} from "react-native";
     
         StyleSheet.create({
             bgPrimary: {
                 backgroundColor: 'red'        
             }   
         })  
  • we can access style in code the following:
         export const ExampleComponent = () => {
             return (
                 <View style={lightTheme.bgPrimary}/>
             );   
         }   

Border Color

  • Generate when we setting colors
  • Example:
         import {buildTheme} from 'reactstrap-native-web';
         import {StyleSheet} from 'react-native'   
         const themes = buildTheme({
             lightTheme: {
                 spacer: 30,  
                 colors: {
                     primary: 'red',
                 },
             },
         });
        
         export const bootstrap = StyleSheet.create(themes.default.styleSheet);
         export const lightTheme = StyleSheet.create(themes.lightTheme.styleSheet);
  • Auto generate border color for lightTheme:
         import {StyleSheet} from "react-native";
     
         StyleSheet.create({
             borderPrimary: {
               borderColor: 'red',    
             },
             borderFullPrimary: {
               borderWidth: 1,
               borderColor: 'red',
               borderStyle: 'solid',     
             },
             borderBottomPrimary: {
               borderBottomColor: 'red',
               borderBottomWidth: 1,
               borderStyle: 'solid',
             },
             borderLeftPrimary: {
               borderLeftColor: 'red',
               borderLeftWidth: 1,
               borderStyle: 'solid',
             },
             borderRightPrimary: {
               borderRightColor: 'red',
               borderRightWidth: 1,
               borderStyle: 'solid',
             },
             borderTopPrimary: {
                borderTopColor: 'red',
                borderTopWidth: 1,
                borderStyle: 'solid',
             }                            
         })  
  • we can access style in code the following:
         export const ExampleComponent = () => {
             return (
                 <View style={lightTheme.borderFullPrimary}/>
             );   
         }   

Border Width

  • Generate when we setting spacer
  • Example:
         import {buildTheme} from 'reactstrap-native-web';
         import {StyleSheet} from 'react-native'   
         const themes = buildTheme({
             lightTheme: {
                 spacer: 30,  
                 colors: {
                     primary: 'red',
                 },
             },
         });
        
         export const bootstrap = StyleSheet.create(themes.default.styleSheet);
         export const lightTheme = StyleSheet.create(themes.lightTheme.styleSheet);
  • Auto generate border width for lightTheme:
         import {StyleSheet} from "react-native";
     
         StyleSheet.create({
             border0: {
                 borderWidth: 0,
             },
             borderB0: {
                 borderBottomWidth: 0,
             },
             borderE0: {
                 borderEndWidth: 0,
             },
             borderL0: {
                 borderLeftWidth: 0,
             },
             borderR0: {
                 borderRightWidth: 0,
             },
             borderS0: {
                 borderStartWidth: 0,
             },
             borderT0: {
                 borderTopWidth: 0,
             },
             borderX0: {
                 borderRightWidth: 0,
                 borderLeftWidth: 0,
             },
             borderY0: {
                 borderBottomWidth: 0,
                 borderTopWidth: 0,
             },
             ... generate => spacer / 2 ,  
             border15: {
                 borderWidth: 15,
             }                    
                  
         })  
  • we can access style in code the following:
         export const ExampleComponent = () => {
             return (
                 <View style={lightTheme.border3}/>
             );   
         }   

Padding

  • Generate when we setting spacer
  • Example:
         import {buildTheme} from 'reactstrap-native-web';
         import {StyleSheet} from 'react-native'   
         const themes = buildTheme({
             lightTheme: {
                 spacer: 30,  
                 colors: {
                     primary: 'red',
                 },
             },
         });
        
         export const bootstrap = StyleSheet.create(themes.default.styleSheet);
         export const lightTheme = StyleSheet.create(themes.lightTheme.styleSheet);
  • Auto generate padding for lightTheme according to the rate of spacing of the bootstrap
         import {StyleSheet} from "react-native";
     
         StyleSheet.create({
             p0: {
                 padding: 0,
             },
             pb0: {
                 paddingBottom: 0,
             },
             pl0: {
                 paddingLeft: 0,
             },
             pt0: {
                 paddingTop: 0,
             },
             pr0: {
                 paddingRight: 0,
             },
             px0: {
                 paddingHorizontal: 0,
             },
             py0: {
                 paddingVertical: 0,
             },
             ... generate => 5,
             p5: {
                 padding: spacer * 3,
             }   
         })  
  • we can access style in code the following:
         export const ExampleComponent = () => {
             return (
                 <View style={lightTheme.p3}/>
             );   
         }   

Margin

  • Generate when we setting spacer
  • Example:
         import {buildTheme} from 'reactstrap-native-web';
         import {StyleSheet} from 'react-native'   
         const themes = buildTheme({
             lightTheme: {
                 spacer: 30,  
                 colors: {
                     primary: 'red',
                 },
             },
         });
        
         export const bootstrap = StyleSheet.create(themes.default.styleSheet);
         export const lightTheme = StyleSheet.create(themes.lightTheme.styleSheet);
  • Auto generate margin for lightTheme according to the rate of spacing of the bootstrap
         import {StyleSheet} from "react-native";
     
         StyleSheet.create({
             m0: {
                 margin: 0,
             },
             mb0: {
                 marginBottom: 0,
             },
             ml0: {
                 marginLeft: 0,
             },
             mt0: {
                 marginTop: 0,
             },
             mr0: {
                 marginRight: 0,
             },
             mx0: {
                 marginHorizontal: 0,
             },
             my0: {
                 marginVertical: 0,
             },
             ... generate => 5,
             m5: {
                 margin: spacer * 3,
             }   
         })  
  • we can access style in code the following:
         export const ExampleComponent = () => {
             return (
                 <View style={lightTheme.m3}/>
             );   
         }   

Width and Height

Display

ClassProperties
flexdisplay: 'flex'
hiddendisplay: 'none'

Overflow

ClassProperties
overflowVisibleoverflow: 'visible'
overflowHiddenoverflow: 'hidden'

Position

ClassProperties
relativeposition: 'relative'
absoluteposition: 'absolute'
inset0top: 0, bottom: 0, left: 0, right: 0
insetY0top: 0, bottom: 0
insetX0left: 0, right: 0
top0top: 0
right0right: 0
bottom0bottom: 0
left0left: 0

ZIndex

ClassProperties
z0zIndex: 0
z10zIndex: 10
z20zIndex: 20
z30zIndex: 30
z40zIndex: 50
z50zIndex: 50

Font Size

ClassProperties
textXsfontSize: 12
textSmfontSize: 14
textBasefontSize: 16
textLgfontSize: 18
textXlfontSize: 20
text2xlfontSize: 24
text3xlfontSize: 30
text4xlfontSize: 36
text5xlfontSize: 48
text6xlfontSize: 64

Font Weight

ClassProperties
fontHairlinefontWeight: 100
fontThinfontWeight: 200
fontLightfontWeight: 300
fontNormalfontWeight: 'normal'
fontMediumfontWeight: 500
fontSemiboldfontWeight: 600
fontBoldfontWeight: 'bold'
fontExtraboldfontWeight: 800
fontBlackfontWeight: 900

Letter Spacing

ClassProperties
trackingTighterletterSpacing: -0.8
trackingTightletterSpacing: -0.4
trackingNormalletterSpacing: 0
trackingWideletterSpacing: 0.4
trackingWiderletterSpacing: 0.8
trackingWidestletterSpacing: 1.6

Line Height

ClassProperties
leadingNonelineHeight: 1
leadingTightlineHeight: 1.25
leadingSnuglineHeight: 1.375
leadingNormallineHeight: 1.5
leadingRelaxedlineHeight: 1.625
leadingLooselineHeight: 2

Text Align

ClassProperties
textAutotextAlign: auto
textLefttextAlign: left
textRighttextAlign: right
textCentertextAlign: center
textJustifytextAlign: justify

Text Decoration

ClassProperties
noUnderlinetextDecorationLine: 'none'
underlinetextDecorationLine: 'underline'
lineThroughtextDecorationLine: 'line-through'
underlineLineThroughtextDecorationLine: 'underline line-through'

Text Transform

ClassProperties
normalCasetextTransform: 'none'
uppercasetextTransform: 'uppercase'
lowercasetextTransform: 'lowercase'
capitalizetextTransform: 'capitalize'

Flex Direction

ClassProperties
flexRowflexDirection: 'row'
flexRowReverseflexDirection: 'row-reverse'
flexColflexDirection: 'column'
flexColReverseflexDirection: 'column-reverse'

Flex Wrap

ClassProperties
flexWrapflexWrap: 'wrap'
flexWrapReverseflexWrap: 'wrap-reverse'
flexNoWrapflexWrap: 'nowrap'

Align Items

ClassProperties
itemsStartalignItems: 'flex-start'
itemsEndalignItems: 'flex-end'
itemsCenteralignItems: 'center'
itemsStretchalignItems: 'stretch'
itemsBaselinealignItems: 'baseline'

Align Content

ClassProperties
contentStartalignContent: 'flex-start'
contentEndalignContent: 'flex-end'
contentCenteralignContent: 'center'
contentStretchalignContent: 'stretch'
contentBetweenalignContent: 'space-between'
contentAroundalignContent: 'space-around'

Align Self

ClassProperties
selfAutoalignSelf: 'auto'
selfStartalignSelf: 'flex-start'
selfEndalignSelf: 'flex-end'
selfCenteralignSelf: 'center'
selfStretchalignSelf: 'stretch'
selfBaselinelignSelf: 'baseline'

Justify Content

ClassProperties
justifyStartjustifyContent: 'flex-start'
justifyEndjustifyContent: 'flex-end'
justifyCenterjustifyContent: 'center'
justifyBetweenjustifyContent: 'space-between'
justifyAroundjustifyContent: 'space-around'
justifyEvenlyjustifyContent: 'space-evenly'

Flex

ClassProperties
flexNoneflex: 0
flexAutoflex: 1

Flex Grow

ClassProperties
flexGrowflexGrow: 1
flexGrowNoneflexGrow: 0

Flex Shrink

ClassProperties
flexShrinkflexShrink: 1
flexShrinkNoneflexShrink: 0

Container Component

Usage

import {Container} from 'reactstrap-native-web';

Document

NameDescriptionDefaultTypeRequired
fluidType container you want: "sm", "md", "lg", "xl", true You can reference link Container bootstrap to know use themfalseString or Booleanfalse
debugSupport debug for container component ( add border around container component )falseBooleanfalse

Example with default container and enable debug

import React from 'react';
import {View, Text} from 'react-native';
import {Container} from 'reactstrap-native-web';

export const ContainerWithDebug = () => {
  return (
    <Container debug>
      <View>
        <Text>Container</Text>
      </View>
    </Container>
  );
};
On WebOn IOSOn Android
npm.io containerWithDebug.jsnpm.io containerWithDebug.jsnpm.io containerWithDebug.js

Row Component

Usage

import {Row} from 'reactstrap-native-web';

Document

Col Component

Usage

import {Col} from 'reactstrap-native-web';

Document

NameDescriptionDefaultTypeRequired
colNumber column: 1...12 or 'auto' or object: {size: number, offset: number} You can reference link Column ReactstrapNoneString or Number or Objecttrue
smNumber column: 1...12 or 'auto' or object: {size: number, offset: number} You can reference link Column ReactstrapNoneString or Number or Objectfalse
mdNumber column: 1...12 or 'auto' or object: {size: number, offset: number} You can reference link Column ReactstrapNoneString or Number or Objectfalse
xlNumber column: 1...12 or 'auto' or object: {size: number, offset: number} You can reference link Column ReactstrapNoneString or Number or Objectfalse
lgNumber column: 1...12 or 'auto' or object: {size: number, offset: number} You can reference link Column ReactstrapNoneString or Number or Objectfalse
debugSupport debugfalseBooleanfalse

Example

import React from 'react';
import {Text} from 'react-native';
import {Container, Row, Col} from 'reactstrap-native-web';

export const TestColumn = () => {
  return (
    <Container fluid>
      <Row>
        <Col
          col={{size: '3', offset: '1'}}
          sm={{size: '6', offset: '0'}}
          md={{size: '4', offset: '0'}}
          debug>
          <Text>Col 6</Text>
        </Col>
        <Col
          col={{size: 7, offset: '1'}}
          sm={{size: 6, offset: '0'}}
          md={{size: 7, offset: '1'}}
          debug>
          <Text>Col 6</Text>
        </Col>
      </Row>
    </Container>
  );
};
On WebOn IOSOn Android
npm.io demo.jsnpm.io demo.jsnpm.io demo.js

Image Component

Usage

import {Image} from 'reactstrap-native-web';

Document

Use library react-native-fit-image

Example

Please reference link react-native-fit-image

TextShadow Component

Usage

import {TextShadow} from 'reactstrap-native-web';

Document

NameDescriptionDefaultTypeRequired
childrenstring text shadowText ShadowStringfalse
stylestyle for text Text StyleNoneTextStylePropsfalse
textShadowstring shadow as css text shadowNoneStringtrue

Example

import {TextShadow} from 'reactstrap-native-web';

export const TextShadowDemo = () => {
  return (
   <View style={{flex: 1, backgroundColor: "#232323"}}>
       <TextShadow textShadow={'0 0 5px #FFF, 0 0 10px #FFF, 0 0 15px #FFF, 0 0 20px #49ff18, 0 0 30px #49FF18, 0 0 40px #49FF18, 0 0 55px #49FF18, 0 0 75px #49ff18'} style={{color: "#FFFFFF"}} />
   </View>
  );
};
On AndroidOn IOS
npm.ionpm.io

Inspired by

Contributing

Pull requests are always welcome! Feel free to open a new GitHub issue for any changes that can be made.

Working on your first Pull Request? You can learn how from this free series How to Contribute to an Open Source Project on GitHub

Author

Pham Minh Hai Au

License

MIT