1.0.2 • Published 6 years ago

@breathecode/breathecode-react-components v1.0.2

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
6 years ago

BreatheCode Platform JS Components

This is the main UI Library used in all BreatheCode interfaces based on react.

Note: This is a very early development library, please help us debug it.

Philosophy

The BreatheCode UX is based on Markdown, it mainly relys on typography to create a neat experience but with a very minimalis approach.

Instalation

  1. Install using npm
$ npm i @breathecode/breathecode-react-components --save
  1. Import any component that you want to use
import { Panel, DropLink } from '@breathecode/breathecode-react-components';

Component Table of Contents:

ComponentDescription
ButtonSimple button
CheckboxIt's a very simple checkbot
DroplinkIt's a minimalist bootstrap dropdown
ListJust a list of stuff
LoadingLoading animation
MenuItemItem on the left sidebar
ModalShow stuff in the center of the screen
NotifierNotifications in the top of the viewport
PanelTo display a box with material design shadow level
PrivateRouteReact Route that requiers autentication to display
ProgressKPISmall indicator of progress
SidebarThe Main Navegation component in BreatheCode's UI
BreatheCrumbShow the path were the user is standing and allos the user to go back to previous levels

Actionable

A label that has a check on the right depending if its done or not.

Demoalt text

Properties

{
  label: PropTypes.string.isRequired,
  dropdown: PropTypes.array,
  isSelected: PropTypes.bool,
  onDropdownSelect: PropTypes.func.isRequired,
  type: PropTypes.oneOf(['lesson', 'replit', 'quiz', 'assignment']),
}
    <ActionableItem key={i} type={l.type} 
        done={(l.status === "done")} 
        label={(typeof l.title !== 'undefined') ? l.title : l.associated_slug} 
        dropdown={l.menu} 
        onDropdownSelect={(option)=>this.actionableSelected(l,option)} 
      />;

Checkbox

Demoalt text

Droplink

It displays a list of options when you click on it

Demoalt text

=======

Usage

        <DropLink
            className='list_card' 
            dropdown={[
                { label: 'review students', slug: 'cohort_students', to: `/manage/student/?cohort=${data.slug}`},
                { label: 'change cohort stage', slug: 'change_stage', data: someData }
            ])}
            onSelect={(opt) => onEntitySelect(opt)}
        >
        Click me
        </DropLink>

List

It displays a ul with LIs or OLs depending on if it is ordered or not.

Demoalt text
    <List className="any-class" ordered={true}>
        <ActionableItem key={i} label="Make the bed" done={false} />
        <ActionableItem key={i} label="Make the bed" done={false} />
        <ActionableItem key={i} label="Make the bed" done={false} />
        <ActionableItem key={i} label="Make the bed" done={false} />
    </List>

Loading

Show or hides a loadbar on the center of the screen

Demoalt text
    <Loading show={true} />

Modal

Demoalt text

Notifier

Displays a notification message on the top of the screen, you can specify if you want your notification to prompt the user for confirmation or not.

Demoalt text
    let notifications = [{
        id: 1, //unique identifier
        msg: 'Are you sure you want to delete?', //message to display
        type: 'info', //info, error, success or warning
        onConfirm: confirm //this callback will be called on user confirmation 
    }];
    <Notifier notifications={notifications} />

PrivateRoute

It behaves like a normal react-router Route but with the addition that it redirects the user to /login if it loggedIn = false

    <BrowserRouter>
            <Switch>
                <Route exact path='/login' component={LoginView} />
                <PrivateRoute exact path='/' loggedIn={this.state.loggedIn} component={AnyPrivateView} />
                <Route render={() => (<p className="text-center mt-5">Not found</p>)} />
            </Switch>
        </div>
    </BrowserRouter>

ProgressKPI

Displays the percentage of progress from 0 to 100%

Demoalt text
    <ProgressKPI progress={76} />

Sidebar

Demoalt text

BreatheCrumb

Demoalt text