1.12.6 • Published 7 months ago

@team-devmonster/react-native-tags v1.12.6

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

@team-devmonster/react-native-tags

This is under devmonster's react & react-native union project.

This project is part of the react-module&react-native-module projects, that integrate react&react-native by the devmonster team. react => @team-devmonster/react-tags General react-native-modules load map => here; General react-modules load map => here;

Other react-native modules

author: devmonster

We are always looking for investment or assistance. hompage: https://devmonster.co.kr email: aldegad@devmonster.co.kr

items

  • o => Just br.
  • o(#Button)
  • o
  • o(#Img)
  • o => this is for main contents. extends div.
  • o => this is for text. extends div.
  • o => this is for text. extends div.
  • o => this is for inline text. extends div.
  • o => this is for define list. extends div.
  • o => this is for define list title. extends div.
  • o => this is for define list description. extends div.
  • o => Under development :(help) extends div.
  • o => Under development :(help) extends div.
  • o => Under development :(help) extends div.
  • o => Under development :(help) extends div.
  • o => Under development :(help) extends p.
  • o => Under development :(help) extends p.

additional items

  • o => Like Style.create, it prevents the style from being re-rendered, but This is a function created to be used within a component. Use like state, useMemo, etc.
  const { buttonStyle, chipActiveStyle, chipStyle } = useCreateStyle({
    buttonStyle: {
      height: 28,
      ...
    },
    chipActiveStyle: {
      height: 28,
      ...
    },
    chipStyle: {
      height: 28,
      ...
    }
  });

  return (
    <Button style={buttonStyle}>
      <View style={chipActiveStyle}></View>
      <View style={chipStyle}></View>
    </Button>
  )

Getting started

$ npm install @team-devmonster/react-native-theme@latest @team-devmonster/react-native-tags@latest

Examples

Easy. Too Easy.

step1. Set Provider

// App.theme.tsx => You can use any file name :)
import React from 'react';
import { ThemeProvider, useTheme } from '@local_modules/theme';
import { TagProvider, ButtonConfig, InputConfig, ErrorTextConfig, LabelConfig, SelectConfig, TagConfig } from '@local_modules/tags';

const color = {
  light: {
    // key colors
    primary: '#4a93cf',
    warning: '#ec670b',
    success: '#9cca5a',
    danger: '#eb445a',
    placeholder: '#4d4d4d',
    backgroundColor: '#f2f2f2',
    // color steps
    white: '#ffffff',
    step50: '#f2f2f2',
    step100: '#e6e6e6',
    step200: '#cccccc',
    step300: '#b3b3b3',
    step400: '#999999',
    step500: '#808080',
    step600: '#666666',
    step700: '#4d4d4d',
    step800: '#333333',
    step900: '#191919',
    black: '#111111'
  },
  dark: {
    // key colors
    primary: '#4a93cf',
    warning: '#ec670b',
    success: '#9cca5a',
    danger: '#eb445a',
    placeholder: '#4d4d4d',
    backgroundColor: '#191919',
    // color steps
    white: '#111111',
    step50: '#191919',
    step100: '#333333',
    step200: '#4d4d4d',
    step300: '#666666',
    step400: '#808080',
    step500: '#999999',
    step600: '#b3b3b3',
    step700: '#cccccc',
    step800: '#e6e6e6',
    step900: '#f2f2f2',
    black: '#ffffff'
  }
}

const theme = (color:Color) => {
  const fontSize = {
    xs: 12 as const,
    sm: 14 as const,
    base: 16 as const,
    lg: 18 as const,
    xl: 20 as const,
    x2l: 24 as const,
    x3l: 30 as const,
    x4l: 36 as const,
    x5l: 48 as const,
    x6l: 60 as const,
    x7l: 72 as const,
    x8l: 96 as const,
    x9l: 128 as const
  }

  const shadow = {
    base: {
      shadowColor: color.black,
      shadowOffset: {
        width: 0,
        height: 2,
      },
      shadowOpacity: 0.25,
      shadowRadius: 3.84,
      elevation: 5
    },
    lg: {
      shadowColor: color.black,
      shadowOffset: {
        width: 0,
        height: 2,
      },
      shadowOpacity: 0.25,
      shadowRadius: 3.84,
      elevation: 5
    },
    card: {
      shadowColor: color.black,
      shadowOffset: {
        width: 0,
        height: 2,
      },
      shadowOpacity: 0.25,
      shadowRadius: 3.84,
      elevation: 5
    }
  }

  const div:TagConfig = {
    style: {
      color: color.black,
      fontSize: fontSize.base
    }
  }

  const button:ButtonConfig = {
    color: color.white,
    style: {
      cursor: 'pointer',
      position: 'relative',
      padding: 10,
      alignItems: 'center',
      justifyContent: 'center',
      fontSize: fontSize.base,
      height: 42,
      borderRadius: 5
    },
    disabledStyle: {
      opacity: 0.5
    }
  }
  button['fill=translucent'] = {
    color: color.primary,
    style: {
      backgroundColor: color.danger
    },
    activeStyle: {
      backgroundColor: color.black
    }
  }

  return {
    // basic theme
    color, fontSize, shadow,
    // tags theme
    div, button
  }
}

// example of Color & ColorKeys type
export type Color = typeof color.light;
export type ColorKeys = keyof Color;
export type Theme = ReturnType<typeof theme>;

export const AppThemeProvider = ({children}: {children:React.ReactNode}) => {
  return (
    <ThemeProvider color={color} theme={theme}>
      {children}
    </ThemeProvider>
  )
}

export const AppTagProvider = ({children}: {children:React.ReactNode}) => {
  const theme = useTheme<Theme>();
  return (
    <TagProvider tagConfig={theme}>
      {children}
    </TagProvider>
  )
}
import { AppTagProvider } from './App.theme';

export default function App() {

  return (
    <AppTagProvider>
      <Component></Component>
    </AppTagProvider>
  )
}

step2. Use

import React from "react";
import { useTheme } from '@team-devmonster/react-native-theme';
import { Theme } from './App.theme';
import { Div, Button, Img, P, Span, Br } from "@team-devmonster/react-native-tags";

const TagsEx = () => {

  // useTheme is in react-theme. If you wanna use darkmode easily, use it.
  const { color, fontSize } = useTheme<Theme>();

  return (
    <ScrollView
      style={{
        backgroundColor: color.white, 
        flex: 1, 
        padding: 18 
      }}>
      <Div style={{ fontSize: fontSize.xl }}>
        {`1. div => <Div></Div>`}
      </Div>
      <Div>
        <Button color={color.primary} onClick={() => Alert.alert('pressed')}>
          {`2. button => <Button></Button>`}
        </Button>
      </Div>
      <Div>
        <Img 
          style={{
            width: '100%',
            aspectRatio: 1.774,
            backgroundColor: color.step500
          }} 
          src={require('assets/images/back.png')}></Img>
      </Div>
      <P style={{  
        marginBottom: 24, 
        height: 80
        }}>
        hello P
        <Span style={{ color: color.danger }}>hello Span</Span>
        <Button 
          color={color.primary} 
          style={{ display: 'inline-flex', height: 40 }}>inline button</Button>
        hello~!
      </P>
      <P style={{ marginBottom: 20, color: color.primary }}>
        hello?
        <Button color={color.step500}>not inline button. normal button.</Button>
      </P>
      <P>
        text with {`<Br/>`}<Br></Br>hello
      </P>
      <Button 
        color={color.primary}
        fill="outline"
        style={{ 
          alignSelf: 'stretch', 
          alignItems: 'center',
          fontSize: fontSize.sm,
          ...shadow.base,
          marginBottom: 18
        }}>
          hellohellohello omg~
          <Img 
          style={{
            width: 20,
            aspectRatio: 1.774, 
            backgroundColor: color.step500
          }} 
          src="https://devmonster.co.kr/static/media/main-bg-05.d88f30e7.png"></Img>
      </Button>

      <Button color={color.primary} fill="outline" style={{ marginBottom: 8 }}>
        outline
      </Button>

      <Button color={color.primary} fill="translucent" style={{ marginBottom: 8 }}>
        translucent
      </Button>

      <Button color={color.primary} fill="outline" style={{ marginBottom: 10 }} disabled={true}>
        disabled
      </Button>

      <Button 
        color={color.primary} 
        fill="outline" 
        style={{ 
          marginBottom: 10,
          borderRadius: 10,
          borderTopLeftRadius: 0,
          borderTopRightRadius: 0
        }}>
        disabled
      </Button>

      <Button 
        color={color.step100}
        style={{
          width: 100,
          height: 100,
          borderRadius: 50,
          borderStyle: 'dashed',
          borderColor: color.primary,
          borderWidth: 1
        }}>
      </Button>

      <P>gap Test</P>
      <Div style={{ borderColor: 'orange', borderWidth: 1, flexDirection: 'row', gap: 8, borderRadius: 20, flexWrap: 'wrap', marginBottom: 10, ...shadow.base, overflow: 'hidden' }}>
        <Div style={{ backgroundColor: 'lightgray', flex: 2, minWidth: 100, height: 50 }}>1</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>2</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 3, minWidth: 100, height: 50 }}>3</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>4</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>5</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>6</Div>
      </Div>

      <P>not gap Test</P>
      <Div style={{ borderColor: 'orange', borderWidth: 1, flexDirection: 'row', borderRadius: 20, flexWrap: 'wrap', ...shadow.base, padding: 5 }}>
        <Div style={{ backgroundColor: 'lightgray', flex: 2, minWidth: 100, height: 50 }}>1</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>2</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 3, minWidth: 100, height: 50 }}>3</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>4</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>5</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>6</Div>
      </Div>

      <P>button gap Test</P>
      <Button color={color.primary} fill="none" style={{ 
        borderColor: 'red', 
        borderWidth: 2, 
        flexDirection: 'row', 
        gap: 10, 
        ...shadow.base, 
        borderRadius: 20, 
        flexWrap: 'wrap', 
        padding: 2,
        marginBottom: 20}}>
        <Div style={{ backgroundColor: 'lightgray', flex: 2, minWidth: 100, height: 50 }}>1</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>2</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 3, minWidth: 100, height: 50 }}>3</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>4</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>5</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>6</Div>
      </Button>

      <P>button not gap Test</P>
      <Button color={color.primary} fill="none" style={{ borderColor: 'green', borderWidth: 1, flexDirection: 'row', borderRadius: 20, flexWrap: 'wrap', padding: 5}}>
        <Div style={{ backgroundColor: 'lightgray', flex: 2, minWidth: 100, height: 50 }}>1</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>2</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 3, minWidth: 100, height: 50 }}>3</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>4</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>5</Div>
        <Div style={{ backgroundColor: 'lightgray', flex: 1, minWidth: 100, height: 50 }}>6</Div>
      </Button>
    </ScrollView>
  )
}

export default TagsEx;
1.11.10

8 months ago

1.11.7

9 months ago

1.11.6

10 months ago

1.11.9

8 months ago

1.12.3

7 months ago

1.12.2

8 months ago

1.12.1

8 months ago

1.12.0

8 months ago

1.12.6

7 months ago

1.12.5

7 months ago

1.12.4

7 months ago

1.11.5

1 year ago

1.11.4

1 year ago

1.10.40

1 year ago

1.10.41

1 year ago

1.10.48

1 year ago

1.10.49

1 year ago

1.10.46

1 year ago

1.10.47

1 year ago

1.10.44

1 year ago

1.10.45

1 year ago

1.10.42

1 year ago

1.10.43

1 year ago

1.10.37

1 year ago

1.10.38

1 year ago

1.10.36

1 year ago

1.10.39

1 year ago

1.11.3

1 year ago

1.11.2

1 year ago

1.11.1

1 year ago

1.10.51

1 year ago

1.10.52

1 year ago

1.10.50

1 year ago

1.10.57

1 year ago

1.10.58

1 year ago

1.10.55

1 year ago

1.10.56

1 year ago

1.10.53

1 year ago

1.10.54

1 year ago

1.11.0

1 year ago

1.10.30

1 year ago

1.10.35

1 year ago

1.10.33

1 year ago

1.10.34

1 year ago

1.10.31

1 year ago

1.10.32

1 year ago

1.10.26

1 year ago

1.10.27

1 year ago

1.10.24

1 year ago

1.10.25

1 year ago

1.10.28

1 year ago

1.10.29

1 year ago

1.10.5

1 year ago

1.10.4

1 year ago

1.10.3

1 year ago

1.10.2

1 year ago

1.10.9

1 year ago

1.10.8

1 year ago

1.10.7

1 year ago

1.10.6

1 year ago

1.9.26

1 year ago

1.9.25

1 year ago

1.9.24

1 year ago

1.9.23

1 year ago

1.9.22

1 year ago

1.10.1

1 year ago

1.10.0

1 year ago

1.10.22

1 year ago

1.10.23

1 year ago

1.10.20

1 year ago

1.10.21

1 year ago

1.10.15

1 year ago

1.10.16

1 year ago

1.10.13

1 year ago

1.10.14

1 year ago

1.10.11

1 year ago

1.10.12

1 year ago

1.10.10

1 year ago

1.10.19

1 year ago

1.10.17

1 year ago

1.10.18

1 year ago

1.9.21

1 year ago

1.9.20

1 year ago

1.9.19

1 year ago

1.9.18

1 year ago

1.9.17

1 year ago

1.9.16

1 year ago

1.9.15

1 year ago

1.9.14

1 year ago

1.9.13

1 year ago

1.9.12

1 year ago

1.9.11

1 year ago

1.9.10

1 year ago

1.9.9

1 year ago

1.9.8

1 year ago

1.9.7

1 year ago

1.9.6

1 year ago

1.9.5

1 year ago

1.9.4

1 year ago

1.9.3

1 year ago

1.9.2

1 year ago

1.9.1

1 year ago

1.9.0

1 year ago

1.8.9

1 year ago

1.8.8

1 year ago

1.8.7

1 year ago

1.8.6

1 year ago

1.8.5

1 year ago

1.8.4

1 year ago

1.8.3

1 year ago

1.8.2

1 year ago

1.8.1

1 year ago

1.8.0

1 year ago

1.7.9

1 year ago

1.7.8

1 year ago

1.7.7

1 year ago

1.7.6

1 year ago

1.7.5

1 year ago

1.7.4

1 year ago

1.7.3

1 year ago

1.7.2

1 year ago

1.7.1

1 year ago

1.7.0

1 year ago

1.6.9

1 year ago

1.6.8

1 year ago

1.6.7

1 year ago

1.6.6

1 year ago

1.6.5

1 year ago

1.6.4

1 year ago

1.6.3

1 year ago

1.6.2

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.9

1 year ago

1.5.8

1 year ago

1.5.7

1 year ago

1.5.6

1 year ago

1.5.5

1 year ago

1.5.4

1 year ago

1.5.3

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.9

1 year ago

1.4.8

1 year ago

1.4.7

1 year ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.9

1 year ago

1.3.8

1 year ago

1.3.7

1 year ago

1.3.6

1 year ago

1.3.5

1 year ago

1.3.4

1 year ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.18

2 years ago

1.2.17

2 years ago

1.2.16

2 years ago

1.2.15

2 years ago

1.2.14

2 years ago

1.2.13

2 years ago

1.2.12

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago