0.1.0 • Published 2 years ago

@tarikfp/react-native-ui-kit v0.1.0

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

Installing

Install dependencies

  yarn add @tarikfp/react-native-ui-kit

or

  npm install @tarikfp/react-native-ui-kit

Components

Button

A button is component that the user can press to trigger an action.

Properties

Inherits TouchableOpacity and the following:

PropTypeDescription
sizestringSize of the button. Can be one of the following: large, medium, small, xsmall
loadingbooleanWhether button is in loading state. Loading indicator will be shown next to the label in case of true.
labelStyleStyleProp<TextStyle>Button label style.
labelstringLabel of the button.
backgroundColorstringBackground color of the button.
startIconIconPropsProps of the icon which will be displayed start of the button.
endIconIconPropsProps of the icon which will be displayed end of the button.
loadingPropsActivityIndicatorPropsProps of the loading indicator.

Usage

import { Button } from "@tarikfp/react-native-ui-kit";

return (
  <Button
    size="xsmall"
    backgroundColor="royalblue"
    label="Start recording"
    startIcon={{
      name: "microphone",
      type: "FontAwesome",
      color: "white",
    }}
  />
);

Avatar

Avatars represent a user and can contain photos, icons, or even text.

Avatar Icon

Avatar with icon. This component uses react-native-vector-icons under the hood.

PropTypeDescription
sizenumberSize of the avatar. Default 32
backgroundColorstringBackground color of the avatar.
styleStyleProp<ViewStyle>Style of the avatar.
namestringName of the icon.
typestringType of the icon. See available icon types
colorstringColor of the icon.
iconPropsIconPropsProps of the icon.

Avatar Icon usage

import { Avatar } from "@tarikfp/react-native-ui-kit";

return (
  <Avatar.Icon color="dodgerblue" size={65} name="react" type="Fontisto" />
);

Avatar Image

Inheirts Image props and the following.

PropTypeDescription
sizenumberSize of the avatar. Default 32
sourceImageSourcePropTypeThe image source (either a remote URL or a local file resource).
backgroundColorstringBackground color of the avatar.
styleStyleProp<ViewStyle>Style of the image wrapper.
imageStyleStyleProp<ImageStyle>Style of the image.

Avatar Image usage

import { Avatar } from "@tarikfp/react-native-ui-kit";

return (
  <Avatar.Image
    size={65}
    source={{ uri: "https://reactnative.dev/img/logo-og.png" }}
  />
);

Avatar Text

Avatar with text component.

PropTypeDescription
sizenumberSize of the avatar. Default 32
labelstringText to display on avatar.
backgroundColorstringBackground color of the avatar.
labelColorstringColor of the avatar label.
styleStyleProp<ViewStyle>Style of the avatar label wrapper.
labelStyleStyleProp<TextStyle>Style of the label.

Avatar Text usage

import { Avatar } from "@tarikfp/react-native-ui-kit";

return <Avatar.Text backgroundColor="darkorange" size={65} label="TP" />;

Header

Headers are the components that display information and actions for the current screen.

Properties

Inherits View and the following:

PropTypeDescription
heightnumberHeight of the header component. Defaults to 56.
hasShadowbooleanWhether header has the shadow style applied or not. Defaults to false
backgroundColorstringBackground color of the header.
styleStyleProp<ViewStyle>Style of the header.

Usage

import { Header } from "@tarikfp/react-native-ui-kit";

return (
  <Header>
    <Header.Title label="Home screen" />
    <Header.Image
      source={{
        uri: "https://reactnative.dev/img/logo-og.png",
      }}
    />
    <Header.Icon
      alignment="end"
      name="arrow-right"
      type="MaterialCommunityIcons"
    />
  </Header>
);

Header Icon

Header icon element. This component uses react-native-vector-icons under the hood.

Properties

Inherits IconProps and the following:

PropTypeDescription
styleStyleProp<TextStyle>Style of the icon.
wrapperStyleStyleProp<ViewStyle>Style of the icon wrapper.
alignmentstringAlignment of the icon component. Can be one of the following: start, end

Header Icon usage

import { Header } from "@tarikfp/react-native-ui-kit";

return (
  <Header height={72}>
    <Header.Icon name="arrow-left" type="MaterialCommunityIcons" />
  </Header>
);

Header Image

Header image element.

Properties

Inherits Image props and the following:

PropTypeDescription
styleStyleProp<ViewStyle>Style of the image.

Header Image usage

import { Header } from "@tarikfp/react-native-ui-kit";

return (
  <Header>
    <Header.Image
      source={{
        uri: "https://reactnative.dev/img/logo-og.png",
      }}
    />
  </Header>
);

Header Title

Header title element.

Properties

Inherits Text props and the following:

PropTypeDescription
titlestringTitle text.
subtitlestringSubtitle text.
subtitleStyleStyleProp<TextStyle>Style of the subtitle text.
styleStyleProp<TextStyle>Style of the title text.
wrapperStyleStyleProp<ViewStyle>Style of the wrapper view.

Header Title usage

import { Header } from "@tarikfp/react-native-ui-kit";

return (
  <Header>
    <Header.Title title="Home screen" />
  </Header>
);

Text Input

Text Input is a component for inputting text into the app via a keyboard.

Properties

Inherits TextInput and the following:

PropTypeDescription
isPasswordbooleanWhether the text input is password type. Toggling secureTextEntry with icon will be shown at the end of input in case of true
backgroundColorstringBackground color of text input.
inputStyleStyleProp<TextStyle>Style of the input.
wrapperStyleStyleProp<ViewStyle>Style of the text input wrapper.
labelstringLabel to display above input.
errorMessagestringError message text to display below input.
errorMessageIconPropsIconPropsError message icon props.
startIconIconPropsProps of the icon which will be displayed start of the input.
endIconIconPropsProps of the icon which will be displayed end of the input.
renderStartElement() => React.ReactNodeCallback function that returns React element(s) to be displayed on the start of the input. Overrides startIcon prop.
renderEndElement() => React.ReactNodeCallback function that returns React element(s) to be displayed on the end of the input. Overrides endIcon prop.
renderInput() => React.ReactNodeCallback function that returns React element(s) which will replace the default input.
endTextstringText which will be displayed on the end of the input.
endTextStyleStyleProp<TextStyle>End text style.
loadingbooleanIndicates whether input is in loading state. Loading indicator will be displayed at the end of the input.
loadingPropsbooleanIndicates whether input is in loading state. Loading indicator will be displayed at the end of the input.
renderLoading() => React.ReactNodeRenders loading section of the input.
renderPasswordIcon() => React.ReactNodeRenders custom password icon while overriding default one. isPassword must be set to true.
disabledbooleanWhether all interactions are disabled in the input.
hideDefaultEndIconsbooleanHides default end icons for password and text type input. Defaults to false (Close icon for text and eye icon for password input)
heightnumberHeight of the input. Defaults to 56
borderRadiusnumberBorder radius of the input. Defaults to 8
borderColorstringBorder color of the input. Defaults to 8
labelStyleStyleProp<TextStyle>Input text style.
errorColorstringColor of the error which will be applied to the input border, error icon and text.
renderErrorSection() => React.ReactNodeCallback function that returns React element(s) to be displayed on the error section of the input.

Usage

import { TextInput } from "@tarikfp/react-native-ui-kit";

return (
  <TextInput
    wrapperStyle={{ marginBottom: 16 }}
    label="E-Mail"
    labelStyle={{ color: "#FFFFFF" }}
    endText="Special one"
    endTextStyle={{ color: "grey" }}
    placeholder="Type your email"
    placeholderTextColor="grey"
    startIcon={{ type: "MaterialCommunityIcons", name: "email" }}
    value={email}
    onChangeText={setEmail}
  />
);

// Display custom password icon

return (
  <TextInput
    isPassword
    renderPasswordIcon={({ isSecureTextEntry, toggleSecureTextEntry }) =>
      isSecureTextEntry ? (
        <Icon onPress={toggleSecureTextEntry} name="eye" type="Feather" />
      ) : (
        <Icon onPress={toggleSecureTextEntry} name="eye-off" type="Feather" />
      )
    }
  />
);

// Display custom loading section

return (
  <TextInput
    loading
    renderLoading={(containerStyle) => (
      // inject computed container style
      <View style={[containerStyle, myStyle]}>
        <Text>Loading...</Text>
      </View>
    )}
  />
);

// Display custom start element

return (
  <TextInput
    renderStartElement={() => (
      <View>
        <Image
          style={{ width: 30, height: 30 }}
          source={{
            uri: "customImageUrl",
          }}
        />
      </View>
    )}
  />
);

List Item

List items are used to display rows of information, they are extremely flexible and can contain almost anything.

Properties

Inherits TouchableOpacityProps and the following:

PropTypeDescription
heightnumberHeight of the list item component. Defaults to 56.
hasShadowbooleanWhether list item has the shadow style applied or not. Defaults to false
backgroundColorstringBackground color of the list item.
styleStyleProp<ViewStyle>Style of the list item.

Usage

import { ListItem } from "@tarikfp/react-native-ui-kit";

return (
  <ListItem style={{ marginTop: 50 }} hasShadow height={150}>
    <ListItem.Title
      title="React Native"
      style={{ fontSize: 32, lineHeight: 55, fontWeight: "500" }}
      subtitle="Flexible list item..."
      subtitleStyle={{ fontWeight: "300", color: "grey" }}
    />
    <ListItem.Button
      alignment="end"
      backgroundColor="royalblue"
      size="xsmall"
      label="List item button"
    />
  </ListItem>
);

List Item Icon

List Item icon element. This component uses react-native-vector-icons under the hood.

Properties

Inherits IconProps and the following:

PropTypeDescription
styleStyleProp<ViewStyle>Style of the icon.
wrapperStyleStyleProp<ViewStyle>Style of the icon wrapper.
alignmentstringAlignment of the icon component. Can be one of the following: start, end

List Item Icon usage

import { ListItem } from "@tarikfp/react-native-ui-kit";

return (
  <ListItem>
    <ListItem.Icon
      name="lightbulb"
      type="MaterialCommunityIcons"
      color="orange"
    />
  </ListItem>
);

List Item Image

List Item image element.

Properties

Inherits Image props and the following:

PropTypeDescription
styleStyleProp<ViewStyle>Style of the image.

List Item Image usage

import { ListItem } from "@tarikfp/react-native-ui-kit";

return (
  <ListItem>
    <ListItem.Image
      style={{ width: 50, height: 50 }}
      source={{
        uri: "https://reactnative.dev/img/logo-og.png",
      }}
    />
  </ListItem>
);

List Item Title

List Item title element.

Properties

Inherits Text props and the following:

PropTypeDescription
titlestringTitle text.
subtitlestringSubtitle text.
subtitleStyleStyleProp<TextStyle>Style of the subtitle text.
styleStyleProp<TextStyle>Style of the title text.
wrapperStyleStyleProp<ViewStyle>Style of the wrapper view.

List Item Title usage

import { ListItem } from "@tarikfp/react-native-ui-kit";

return (
  <ListItem>
    <ListItem.Title
      title="Find new ideas!"
      subtitle="Subscribe here..."
      subtitleStyle={{ fontWeight: "300", color: "grey" }}
    />
  </ListItem>
);

List Item Button

List Item button element.

Properties

Inherits Button props and the following:

PropTypeDescription
wrapperStyleStyleProp<ViewStyle>Style of the button wrapper.
alignmentstringAlignment of the icon component. Can be one of the following: start, end

List Item Button usage

import { ListItem } from "@tarikfp/react-native-ui-kit";

return (
  <ListItem hasShadow height={150}>
    <ListItem.Button
      alignment="end"
      backgroundColor="royalblue"
      size="xsmall"
      label="List item button"
    />
  </ListItem>
);

License

MIT