1.0.8 • Published 3 years ago

base-designed-components v1.0.8

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

base-designed-components

Some beautiful components that I decided to code

NPM JavaScript Style Guide

Install

npm install --save base-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 'base-designed-components'
import 'base-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
Theme Prop

Default:

{
    light: {
      text: 'black',
      textLight: '#9b9a9f',
      primary: 'rgba(0, 84, 240)',
      secondary: '',
      third: ''
    },
    dark: {
      text: 'white',
      textLight: '#9b9a9f',
      primary: 'rgba(0, 84, 240)',
      secondary: '',
      third: ''
    },
    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.

License

MIT © HenriqueRamos13

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.5

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