Overview

Welcome to Kniferoll.

Kniferoll provides the following on install:

  • Flexbox grid system
  • Styled Component Library.
  • Flexible theming system.

Installation

> npm i -S kniferoll

Dependencies

Kniferoll requires your application adhere to using certain technologies which you're probably already using anyway:

Kniferoll uses the following libraries under the hood which you may want to look into as they are pretty darn neat themselves!

Example

TODO

For more detailed usage, please see the individual sections.

Grid System

The grid system should look familiar to you. It uses the Container > Row > columns structure as many grid systems do. It is based on the popular flexbox grid. It is currently only supporting responsiveness of the grid layout, but without push/pull, alignment, or distribution.

Out of the box, it resembles your standard, responsive 12 column grid system.

<Col xs={6} sm={3} />
<Col xs={6} sm={3} />
<Col xs={12} sm={6} />
<Col xs={12} sm={5} />
<Col xs={6} sm={4} />
<Col xs={6} sm={3} />

The biggest benefit of turning the grid elements into react components is run time configuration of the grid and for your layout.

5 Column Grid

17 Column Grid

Grid

src/grid/Grid.js

Grid container component. Setup the grid here for it's child components.

Prop nameTypeDefaultDescription
childrennode

Grid child components.

columnsnumber12

Number of columns for grid

paddingnumber15

Container padding.

gutternumber15

Column gutter size

fluidbooltrue

Fluid container or not

xsBreaknumber576

xs breakpoint for grid.

smBreaknumber768

sm breakpoint for grid.

mdBreaknumber992

md breakpoint for grid.

unitstringpx

Unit measurement for grid. Applied to padding, gutter, and breakpoints.

Row

src/grid/Row.js

Simple grid Row component.

Prop nameTypeDefaultDescription
childrennode

Row children

classNamestring
reverseboolfalse

Whether to reverse the column order or not

Col

src/grid/Col.js

Grid column component

Prop nameTypeDefaultDescription
childrennode

Col children

classNamestring
xsnumber

Col spread at xs

smnumber

Col spread at sm

mdnumber

Col spread at md

lgnumber

Col spread at lg

xsOffsetnumber

Col offset at xs

smOffsetnumber

Col offset at sm

mdOffsetnumber

Col offset at md

lgOffsetnumber

Col offset at lg

Components

TODO: Explain general component usage

Button

src/components/Button/Button.js

Simple button.

Prop nameTypeDefaultDescription
childrennode

Button child content

disabledbool

Whether button is disabled or not. Prevents onClick.

hrefstring

Href link. Will turn button into <a/> element.

loadingbool

Whether button is loading asynchronous content or not. Will block onClick if true.

loadingContentnodeloading...

Loading content to replace children when loading

onClickfunc

Button onClick handler function.

Dialog

src/components/Dialog/Dialog.js

Dialog window for dispaying alerts, messages, confirms, or anything else.

Prop nameTypeDefaultDescription
cancelTextstringCancel

Text for cancel button

childrennode

Child component(s) to render within the Dialog box

confirmTextstringConfirm

Text for confirm button

contentstring

Text content to display within the Dialog

onCancelfunc

Cancel button handler. Cancel button will not display if not set.

onConfirmfunc

Confirm button handler. Confirm button will not display if not set.

onEscKeyDownfunc

Attach function to escape key while mounted. Maybe to CLOSE the Dialog? Perhaps?

onOverlayClickfunc

Function to call when clicking outside the Dialog box. Often you will want a function to close the Dialog.

openboolfalse

Whether or not the Dialog is open

timeoutunion150

Dialog transition timeout. Either integer or object.

{ enter: 300, exit: 100 }

One of type: number, shape
titlestring

Dialog title text

You can give a a Dialog a title, content, confirm action and cancel action out of the box.

Or fully customize the the content rendered in a for more complicated (even multi-step) Dialogs.

Input

src/components/Input/Input.js

Basic form input. All other props passed to this component will be passed through to the actual input field.

Prop nameTypeDefaultDescription
classNamestringRequired

className for glamorous styles

descriptionstring

Helper description for tooltip

errorstring

Error message for input. Alters input style and displays error message if set.

labelstring

Field label text to display above input

namestring

Field name in form

onBlurfunc

Function to call on input blur

onChangefunc

Function to call on input change

onFocusfunc

Function to call on input focus

placeholderstring

Placeholder text for input

typestringRequired

Input type

wrapperPropsobject

Props to pass on to the Input Component Wrapper.

valuestring

Input value

A basic form input.

Basic Input Example

With Label

With Label & Error

Tomato is a fruit, dummy...

Textarea

src/components/Textarea/Textarea.js

Basic form textarea input. All other props passed to this component will be passed through to the actual textarea element.

Prop nameTypeDefaultDescription
classNamestringRequired

className for glamorous styles

descriptionstring

Helper description for tooltip

errorstring

Error message for textarea. Alters textarea style and displays error message if set.

focusedbool

Whether this component has focus or not. Automatically set by onFocus and onBlur coming from withFocus HOC

labelstring

Field label text to display above textarea

namestring

Field name in form

onBlurfunc

Function to call on textarea blur

onChangefunc

Function to call on textarea change

onFocusfunc

Function to call on textarea focus

placeholderstring

Placeholder text for textarea

rowsnumber5

Number of rows for this Textarea

wrapperPropsobject

Input value

valuestring

props defined in the instrument for the purpose of style

A basic form textarea input.

Checkbox

src/components/Checkbox/Checkbox.js

Basic checkbox input.

Prop nameTypeDefaultDescription
checkedComponentnode<i className="fa fa-check-square-o" />

Component to display when checked

defaultValuebool

Set true to default checked.

descriptionstring

Helper description for tooltip

disabledbool

Whether checkbox is disabled or not. onSwitch, onChange and onClick will not fire if disabled.

errorstring

Error message for input. Alters input style and displays error message if set.

labelstring

Field label text to display above input

namestring

Field name in form

onBlurfunc

Function to call on input blur

onChangefunc

Function to call on input change

onSwitchfunc

Function to call when switched. Also fires onChange and onClick if passed as props. Will not fire when disabled.

uncheckedComponentnode<i className="fa fa-square-o" />

Component to display when unchecked

valuebool

Input value. Whether checked or not.

Simple Checkbox


Controlled Input


Custom Check Icons

Toggle

src/components/Toggle/Toggle.js

Basic checkbox input.

Prop nameTypeDefaultDescription
defaultValuebool

Set true to default checked.

descriptionstring

Helper description for tooltip

disabledbool

Whether checkbox is disabled or not. onSwitch, onChange and onClick will not fire if disabled.

errorstring

Error message for input. Alters input style and displays error message if set.

labelstring

Field label text to display above input

namestring

Field name in form

onBlurfunc

Function to call on input blur

onChangefunc

Function to call on input change

onSwitchfunc

Function to call when switched. Also fires onChange and onClick if passed as props. Will not fire when disabled.

valuebool

Input value. Whether checked or not.

Simple Toggle


Controlled Input


Default Value