0.1.27 • Published 3 years ago

@gerrico/react-components v0.1.27

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

React Components

This library provides a list of useful components for React projects

Install

To install the library, run this command:

npm install @gerrico/react-components

Index

BubbleLoader

A loader with twelve bubbles that increase and decrease their size.

Alt Text

Props

NameDescriptionTypeRequiredDefault
left?Set the distance from the left marginstringNo
top?Set the distance from the top marginstringNo
bubbleSize?Set the size of the bubbles (the size of the component doesn't change)numberNo1
color?The color of the bubblesstringNo#DDD
className?Provide other stylestringNoundefined

Example

import React from "react";
import { BubbleLoader } from "./components";

const App = () => {
  return (
    <div>
      <BubbleLoader left="50vw" top="50vh" color="#20E080" />
    </div>
  );
};

export default App;

BounceLoader

A loader with three bouncing balls.

Alt Text

Props

NameDescriptionTypeRequiredDefault
left?Set the distance from the left marginstringNo
top?Set the distance from the top marginstringNo
size?A multiplying factor for balls sizenumberNo1
color?The color of the ballsstringNo#DDD
className?Provide other stylestringNoundefined

Example

import React from "react";
import { BounceLoader } from "./components";

const App = () => {
  return (
    <div>
      <BounceLoader left="50vw" top="50vh" color="#2080E0" size={0.8}/>
    </div>
  );
};

export default App;

RadarLoader

A loader that simulates a radar signal

Alt Text

Props

NameDescriptionTypeRequiredDefault
left?Set the distance from the left marginstringNo
top?Set the distance from the top marginstringNo
size?A multiplying factor for radar sizenumberNo1
color?The color of the radarstringNo#be97e8
fill?Only border (if false) or entire circle (if true)booleanNofalse
className?Provide other stylestringNoundefined

Example

import React from "react";
import { RadarLoader } from "./components";

const App = () => {
  return (
    <div>
      <RadarLoader left="50vw" top="62vh" size={1} fill={false} />
    </div>
  );
};

export default App;

Selector

A button to toggle between states.

Alt Text

Props

NameDescriptionTypeRequiredDefault
idUnique id for the componentstringYes
statusThe status of the selector (false -> left, true -> right)booleanYes
onClickAction to performfunctionYes
colorOff?The color of the selector while is offstringNo#444
colorOff?The color of the selector while is onstringNo#444
textColor?The color of the text inside the selectorstringNo#FFF
disabled?If true, the selector is disabledbooleanNofalse
className?Provide other stylestringNoundefined

Example

import React, { useState } from "react";
import { Selector } from "@gerrico/react-components";

const App = () => {
  const [status, setStatus] = useState(false);

  return (
    <div>
      <Selector
        id="selector"
        status={status}
        onClick={() => {
          setStatus(!status);
        }}
        items={["OFF", "ON"]}
        colorOff="#2080B0"
        colorOn="#20B080"
      />
    </div>
  );
}

export default App;

Checkbox

A simple and custom checkbox

Alt Text Alt Text

Props

NameDescriptionTypeRequiredDefault
onClickAction performed after clicking itfunctionYes
text?Custom text for the checkboxstringNo
disabled?If true, the component is disabledbooleanNofalse
className?Provide other stylestringNoundefined

Example

import React, { useState } from "react";
import { Checkbox } from "@gerrico/react-components";

const App = () => {
  const [status, setStatus] = useState(false);

  return (
    <div>
      <Checkbox
        status={status}
        onClick={() => {
          setStatus(!status);
        }}
        text="Checkbox"
      />
    </div>
  );
}

export default App;

Button

A simple button with background color selection and automatic text color.

Alt Text

Props

NameDescriptionTypeRequiredDefault
onClickAction performed after clicking itfunctionYes
colorBackground color for the button (text color is always black or white, based on the background colorstringNo#2090F0
disabled?If true, the button is disabledbooleanNofalse
className?Provide other stylestringNoundefined

ATTENTION: currently, the color prop must be in hex format (#RRGGBB). This is due to the calculation of the text color. In future, there will be the possibility to set the color by:

  • picking it from a list of standard colors (primary, info, warning, danger, etc.)
  • writing the exact color (red, blue, green, etc.)
  • by entering the color coding (rgb, hsl, etc.)

Example

import React from "react";
import { Button } from "./components";

const App = () => {
  return (
    <div>
      <Button onClick={() => alert("Pressed!")}>Press Me!</Button>
    </div>
  );
};

export default App;

Dropdown

A dropdown control for items selection.

Alt TextAlt Text

Props

NameDescriptionTypeRequiredDefault
itemsArray of items to show (props for items are described below)arrayYes
title?The string to show inside the control. If not set, the selected values is shownstringNoFirst item
selected?The index of the selected itemnumberNo0
onSelect?Action to perform after selecting an item. It returns the text and the index of the selected itemfunctionNo
disabled?If true, the dropdown is disabledbooleanNofalse
className?Provide other stylestringNoundefined

Each item of the array can have these props:

NameDescriptionTypeRequiredDefault
text?The text of the itemstringNo
checkbox?Set if the item is a normal string or a checkboxbooleanNofalse
status?The status of the checkbox (if checkbox is true)booleanNofalse
onSelect?Action to perform after selecting a checkbox itemfunctionNo
disabled?If true, the item is disabledbooleanNofalse
header?If true, the item has a different style and it cannot be selectedbooleanNofalse
divider?A line that divides the previous and the following item. Other props are ignoredbooleanNofalse

Example

import React from "react";
import { Dropdown } from "./components";

const App = () => {
  const [dropdownSelected, setDropdownSelected] = useState(0);

  const onChangeDropdownValue = (value, index) => {
    // `values` is the text of the item
    // `index` is the index of the item
    setDropdownSelected(index);
  };

  return (
    <div>
      <Dropdown
          items={[
            {
              text: "London",
            },
            {
              text: "Berlin",
            },
            {
              text: "Paris",
            },
            {
              text: "New York",
            },
            {
              text: "Rome",
            }
          ]}
          onSelect={onChangeDropdownValue}
          selected={dropdownSelected}
        />
    </div>
  );
};

export default App;
0.1.27

3 years ago

0.1.26

3 years ago

0.1.25

3 years ago

0.1.24

3 years ago

0.1.23

3 years ago

0.1.22

3 years ago

0.1.21

3 years ago

0.1.20

3 years ago

0.1.19

3 years ago

0.1.18

3 years ago

0.1.17

3 years ago

0.1.16

3 years ago

0.1.15

3 years ago

0.1.14

3 years ago

0.1.12

3 years ago

1.0.0

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago