1.3.2 • Published 3 years ago

react-ui-designed-components v1.3.2

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

react-ui-designed-components

Some beautiful components that I decided to code

NPM JavaScript Style Guide

Install

npm install --save react-ui-designed-components

Usage

SideBarTemplate

A component to serve as a template for simple systems. The idea is to have a sidebar and a fixed header around the content. Pure component:

pure component image

The area where the content will stay (in grey):

pure component image

Component with content usage example:

pure component image

import React from 'react'
import { SideBarTemplate } from 'react-ui-designed-components'
import 'react-ui-designed-components/dist/index.css'
const notifyW = require('./icons/notify-w.png')

const fakeMenus = new Array(6).fill({
  key: Math.random(100),
  label: 'Label',
  path: '/path',
  icon: notifyW
})

const App = () => {
  return (
    <SideBarTemplate
      menus={fakeMenus}
      userName={'Ulf Anderson'}
      theme={{ userInfoColor: 'red', theme: 'dark' }}
      maxWidth
    >
      <div
        style={{
          display: 'flex',
          flexWrap: 'wrap',
          width: '100%',
          justifyContent: 'space-around',
          height: '100%'
        }}
      >
        {new Array(20).fill(0).map((_, i) => (
          <div
            key={i}
            style={{
              marginTop: 16,
              width: '22%',
              height: 200,
              background: 'lightgreen'
            }}
          ></div>
        ))}
      </div>
    </SideBarTemplate>
  )
}

Props

PropTypeDefaultNote
themeobjectBase theme for component design. Colors and theme type. See the next section to better understand this property
menusarray[]Array of json indicating which menus should be built in the sidebar
maxWidthboolfalseDefines if the layout will grow with the user's screen or if it will have a maximum limit.
onClickOptionfuncFunction called when a click on the sidebar button happens. It is only called when the navigator property is null
navigatorfunc, anyMain function/object of libraries like react-navigation. Pass the navigator and the navigator.push(path) function will automatically run when a sidebar button is clicked
userNamestringnullText on the left side of the user photo
customSidebarHeaderfunc, elementCustom header for the sidebar
customSidebarFooterfunc, elementCustom footer for the sidebar
customFooterfunc, elementCustom footer for the template
profileIconfunc, element, stringUrl/Component for User Photo
mobileLogofunc, elementComponent for logo icon in mobile version
Theme Prop

Default:

{
    light: {
      text: 'black',
      textLight: '#9b9a9f',
      primary: 'rgba(0, 84, 240)',
      secondary: '',
      third: '',
      layer1: 'rgba(255,255,255)', //Layer is the default color for items above the background. The InfoCard component's default background color is layer1 to give a feeling of depth
      layer2: '',
      layer3: ''
    },
    dark: {
      text: 'white',
      textLight: '#9b9a9f',
      primary: 'rgba(0, 84, 240)',
      secondary: '',
      third: '',
      layer1: 'rgba(40,39,63)',
      layer2: '',
      layer3: ''
    },
    theme: 'dark',
    darkColor: 'linear-gradient(#1e1e2f,#1e1e24)',
    lightColor: '#f5f6fa',
    userLogoBackground: '#fcc2c8',
    userInfoColor: '#bea5ce'
}

The component colors that are used are in that object. If you want to change from light to dark theme, just change the value of the theme key to dark and vice versa. It can be done for example: <SideBarTemplate {...props} theme={{ userInfoColor: 'red', theme: 'dark' }}> In this case we are changing the color value of the username that is next to the profile picture, and changing the theme to dark.

Menus Prop

The menus property must be an array of objects with this format:

{
  key: Math.random(100),
  label: 'Label',
  path: '/path',
  icon: notifyW
}
  • Key: If not passed, the element's index will be used as key.
  • Label: The text that the user will read in the sidebar.
  • Path: Which url should this menu send to.
  • Icon: It can be a string for the icon path, or a custom component/element.

InfoCard

A component to show simple infos with a beautiful style:

pure component image

Light version:

pure component image

import React from 'react'
import { InfoCard } from 'react-ui-designed-components'
import 'react-ui-designed-components/dist/index.css'
const icon = require('./icons/icon.png')

const theme = { theme: 'dark' }

const App = () => {
  return (
    <div
      style={{
        display: 'flex',
        flexWrap: 'wrap',
        width: '100%',
        justifyContent: 'space-around',
        height: '100%'
      }}
    >
        {new Array(4).fill(0).map((_, i) => (
          <InfoCard
            title='Valor'
            value='7000'
            subTitle='Just a subtitle'
            theme={theme}
            color={'linear-gradient(to bottom left, #FFE53B, #FF2525)'}
            headerIcon={
              <img
                src={icon}
                style={{ width: 24, height: 24 }}
                alt='icon'
              />
            }
          />
        ))}
        {new Array(4).fill(0).map((_, i) => (
          <InfoCard
            title='Valor'
            value='7000'
            subTitle='Just a subtitle'
            theme={theme}
            color={'linear-gradient(to bottom left, #FFE53B, #FF2525)'}
            withoutFooter
            headerIcon={
              <img
                src={icon}
                style={{ width: 24, height: 24 }}
                alt='icon'
              />
            }
          />
        ))}
    </div>
  )
}

Props

PropTypeDefaultNote
colorstringA string containing the color of the circle around the icon in the header
titlestringThe smallest text in the header
subTitlestringText that stays in the footer
valuestringThe largest text in the header
withoutFooterboolfalseBoolean value that defines whether the card will have footer or not
footerIconfunc, elementComponent that defines the footer icon
headerIconfunc, elementComponent that defines the header icon

ChartCards

A component to show simple charts with a beautiful style:

pure component image

import React from 'react'
import {
  SideBarTemplate,
  InfoCard,
  ChartCard
} from 'react-ui-designed-components'
import 'react-ui-designed-components/dist/index.css'
const icon = require('./icons/icon.png')

const { DoughnutChart, BarChart, LineChart, PieChart } = ChartCard

const theme = { theme: 'dark' }

const App = () => {
  const dataDoughnut = (canvas) => {
    return {
      labels: ['Feijao', 'Arroz', 'Carne', 'Vinho', 'Ovo', 'Leite'],
      datasets: [
        {
          // label: 'Dataset 1',
          data: [19, 20, 44, 33, 12],
          backgroundColor: [
            'rgba(255, 99, 132, 0.6)',
            'rgba(54, 162, 235, 0.6)',
            'rgba(255, 206, 86, 0.6)',
            'rgba(75, 192, 192, 0.6)',
            'rgba(153, 102, 255, 0.6)',
            'rgba(255, 159, 64, 0.6)'
          ],
          borderColor: [
            'rgba(255, 99, 132, 1)',
            'rgba(54, 162, 235, 1)',
            'rgba(255, 206, 86, 1)',
            'rgba(75, 192, 192, 1)',
            'rgba(153, 102, 255, 1)',
            'rgba(255, 159, 64, 1)'
          ],
          borderWidth: 0.5
        }
      ]
    }
  }

  const dataLine = (canvas) => {
    const ctx = canvas.getContext('2d')
    const gradient = ctx.createLinearGradient(0, 300, 0, 0)
    gradient.addColorStop(0, '#ff638400')
    gradient.addColorStop(0.1, '#ff638400')
    gradient.addColorStop(0.2, '#ff638400')
    gradient.addColorStop(0.3, '#ff638400')
    gradient.addColorStop(0.4, '#ff638420')
    gradient.addColorStop(0.5, '#ff638430')
    gradient.addColorStop(0.6, '#ff638440')
    gradient.addColorStop(0.7, '#ff638450')
    gradient.addColorStop(0.8, '#ff638450')
    gradient.addColorStop(0.9, '#ff638450')
    gradient.addColorStop(1, '#ff638450')

    return {
      labels: ['Feijao', 'Arroz', 'Carne', 'Vinho', 'Ovo'],
      datasets: [
        {
          // label: 'Dataset 1',
          data: [19, 20, 44, 33, 12],
          backgroundColor: gradient,
          borderColor: [
            'rgba(255, 99, 132, 1)',
            'rgba(54, 162, 235, 1)',
            'rgba(255, 206, 86, 1)',
            'rgba(75, 192, 192, 1)',
            'rgba(153, 102, 255, 1)',
            'rgba(255, 159, 64, 1)'
          ],
          fill: true,
          tension: 0.4,
          borderWidth: 0.5
        }
      ]
    }
  }

  const dataBar = dataDoughnut

  return (
    <SideBarTemplate userName={'Ulf Anderson'} theme={theme} maxWidth>
      <div
        style={{
          display: 'flex',
          flexWrap: 'wrap',
          width: '100%',
          justifyContent: 'space-around',
          height: '100%'
        }}
      >
        <DoughnutChart
          title='Vendas por item'
          value='7000'
          data={dataDoughnut}
          width='30%'
          theme={theme}
          valueIcon={icon}
        />
        <BarChart
          title='Vendas por item'
          value='7000'
          data={dataBar}
          width='30%'
          theme={theme}
          valueIcon={icon}
        />
        <PieChart
          title='Vendas por item'
          value='7000'
          data={dataBar}
          width='30%'
          theme={theme}
          valueIcon={icon}
        />
        <BarChart
          title='Vendas por item'
          value='7000'
          data={dataBar}
          width='47%'
          horizontal
          height={250}
          theme={theme}
          valueIcon={icon}
        />
        <LineChart
          title='Vendas por item'
          value='7000'
          data={dataLine}
          width='47%'
          height={250}
          theme={theme}
          valueIcon={icon}
        />
      </div>
    </SideBarTemplate>
  )
}

Props

PropTypeDefaultNote
positionLabelsstringPosition for labels one of "bottom, top, left, right, chartArea"
heightstringGraph height. This prop change Card height too
titlestringFirst text in card header
valuestringSecond text in card header
widthstringfalseCard width
styleobjectStyle for a first parent element
chartOptionsobjectOptions for chartjs
horizontalboolfalseFor bar chart be horizontal
labelsarrayArray of labels
dataobjectData of chart. Read Chartjs-2 documentation
valueIconfunc, elementIcon in left of value text

License

MIT © HenriqueRamos13

1.2.0

3 years ago

1.2.8

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.2.6

3 years ago

1.1.7

3 years ago

1.2.5

3 years ago

1.1.6

3 years ago

1.2.4

3 years ago

1.1.5

3 years ago

1.3.2

3 years ago

1.2.3

3 years ago

1.3.1

3 years ago

1.2.2

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.2.9

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago