1.0.37 • Published 2 years ago

react-native-design-sprint v1.0.37

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

Warning !

I am currently facing issues with this lib on Expo. To everyone who tries this library, do not hesitate to open an issue if you face it too, just to see if I'm the only one who has this problem ! I'm working on it ! Thank you !

DesignSprint

DesignSprint is a little component library I made while I was learning React Native.

This library has not been tested on IOS ! I cannot guarantee the result on IOS for the time being !

This react native library offers some components to make mobile coding faster with prebuilt and fully-personnalizable widgets. I'll give you some screenshots to see what are the default components of this lib, but remember that you can always (on every component of this lib) add your own style to customize 'em ! This lib has been coded with only the standard react-native components, no external library has been used !

Here is a list of the widgets:

  • Avatar (utilisateur) : alt text
  • Clickable (bouton) : alt text
  • colors (a full package of colors),
  • DropDown (a button which displays a list on click) : alt text
  • LoginForm (login form) : alt  text
  • Input (a text input) : alt text
  • Layout (an default app layout),
  • Spacer (a horizontal or vertical spacer),
  • Title (a very big text) : alt text

Since v1.0.6, this lib adds little functions to make programming easier :

  • log (e: any) which equals to console.log(e: any) : makes it faster to type,
  • toast (e: string) which equals to a short centered Android toast : it has not been tested on IOS !
  • capitalize (e: string) which returns a string capitalized like in this example : capitalize('hello world') ==> 'Hello world'
  • ftoi (e: number) which returns the entire part of a float : ftoi(4.55) ==> 4

Installation

To install DesignSprint, just type in your project folder : For npm :

npm i react-native-design-sprint

For yarn :

yarn add react-native-design-sprint

And then, import the components you want to use in your project, as you could have done for react native components :

import { Component1, Component2 } from 'react-native-design-sprint';

You're done !

How to use

This lib's components are used the same way than react-native's ones :

import { Avatar, Title } from 'react-native-design-sprint';

const App = () => {
  return (
    <Title> My title </Title>
    <Avatar text='My avatar' />
  )
}

export default App;

Next, you'll see a list of every component's options, to understand how they work, and how you can customize them.

Components' options

Avatar

OptionMandatory?TypeDescriptionExampleDefault
imageUrlnostringloads an image into the Avatar<Avatar imageUrl="https://www.image.com" />'none'
textnostringdisplays the first letter into the Avatar<Avatar text="Evan" />'user'
connectednostringchanges the color<Avatar connected="connected" />'none'
sizenonumberSize of the Avatar (in px)<Avatar size={140} />100
stylenoStyleProp <ViewStyle>style applied to main layout<Avatar style={{ borderRadius: 15 }} />{ }
backgroundColornostringbackground color<Avatar backgroundColor={colors.red} />'none'

Clickable

OptionMandatory?TypeDescriptionExampleDefault
primarynobooleanloads a primary prebuilt style (with primaryColor)<Clickable primary />false
secondarynobooleansame as primary<Clickable secondary />false
disablednobooleandisables the button<Clickable disabled />false
primaryColorif primary or secondarystringset a colorbase for prebuilt style<Clickable primaryColor='#000'colors.red700
onPressno(e: GestureResponderEvent) => voidonPress function<Clickable onPress={() => function()} />console.log('You clicked here !')
textStylenoStyleProp <TextStyle>applies a style for the button's text<Clickable textStyle={{ color: '#fff' }} />{ }
stylenoStyleProp <ViewStyle>applies a style for the buttonsame as textStyle{ }
textnostringbutton text<Clickable text='Click here !' />'Click here'
shadownostringdisplays a cheated bordered shadow<Clickable shadow='left-top' />'none'
shadowColornostringshadow's color<Clickable shadowColor='#000' />colors.grey60
imageUrlnostringurl of an image<Clickable imageUrl='https://reactnative.dev/img/tiny_logo.png' />''
imageHeightif imageUrlnumberimage height<Clickable imageHeight={40} />40
imageWidthif imageUrlnumberimage widthsame as imageHeight40
imageStyleif imageUrlStyleProp <ImageStyle>image style<Clickable imageStyle={{ borderRadius: 15 }} />{ }
childrennoanyany component you want to render<Clickable> <Text>Button</Text> </Clickable>{ }
transparentBackgroundnobooleanremoves backgroundColor<Clickable transparentBackground />false

If you want to render icons in front of text, you should use the children prop !

colors

Its a file where many colors are defined. It is used this way : colors.COLORNAME. For example : colors.red900. Refer to src/colors.tsx to see the list !

SlidingPanel

OptionMandatory?TypeDescriptionExampleDefault
stylenoStyleProp <ViewStyle>your own style{ backgroundColor: '#fff' }{ }
sizenonumbersize when opened (0 if fullscreen)500400
initialSizenonumbersize when closed1020
jumpToMaxnobooleangoes to max/min size on scrolltruetrue
topBarDisablednobooleanif true, sliding top bar will be disabledtruefalse
childrennoReact.ReactChild or React.ReactChild[]components rendered in the panel<SlidingPanel> <Text>Hello</Text> </SlidingPanel><></>
isOpenednobooleantells if panel is opened at rendertruetrue
animationTypeno'timing' or 'spring' or 'none' (string)animation type on scroll'spring''timing'
animationDurationnonumberif animationType == 'timing', sets animation duration500500
disabledRadiusOnFullnobooleanif size == 0, when opened, disable borderRadiustruetrue

SlidingPanel has no function like _panelRef.open() or _panelRef.close() at the moement. But it is under developpement !

DropDown

OptionMandatory?TypeDescriptionExampleDefault
listyesanylist to be displayed when button clicked<DropDown list={myList} />{ }
titlenostringtext on the clickable<DropDown title='Click here' />'Dropdown'
renderItemyes(item: any) => voidsame as FlatList's renderItem<DropDown renderItem={(item) => function(item)} />console.log('Lol you forgot the renderItem function')
onOpenno( ) => voidfunction called when dropdown is opened<DropDown onOpen={() => console.log('dropdown is open !')} />undefined
onCloseno( ) => voidfunction called when dropdown is closedsame as onOpenundefined
stylenoStyleProp <ViewStyle>general style<DropDown style={{ backgroundColor: '#212121' }} />{ }
listStylenosame as stylestyle to be applied generally on the list (not on each item !)same as style{ }
buttonStylenosame as stylestyle applied on the clickablesame as style{ }
titleStylenosame as stylestyle applied on the title (clickable's text)same as style{ }
buttonTypenostringprimary/secondary/disabled ... see Clickable options<DropDown buttonType='primary' />'none'

If you want to pass style for each item of the list, do it through your renderItem function !

LoginForm

OptionMandatory?TypeDescriptionDefaultExample
titlenostringtitle text''<LoginForm title='Login' />
titleStylenoStyleProp <TextStyle>style on title{ }<LoginForm titleStyle={{ color: '#000' }} />
buttonColornostringcolor of the buttoncolors.black<LoginForm buttonColor={colors.red400} />
buttonTypenostringprimary/secondary/disabled (linked to clickable)'primary'<LoginForm buttonType='secondary' />
buttonStylenoStyleProp <ViewStyle>style on button{ }<LoginForm buttonStyle={{ backgroundColor: '#fff8' }} />
buttonStickynostringleft/center.. make the button float to a side'none'<LoginForm buttonSticky='right' />
buttonShadownostringnone/right-top... displays a cheated shadow using borders'none'<LoginForm buttonShadow='bottom-right-top' />
buttonShadowColornostringcolor of the shadowcolors.grey60<LoginForm buttonShadowColor={colors.dark} />
stylenoStyleProp <ViewStyle>main style{ }<LoginForm style={{ backgroundColor: '#fff8' }} />
onSubmitno(object: any) => voidfunction called on submitconsole.log('Form callback missing. Please add one.')<LoginForm onSubmit={() => console.log('You\'re logged in !')}/>
shadownostringleft-bottom.. say where the shadow is'none'<LoginForm shadow='left-bottom' />
shadowColornostringcolor of the shadowcolors.grey60<LoginForm shadowColor={colors.dark}/>
borderRadiusnonumberborder radius for the layout15<LoginForm borderRadius={20} />
placeholderTopnostringtext displayed in top placeholder'Email'<LoginForm placeholderTop='type your email here' />
placeholderTopStylenoStyleProp <TextStyle>top placeholder style{ }<LoginForm placeholderTopStyle={{ color: colors.white }} />
placeholderBottomnostringbottom placeholder style'Password'same as placeholderTop
placeholderBottomStylenosame as placeholderTopStyle{ }same as placeholderTopStyle
childrennoanyany component to be rendered inside(<> </>)<LoginForm> <Text> Hello World ! </Text> </LoginForm>

Input

OptionMandatory?TypeDescriptionDefaultExample
typenostringemail ? Password ?'text'<Input type='text' />
placeholdernostringplaceholder'Input text right here '`<Input
placeholderColornostringplaceholder colorcolors.grey200<Input placeholderColor={colors.transp400}/>
stylenoStyleProp <ViewStyle>style applied on main layout{ }<Input style={{ backgroundcolor: colors.red500 }} />
textStylenoStyleProp <TextStyle>style applied to the text{ }same as style
onFinishedno(e: string) => voidfunction called when submittedconsole.log('You typed something !')<Input onFinished={(e) => console.log(e)} />
onCharTypedno(e: string) => voidfunction called when a text is changed{ }<Input onCharTyped={(e) => console.log(e)} />
requirednobooleantells wether this field is required or notfalse<Input required />
valuenostringtext that is typed in the entry by default''<Input value='Hi !'/>
placeholderColornostringplaceholder's colorcolors.grey200<Input placeholderColor={colors.wtransp500} />
noRegexnobooleanfor email only: disables regexfalse<Input noRegex />
disablednobooleandisables the entryfalse<Input disabled />
onFocusno( ) => voidfunction when focus gained( ) => { }<Input onFocus={() => log('I\'m focused !')}

Layout

OptionMandatory?TypeDescriptionDefaultExample
darknobooleanenables dark backgroundfalse<Layout dark />
titlenostringdisplays a title''<Layout title='Welcome !' />
titleStylenoStyleProp <TextStyle>style applied on title{ }<Layout titleStyle={{ color: colors.grey700 }} />
titleColornostringtitle colorcolors.black<Layout titleColor={colors.grey700} />
titleSizenonumbersize (px) for font title50<Layout titleSize={42}/>
stylenoStyleProp <ViewStyle>style applied on main layout{ }<Layout style={{ backgroundColor: '#0008' }} />
scrollablenobooleanmakes the layout scrollablefalse<Layout scrollable />
backgroundColornostringset a custom background colordepending on dark option<Layout backgroundColor={colors.fadeRedDark} />

Spacer

OptionMandatory?TypeDescriptionDefaultExample
verticalif not horizontalbooleanmakes spacer verticalfalse<Sapcer vertical />
horizontalif not verticalbooleanmakes spacer horizontalfalse<Spacer horizontal />
sizeyesnumbersize of the spacer (px)20<Sapcer size={15} />

Title

OptionMandatory?TypeDescriptionDefaultExample
stylenoStyleProp <TextStyle>style applied on the text{ }<Title style={{ color: colors.white }} />
oofsizenobooleanbiggest sizefalse<Title oofsize />
bignobooleanbig sizefalse<Title big />
mediumnobooleanmedium sizefalse<Title medium />
smallnobooleansmall sizefalse<Title small />
extraSmallnobooleanextra small sizefalse<Title extraSmall />
boldnobooleanbold textfalse<Title bold />
fontnostringadds custom fontundefined<Title font='Comic Sans' />
sizenonumberset the text size (px)20<Title size={24} />
colornostringset the text colorcolors.black<Title color={colors.grey200} />
rightnobooleanmakes the title float rightfalse<Title right />
centernobooleancenters the titlefalse<Title center />

Contribute

Feel free to contribute if you know how to make this lib better !

1.0.33

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago