3.0.1 • Published 4 years ago

react-native-bpk-styles v3.0.1

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
4 years ago

react-native-bpk-styles

Common styles for React Native components.

Installation

npm install react-native-bpk-styles --save-dev

Shadows

The package includes definitions for the Backpack shadows. These are available as objects that can be spread in style definitions. These are iOS only and need to be complemented with an appropriate elevation for Android.

Usage

import React from 'react';
import { StyleSheet } from 'react-native';
import {
  colorWhite,
  borderRadiusSm,
  elevationBase,
  elevationLg
} from 'bpk-tokens/tokens/base.react.native';
import { shadows } from 'react-native-bpk-styles';

const styles = StyleSheet.create({
  component: {
    backgroundColor: colorWhite,
    borderRadius: borderRadiusSm,
    ...Platform.select({
      ios: shadows.base(),
      android: {
        elevation: elevationBase
      },
    })
  },
  componentFocused: Platform.select({
    ios: shadows.large(),
    android: {
      elevation: elevationLg,
    }
  })
});

const MyComponent = props => {
  const { focused, children } = props;
  return (
    <View style={[styles.component, focused && styles.componentFocused]}>
      {children}
    </View>
  );
};

export default MyComponent;

Gradients

The package includes definitions for the Backpack gradients. These are available as objects that can be spread in the props of a LinearGradient from react-native-linear-gradient.

Usage

import React from "react";
import { View } from "react-native-linear-gradient";
import LinearGradient from "react-native-linear-gradient";
import {
  colorWhite,
  borderRadiusSm,
  elevationBase,
  elevationLg
} from "bpk-tokens/tokens/base.react.native";
import { gradients } from "react-native-bpk-styles";

const MyComponent = props => {
  return (
  <View>
    <LinearGradient {...gradients.primary()}>
      {children}
    </LinearGradient>
    <LinearGradient {...gradients.primary(gradients.ANGLES.down)}>
      {children}
    </LinearGradient>
  </View>
  );
};

export default MyComponent;

API

The gradients.primary function takes an optional argument indicating the direction(given by the start to end) of the gradient. The valid directions are available in gradients.ANGLES and are:

  • ANGLES.down
  • ANGLES.right
  • ANGLES.left
  • ANGLES.up
  • ANGLES.topLeft
  • ANGLES.topRight
  • ANGLES.bottomLeft
  • ANGLES.bottomRight
3.0.1

4 years ago

3.0.0

4 years ago

2.0.15

4 years ago

2.0.14

4 years ago

2.0.13

4 years ago

2.0.12

4 years ago

2.0.11

4 years ago

2.0.10

4 years ago

2.0.9

4 years ago

2.0.8

4 years ago

2.0.8-alpha.1

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.50

5 years ago

1.1.49

5 years ago

1.1.48

5 years ago

1.1.47

5 years ago

1.1.46

5 years ago

1.1.45

5 years ago

1.1.44

5 years ago

1.1.43

5 years ago

1.1.42

5 years ago

1.1.41

5 years ago

1.1.40

5 years ago

1.1.39

5 years ago

1.1.38

5 years ago

1.1.37

5 years ago

1.1.36

5 years ago

1.1.35

5 years ago

1.1.34

5 years ago

1.1.33

5 years ago

1.1.32

5 years ago

1.1.31

5 years ago

1.1.30

5 years ago

1.1.29

5 years ago

1.1.28

5 years ago

1.1.27

5 years ago

1.1.26

5 years ago

1.1.25

5 years ago

1.1.24

5 years ago

1.1.24-beta.1

5 years ago

1.1.23

5 years ago

1.1.22

5 years ago

1.1.21

5 years ago

1.1.20

6 years ago

1.1.19

6 years ago

1.1.18

6 years ago

1.1.17

6 years ago

1.1.16

6 years ago

1.1.15

6 years ago

1.1.14

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago