1.0.5 • Published 3 years ago

stackby-ui-component v1.0.5

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

stackby-ui-component

Made with create-react-library

NPM JavaScript Style Guide

Features

  • configurable via props
  • Controllable state props and modular architecture
  • Flexible approach to data, with customisable functions
  • auto position
  • small bundle size

Installation and usage

npm install --save stackby-ui-component

Select Usage

import React from 'react';
import { Select } from 'stackby-ui-component';
import 'stackby-ui-component/dist/index.css'

const options = [
    { label: "chocolate", value: 'chocolate', id: 1, color: "#000000" },
    { label: "strawberry", value: 'strawberry', id: 2, color: "#FFEB3B" },
    { label: "vanilla", value: 'vanilla', id: 3, color: "#FD823E" },
    { label: "Banana", value: 'Banana', id: 4, color: "#8BC34A" },
    { label: "Mango", value: 'Mango', id: 5, color: "#FFEB3B" },
];

const collaboratorOptions = [
    { label: "chocolate", value: 'chocolate', id: 1, image: "" },
    { label: "strawberry", value: 'strawberry', id: 2, image: "" },
    { label: "vanilla", value: 'vanilla', id: 3, image: "" },
    { label: "Banana", value: 'Banana', id: 4, image: "" },
    { label: "Mango", value: 'Mango', id: 5, image: "" },
];

class App extends React.Component {
  state = {
    selectedOption: [],
    // selectOption:  [{ label: "chocolate", value: 'chocolate', id: 1, color: "#000000" }]
    // selectCollaborator:  [{ label: "chocolate", value: 'chocolate', id: 1, image: "" }]
  };

  handleChange = selectedOption => {
    this.setState({ selectedOption });
    console.log(`Option selected:`, selectedOption);
  };

  render() {
    const { selectedOption } = this.state;

    return (
      <div>
         // select
        <Select
          value={selectOption}
          onChange={this.handleChange}
          option={options}
          type ='select'
          className= {'myClass'}
         />

         // Multi Select
        <Select
          value={selectOption}
          onChange={this.handleChange}
          option={options}
          type ='multiSelect'
         />

         // collaborator
        <Select
          value={selectCollaborator}
          onChange={this.handleChange}
          option={collaboratorOptions}
          type ='collaborator'
         />

         // Multi Collaborator
        <Select
          value={selectCollaborator}
          onChange={this.handleChange}
          option={collaboratorOptions}
          type ='multiCollaborator'
         />
      </div>
    );
  }
}

Props

Common props you may want to specify include:

  • onChange - subscribe to change events
  • option - specify the options the user can select from
  • value - control the current value
  • type - select, multiSelect, collaborator, multiCollaborator
  • className - add customer class

Rating Usage

import React from 'react';
import { Rating } from 'stackby-ui-component';
import 'stackby-ui-component/dist/index.css'

class App extends React.Component {
  state = {
    defaultValue: 2,
  };

  handleChange = ratingValue => {
    console.log(`Collaborator selected:`, ratingValue);
  };

  render() {
    const { defaultValue } = this.state;

    return (
      <div>
         <Rating value={defaultValue}
              stop={5} 
              onChange={this.handleChange} 
              className = {'myClassName'} >
         </Rating>
      </div>
    );
  }
}

Props

Common props you may want to specify include:

  • onChange - subscribe to change events
  • value - control the current value
  • className - add customer class

Checkbox Usage

import React from 'react';
import { Checkbox } from 'stackby-ui-component';
import 'stackby-ui-component/dist/index.css'

class App extends React.Component {
  state = {
    defaultValue: true,
  };

  handleChange = checkboxValue => {
    console.log(`checkbox selected:`, checkboxValue);
  };

  render() {
    const { defaultValue } = this.state;

    return (
      <div>
         <Checkbox checked={defaultValue} 
             onChange={this.handleChange} 
             className={'myClassName'}>
         </Checkbox>
      </div>
    );
  }
}

Props

Common props you may want to specify include:

  • onChange - subscribe to change events
  • checked - control the value is checked or not
  • className - add customer class

DatePicker Usage

import React from 'react';
import { DatePicker } from 'stackby-ui-component';
import 'stackby-ui-component/dist/index.css'

class App extends React.Component {
  state = {
    defaultValue: '25/10/2021',
  };

  handleChangeDatePicker = Value => {
    console.log(`DatePicker time stamp `, Value);
    console.log("DatePicker date object", new Date(data));
  };

  render() {
    const { defaultValue } = this.state;
    return (
      <div>
         <DatePicker value={defaultValue} 
              onChange={handleChangeDatePicker}
              className = {'myClassName'}>
         </DatePicker>
      </div>
    );
  }
}

Props

Common props you may want to specify include:

  • onChange - subscribe to change events
  • value - control the current value
  • className - add customer class

LongText Usage

import React from 'react';
import { LongText } from 'stackby-ui-component';
import 'stackby-ui-component/dist/index.css'

class App extends React.Component {
  state = {
    defaultValue: '',
  };

  handleChange = Value => {
    console.log(`LongText `, Value);
  };

  render() {
    const { defaultValue } = this.state;

    return (
      <div>
         <LongText value={defaultValue} isMarkDown={true} 
             onChange={this.handleChange} 
             textareaHeight={100}
             modalHeight={100}
             isModel={true}
             modalWidth={300}>
         </LongText>
      </div>
    );
  }
}

Props

Common props you may want to specify include:

  • onChange - subscribe to change events
  • value - control the current value
  • isMarkDown: boolean - enable markdown for true
  • isModel: boolean - open with model popup.

License

MIT © Stackbydev

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