npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@janbox/rn-ui

v0.1.86

Published

test

Downloads

106

Readme

@janbox/rn-ui

react native component design system

Installation

npm install @janbox/rn-ui

Usage

import { multiply } from '@janbox/rn-ui';

// ...

const result = await multiply(3, 7);

Button component

import { Button } from '@janbox/rn-ui';

<Button
  title="Button"
  leftIcon="symbol"
  rightIcon="symbol"
  onPress={onPress}
  style={styles.button}
  fullSize
/>

// ...

ButtonProps {
  title?: string;
  size?: 48 | 40 | 32;
  type?: 'PRIMARY' | 'SECONDARY_ONE' | 'SECONDARY_TWO' | 'TEXT_LINK' | 'ICON';
  disable?: boolean;
  isLoading?: boolean;
  iconSize?: 24 | 16;
  width?: number;
  leftIcon?: string;
  rightIcon?: string;
  iconBtn?: string;
  fullSize?: boolean;
  titleStyle?: StyleProp<TextStyle>;
}

CheckBox component

import { CheckBox } from '@janbox/rn-ui';

<CheckBox title={'Check box'} />

// ...

CheckBoxProps {
  defaultValue?: boolean;
  onChange: Function;
  disable?: boolean;
  style?: StyleProp<ViewStyle>;
  title?: string | undefined;
}

Dim component

import { Dim } from '@janbox/rn-ui';

<Dim>{children}</Dim>

// ...

DimProps {
  children?: Function;
}

EmptyState component

import { EmptyState } from '@janbox/rn-ui';

<EmptyState
  title="Title"
  message="Message"
  onHandle={() => {}}
/>
// ...

EmptyStateProps {
  title?: string;
  image?: string;
  message: string;
  buttonTitle?: string;
  onHandle?: Function;
}

CodeOTP component

import { CodeOTP } from '@janbox/rn-ui';

<CodeOTP
ref={refOTP}
phoneNumber="0858589885"
title="Xác nhận"
error={error}
titleResend="Gửi lại OTP"
onVerify={getMoviesFromApiAsync}
timeResend={3}
onPressBtn={onPressBtn}
description="Điền mã OTP vừa được gửi vào số điện thoại"
titleBtnDialog="Tiếp tục"
titleDialog={'Đây là title nhé, tối đa 2 dòng'}
descriptionDialog={'Đây là description nhé, tối đa 2 dòng thôi nhé'}
onResend={onResend}
/>
// ...
CodeOTPProps {
  title: string;
  description: string;
  titleDialog: string;
  descriptionDialog: string;
  titleResend: string;
  titleBtnDialog: string;
  onPressBtn?: () => void;
  cellCount?: number;
  timeResend?: number;
  phoneNumber: string;
  onVerify: (value: string) => void;
  onResend: (cb: Function) => void;
}

BottomSheet component

import { BottomSheet } from '@janbox/rn-ui';

<BottomSheet
  ref={refBottomSheet}
  titleHeader={'Title'}
  isWithIcon
>
    {children}
</BottomSheet>

// ...

BottomSheetProps {
  top?: number;
  onModalHide?: ButtonAction;
  children: JSX.Element;
  titleHeader?: string;
  isWithIcon?: boolean;
  isWithButton?: boolean;
  rightHeaderIcon?: string;
  rightHeaderBtn?: string;
  rightHeaderPress?: Function;
  maxHeight?: boolean;
  contentWrapperStyle?: StyleProp<ViewStyle>;
}

Dialog component

import { Dialog } from '@janbox/rn-ui';

<Dialog
  ref={refDialog}
  title={'Đây là title nhé, tối đa 2 dòng'}
  description={'Đây là description nhé,  tối đa 2 dòng thôi nhé'}
/>

// ...

DialogProps {
  top?: number;
  onModalHide?: ButtonAction;
  title?: string;
  description?: string;
  oneButton?: boolean;
  titleBtn?: string;
  onPressBtn?: Function;
  leftTitleBtn?: string;
  rightTitleBtn?: string;
  leftPressBtn?: Function;
  rightPressBtn?: Function;
}

Popup component

import { Popup } from '@janbox/rn-ui';

<Popup
  ref={refPopup}
  banner={imageUrl}
  title={'Đây là title, tối đa 1 dòng'}
  description={'Đây là description,  tối đa 4 dòng'}
      />

// ...

PopupProps {
  top?: number;
  onModalHide?: ButtonAction;
  title?: string;
  description?: string;
  oneButton?: boolean;
  titleBtn?: string;
  onPressBtn?: Function;
  leftTitleBtn?: string;
  rightTitleBtn?: string;
  leftPressBtn?: Function;
  rightPressBtn?: Function;
  banner?: any;
  bannerFullSize?: boolean;
}

NavigationBar component

import { NavigationBar } from '@janbox/rn-ui';

<NavigationBar
  title="Title tối đa 1 dòng"
  rightIcon1="shopping"
  pressRightIcon1={handleGoToShopping}
  rightIcon2="share"
  pressRightIcon1={handleShare}

  // rightButton="Chỉnh sửa"
/>

// ...

NavigationBarProps {
  leftIcon?: string;
  leftButtonPress?: Function;
  title?: string;
  rightIcon1?: string;
  pressRightIcon1?: Function;
  rightIcon2?: string;
  pressRightIcon2?: Function;
  rightButton?: string;
  pressRightButton?: Function;
  offDivider?: boolean; //Off bottom line
  backgroundColor?: string;
  isWhite?: boolean; //white content header
}

PlaceholderImage component

import { PlaceholderImage } from '@janbox/rn-ui';

<PlaceholderImage width={40} height={40} />

// ...

PlaceholderImageProps {
  width?: number;
  height?: number;
}

RadioButton component

import { RadioButton } from '@janbox/rn-ui';

<RadioButton
  defaultValue={selected}
  onChange={(v) => setSelected(v)}
  title={'Radio'}
  checked={selected}
/>

// ...

RadioButtonProps {
  onChange?: any;
  disable?: boolean;
  defaultValue: boolean; // Giá trị mặc định checked/no check
  title?: string | undefined;
  style?: StyleProp<ViewStyle>;
  checked: boolean; // checked = true thì không uncheck khi click vào nữa
}

Skeleton component

  • Có 5 dạng Skeleton (SkeletonLarge, SkeletonHorizontal, SkeletonImage, SkeletonLine, SkeletonSmall). Tuỳ theo cách hiển thị mà sử dụng component tương ứng.
import { SkeletonLarge } from '@janbox/rn-ui';

<SkeletonLarge size={78} />

// ...

SkeletonLargeProps {
  size?: number;
  style?: ViewProps['style'];
}

Tag component

import { Tag } from '@janbox/rn-ui';

<Tag tagList={data} />

// ...

TagModel {
  id: string;
  name: string;
}
TagProps {
  tagList?: Array<TagModel>;
  haveIconLeft?: boolean;
  haveIcRight?: boolean;
  isScroll?: boolean;
}

FloatingButton component

import { FloatingButton } from '@janbox/rn-ui';

//data actionList
const actions = [
  {
    text: 'Estimate Price',
    icon: Images.estPrice,
    name: 'bt_estimate',
    color: '#1135A8',
  },
  {
    text: 'Messenger',
    icon: Images.messenger,
    name: 'bt_mess',
    color: '#FF626F',
  },
  {
    text: 'Zalo',
    icon: Images.zalo,
    name: 'bt_zalo',
    color: '#0180C7',
  },
  {
    text: 'WhatApp',
    icon: Images.whatApp,
    name: 'bt_what_app',
    color: '#2DB843',
  },
];

<FloatingButton
  listMenu={actions}
  floatingMainButton={Images.messenger}
  mainBackground={'#1348F2'}
/>

// ...

IMenuItem extends IActionProps {
  icon: JSX.Element; //Icon menu {require('./icon.png')}
  text: string; //label menu item
  color: string; //background color menu item
  name: string; //key item
}

FloatingButtonProps extends IFloatingActionProps {
  listMenu: IMenuItem[]; // tối đa 5 item, nhiều hơn hiển thị 5 item đầu tiên
  floatingMainButton: JSX.Element; //Image MainButton {require('./icon.png')}
  mainBackground: string; //backgroundColor Floating main button
}

Tooltips component

import { Tooltips } from '@janbox/rn-ui';

const renderButtonTips = () => (
  <TouchableOpacity
    style={styles.btnShowTip}
    onPress={() => setShowPopover(true)}
  >
    <Text>Click vào đây</Text>
  </TouchableOpacity>
);

<View>
  <Tooltips
  visibleTooltips={showPopover}
  contentToolTips={
  'Subscribe to our e-newsletter and stay updated on the latest special offers!'
  }
  onClose={() => setShowPopover(false)}
  placement={Placement.AUTO}
  touchComponent={renderButtonTips}
  />
</View>

// ...

ToolTipProps extends PopoverProps {
  touchComponent?: ReactNode; //Component click show tooltips
  contentToolTips: string; //Truyền nội dung của tooltips
  placement?: Placement | Array<Placement>; // Vị trí hiện Tooltips bao gồm 'top', 'bottom', 'left', 'right', hoặc 'auto', Nên để giá trị auto vì nó sẽ tự động xác định vị trí tốt nhất để hiển thị đầy đủ
  onClose?: Function; //Hide tooltips
  visibleTooltips: boolean; //Trạng thái show/hide
}

SnackBar component

import { SnackBar } from '@janbox/rn-ui';
import Toast from 'react-native-toast-message';

// Button action show Snackbar toast
<Button
  title="test"
  onPress={() => {
  Toast.show({
  type: 'toastCustom',
  text1:
    'Content cứ show thoải mái, nhưng cũng nên giới hạn tầm 3 dòng là tối đa nhé',
  props: {
  type: 'error',
  icon: {
    name: 'wifi',
    color: '#fff',
    size: 24,
    },
  textButton: 'Button',
  onPressButton: () => {
    console.log('lala');
    },
  },
  position: 'bottom',
    });
  }}
  style={styles.button}
/>

// ...

<SnackBar />

// ...

IConfigSnackBar {
  type: 'info' | 'success' | 'error'; //Type Snackbar, default is 'info'
  //left icon
  icon?: {
    size: number;
    name: string;
    color: string;
  };
  textButton?: string; // Title right button
  onPressButton?: () => void; //onPress button
}

Input component

import { Input } from '@janbox/rn-ui';
import { useForm } from 'react-hook-form';

const {
    control,
    handleSubmit,
    formState: { errors },
  } = useForm({
    mode: 'all',
  });

<Input
  title="Hello word"
  rightIcon
  renderRightIcon=
  controller={{
    name: 'fieldInput',
    control: control,
    rules: {
      required: {
        value: true,
        message: 'Require field',
      },
      validate: (value) => value.length >= 6 || `Tối thiểu 6 kí tự`,
    },
  }}
  errorText={errors?.fieldInput?.message}
  placeholder={'Nhập số điện thoại nhé'}
  autoCapitalize={'none'}
  selectCountry
  textNote={'Đây là note'}
  showClearIcon
  // isSecure
  // disabled
/>

// ...

InputProps extends TextInputProps {
  title?: string;
  controller: UseControllerProps;
  placeholder?: string;
  selectCountry?: boolean; //show/hide Select country
  errorText?: any; //Show error khi có error validate truyền vào
  textNote?: string;
  numCountTry?: string; //Country Code
  renderFlag?: ReactNode; //custom country flag icon
  containerStyle?: StyleProp<ViewStyle>;
  inputStyle?: StyleProp<ViewStyle>;
  showClearIcon?: boolean; // Show button clear value khi text input
  disabled?: boolean;
  isSecure?: boolean; // bật/tắt secureTextEntry dùng cho password field
  rightIcon?: boolean;
  renderRightIcon?: ReactNode; //custom right icon
  isRequire?: boolean; // *
}

Tham khảo thêm react-hook-form để hiểu cách sử dụng

Label component

import { Label } from '@janbox/rn-ui';

<Label title={'Text Label'} titleSize="14R" showIcon={false} type="GREEN" />

// ...

interface ILabelType {
  backgroundColor: string;
  borderColor: string;
}

const LabelType: { [key: string]: ILabelType } = {
  INFO: {
    backgroundColor: Colors.black6s,
    borderColor: Colors.black5s,
  },
  GREEN: {
    backgroundColor: Colors.green6s,
    borderColor: Colors.green5s,
  },
  RED: {
    backgroundColor: Colors.red6s,
    borderColor: Colors.red5s,
  },
  ORANGE: {
    backgroundColor: Colors.orange6s,
    borderColor: Colors.orange5s,
  },
};

LabelProps {
  showIcon?: boolean;
  type?: 'INFO' | 'GREEN' | 'RED' | 'ORANGE'; //Mặc định type là 'INFO'
  title: string;
  titleSize?: '14R' | '12R';
}

Tabs component

import { Tabs } from '@janbox/rn-ui';

const arryTab = [
  {
    id: 0,
    tabName: 'Thông tin chi tiết',
  },
  {
    id: 1,
    tabName: 'Nội dung cơ bản',
    badge: 1,
  },
];

<Tabs tabs={arryTab} />

// ...

TabModel {
  id: number;
  tabName: string;
  badge?: number;
}
TabProps {
  icon?: string;
  showRedDot?: boolean;
  tabs: TabModel[];
  scrollableTab?: boolean;
}

SearchBar component

import { SearchBar } from '@janbox/rn-ui';

<SearchBar
  ref={refSearch}
  placeholder={'Bạn tìm gì hôm nay...'}
  showClearIcon
  onSubmitEditing={getSearch}
/>

// ...

SearchBarProps extends TextInputProps {
  placeholder: string;
  containerStyle?: StyleProp<ViewStyle>;
  inputStyle?: StyleProp<ViewStyle>;
  showClearIcon?: boolean;
}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library