1.1.13 • Published 12 months ago

smpladminui v1.1.13

Weekly downloads
28
License
MIT
Repository
github
Last release
12 months ago

smpladminui

SimpleAdmin UI - React Components Library

This is a set of simple UI components that can help you build simple Admin interface with a basic functionality.

NPM JavaScript Style Guide

Install

npm install --save-dev smpladminui

Usage

import React, { Component } from "react";

import { ButtonComponent as Button } from "smpladminui";

class Example extends Component {
  render() {
    return <Button />;
  }
}

You can import all the components into your application using the following lines:

import React, { Component } from "react";

import {
  ButtonComponent as Button,
  LayoutComponent as Layout,
  PageComponent as Page,
  DropmenuComponent as Dropmenu,
  CardComponent as Card,
  ListComponent as List,
  PopupComponent as Popup,
  IconComponent as Icon,
  WrapperComponent as Wrapper
} from "smpladminui";

class Example extends Component {
  render() {
    return <Button />;
  }
}

Below you can see a list of all the components along with their props.

Button

This component is a simple styled button which can render in few different styles depending on the props and handling onClick event upon itself.

Button Component

Usage

import React, { Component } from "react";

import { ButtonComponent as Button } from "smpladminui";

class Example extends Component {
  render() {
    return <Button label={"No Action"} danger />;
  }
}

Props

Prop nameTypeDefaultDescription
styleobject{}Style object to be passed to the rendered button
labelstring"Button"This is the label on the button. Note: in case there are children passed to this component, they will be rendered instead.
disabledboolean,function or stringnoneRenders the button as disabled
primaryboolean, anyfalseRenders the button as primary
dangerboolean, anyfalseRenders the button as danger
processingboolean, anyfalseRenders the button as processing (with a spinning icon)
onClickfunctionnoneHandler for the onClick event of the button

Toggle

This component is a simple styled toggle which can render a toggle knob in few different styles depending on the props and handling onToggle event upon itself.

Toggle Component

Usage

import React, { Component } from "react";

import { ToggleComponent as Toggle } from "smpladminui";

class Example extends Component {
  render() {
    return <Toggle label={"No Action"} danger value={this.state.toggleValue} onToggle={(value) => this.setState({toggleValue})}/>;
  }
}

Props

Prop nameTypeDefaultDescription
styleobject{}Style object to be passed to the rendered button
labelstringEmptyThis is the label on the toggle. Note: in case there are children passed to this component, they will be rendered instead.
disabledboolean,function or stringnoneRenders the button as disabled
primaryboolean, anyfalseRenders the button as primary
dangerboolean, anyfalseRenders the button as danger
processingboolean, anyfalseRenders the button as processing (with a spinning icon)
onTogglefunctionnoneHandler for the onToggle event of the component. Returns the value of the toggle (true/false)

Card

This component is a simple styled card with header, body and footer. It can be rendered in different variations depending on the props passed to it.

Card Component

Usage

import React, { Component } from "react";

import { CardComponent as Card } from "smpladminui";

class Example extends Component {
  render() {
    return (
      <Card>
        <h1>UX Science progress experiment.</h1>
      </Card>
    );
  }
}

Props

Prop nameTypeDefaultDescription
styleobject{}The style object that will be passed to the rendered card
typestring"children"Sets the style of the card. Options are: children - renders the children inside the bodyfile - renders file type icon inside the bodyimage - renders an image inside the body
fileTypestring"video_mp4"The filetype that will be used in case the type is set to file. All the options are: application_pdfapplication_mswordapplication_zipapplication_x_rarapplication_vnd_ms_excelaudio_mpegapplication_vnd_ms_powerpointtext_plainvideo_mp4Note: This list will grow with time
imageUrlstring""The URL of the image which should be rendered in case the type is set to image
disabledboolean,function or stringnoneRenders the button as disabled
primaryboolean, anyfalseRenders the button as primary
dangerboolean, anyfalseRenders the button as danger
processingboolean, anyfalseRenders the button as processing (with a spinning icon)
headerboolean, string, object<React.Fragment>Sample Card Header</React.Fragment>The contents of the header element of the card
footerboolean, string, object*several buttons and a textThe contents of the footer element of the card

Dropmenu

This component is a three dots icon which shows a list of options upon hover.

Dropmenu Component

Usage

import React, { Component } from "react";

import { DropmenuComponent as Dropmenu } from "smpladminui";

class Example extends Component {
  render() {
    return <Dropmenu style={{ float: "right" }} />;
  }
}

Props

Prop nameTypeDefaultDescription
styleobject{}The style object that will be passed to the rendered element
disabledboolean,function or stringnoneRenders the button as disabled
primaryboolean, anyfalseRenders the button as primary
dangerboolean, anyfalseRenders the button as danger
processingboolean, anyfalseRenders the button as processing (with a spinning icon)
optionsarray of objects[{option1},{option2}]A list of options for the menu. Each object must have the following properties: icon - the Icon component for the optionlabel - the text for the optiononClick - event handler for the click event of that option

Icon

This component is a three dots icon which shows a list of options upon hover.

Icon Component

Usage

import React, { Component } from "react";

import { IconComponent as Icon } from "smpladminui";

class Example extends Component {
  render() {
    return <Icon type={"listtype_list"} variant={"grey"} />;
  }
}

Props

Prop nameTypeDefaultDescription
styleobject{}The style object that will be passed to the rendered element
disabledboolean,function or stringnoneRenders the icon as disabled
primaryboolean, anyfalseRenders the icon as primary(not yet implemented)
dangerboolean, anyfalseRenders the button as danger (not yet implemented)
processingboolean, anyfalseRenders the button as processing (with a spinning icon) (not yet implemented)
typestring"settings"Sets the type of the icon. Options are: bookmark_offbookmark_oncollectionsdashboardeditfileslisttype_cardslisttype_listlogoutprojectsettingssettingsstaticstructurethreedots
variantstring"grey"Sets the color of the icon. Options are: greywhite
onClickfunctionnoneHandler for the onClick event of the icon

Layout

This component is layout component useful for building the main interface of the admin system. It has sidebar with options, header with labels and footer.

Layout Component

Usage

import React, { Component } from "react";

import { LayoutComponent as Layout } from "smpladminui";

class Example extends Component {
  render() {
    return (
      <Layout progress={0}>
        <Page>
          <Wrapper>
            This is my page
            <h1>Title 1 / H1</h1>
            <h2>Title 2 / H2</h2>
            <h3>Title 3 / H3</h3>
            <h4>Title 4 / H4</h4>
            <h5>Title 5 / H5</h5>
            <h6>Title 6 / H6</h6>
          </Wrapper>
        </Page>
      </Layout>
    );
  }
}

Props

Prop nameTypeDefaultDescription
leftLabelstring"left Label"The smaller label on the top of the sidebar
leftSublabelstring"Left Sublabel"The bigger label on the top of the sidebar
centerLabelstring"Please login to the system first"The label on the header of the layout
centerSublabelstring"Total of 1,567,234 hits this month"The sublevel on the header of the layout
centerRightIconIcon component<Icon type={"logout"} variant={"grey"} />The Icon on the top right corner of the header
centerRightTextstring"Martin D."The text displayed next to the top right icon on the header
progressnumbernullSets the percentage of the progress bar in the header. Values could be 0 - 100. Note: If this is set to null the progress bar will not be displayed
sidebarElementsarray of objectssome default optionsAn array of objects each of them with the following properties: type (string) - could be either "item" or "section" and will determine whether it's a section title or an itemlabel (string) - the label of the menudescription (string) - the sublabel/description of the menuicon (Icon component) - the icon for the menuselected (boolean) - shows whether the menu should be rendered as selected

Note: Everything that is placed as children inside this component will be rendered inside the body of the layout.


List

This component is a list having header, list of elements and footer. It is useful to represent data in a list format.

List Component

Usage

import React, { Component } from "react";

import { ListComponent as List } from "smpladminui";

class Example extends Component {
  render() {
    return <List />;
  }
}

Props

Prop nameTypeDefaultDescription
styleobject{}The style object that will be passed to the rendered element
headerarray of strings"Name", "Structure", "Updated on", "Actions"Sets the header elements (column names) of the list
footerobjectReact.Fragment with several buttons insideSets the footer of the list. Could be any element you decide.
listarray of arrays "UX Science progress experiment with a very very long name that goes on one line for a long line", "Root / All Static Pages", "15 Dec 12:45", <React.Fragment><Button danger style={{ float: "right" }}>delete<Button style={{ float: "right" }}>edit<Icon type={"bookmark_on"} variant={"grey"} style={{ float: "right" }} /></React.Fragment>Each element of this array should be an array with the same number of elements like the header elements. Each element will be placed in the proper column.

Page

This component is a simple wrapper representing a page in our layout. It has a label and content (children).

Page Component

Usage

import React, { Component } from "react";

import { PageComponent as Page } from "smpladminui";

class Example extends Component {
  render() {
    return <Page label={"Page label"}>This is my page</Page>;
  }
}

Props

Prop nameTypeDefaultDescription
styleobject{}The style object that will be passed to the rendered element
labelstring"Page Label"The label of the page displayed at the top
stickyHeaderbooleanfalseWhether the label should stay sticky to the top when scrolling

Popup

This component is a popup element with header (with close button), hint line, body and footer. Often used when there is a need to enter data or display a message to the user.

Popup Component

Usage

import React, { Component } from "react";

import { PopupComponent as Popup } from "smpladminui";

class Example extends Component {
  render() {
    return (
      <Popup
        visible={this.state.popupVisible}
        onClose={this.togglePopupVisible}
        footer={
          <React.Fragment>
            <div style={{ width: "100%", textAlign: "left" }}>
              <Button style={{ float: "right" }} danger>
                delete
              </Button>
              <Button
                style={{ float: "right" }}
                onClick={this.togglePopupVisible}
              >
                close
              </Button>
              Updated on
              <br />
              15 Dec 2017
            </div>
          </React.Fragment>
        }
        hint={"This is the hint of the popup"}
      >
        Body of the popup
      </Popup>
    );
  }
}

Props

Prop nameTypeDefaultDescription
styleobject{}The style object that will be passed to the rendered element
labelstring"Popup Label"The label of the popup displayed at the top. Note: You can use any element here like placing an icon before the label.
hintstringnullAny text that you want to be displayed as a hint on top of the popup. If the value is null the hint will not be displayed
typestring"normal"Sets the style of the popup. Options are: normal - normal popupmessage - displays the body of the popup bigger in size. Useful in displaying messages
timenumber0If set (in seconds) will autoclose the popup in the set number of seconds
footerobjectReact.Fragment with two buttons and a textSets the footer element of the popup. If set to null it will not be displayed
onClosefunctionnoneEvent handler for the close function of the popup

Wrapper

This component is a simple wrapper component apllying some default styles to the elements inside it like labels, text boxes, titles, buttons etc.

Wrapper Component

Usage

import React, { Component } from "react";

import { WrapperComponent as Wrapper } from "smpladminui";

class Example extends Component {
  render() {
    return (
      <Wrapper>
        <label>
          This is label
          <input type="text" placeholder="Project name" />
        </label>
        This is inside a wrapper
        <br />
        Don't have an account? Register one <a href="register.html">here</a>
        .
        <hr size="1" noshade="noshade" />
        <h1>Title 1 / H1</h1>
        <h2>Title 2 / H2</h2>
        <h3>Title 3 / H3</h3>
        <h4>Title 4 / H4</h4>
        <h5>Title 5 / H5</h5>
        <h6>Title 6 / H6</h6>
        <button>My Button</button>
      </Wrapper>
    );
  }
}

Props

Prop nameTypeDefaultDescription
styleobject{}The style object that will be passed to the rendered element

Thoughts

This is work in progress and we will continue working on this simple collection of elements. If you want to participate in it, please do not hesitate to get involved.

License

MIT © marDonchev

1.1.8

12 months ago

1.1.7

12 months ago

1.1.6

12 months ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.12

12 months ago

1.1.11

12 months ago

1.1.10

12 months ago

1.1.13

12 months ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.40

1 year ago

1.0.26

2 years ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.25

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago