0.7.45 • Published 8 days ago

droplr-react-ui-v2 v0.7.45

Weekly downloads
-
License
-
Repository
github
Last release
8 days ago

droplr-react-ui-v2 npm version Storybook Figma React

Logo The up-to-date touch-up to Droplr's react UI Library.

Table of contents

Components

Button

Button(props): Element

Component

Desc

The button component

Parameters

NameTypeDescription
propsButtonPropsThe component props, instance of ButtonProps

Returns

Element

ButtonProps: Interface

NameTypeDescription
labelstring requiredThe label on the button
onClickFunction optionalThe click handler function for the button
classNamestring optionalAppends custom class name
variantstring optionalStyle variants of the button, Options primary secondary success info warning alternative danger transparent Default: primary
sizestring optionalSize variants of the button Options small medium large Default: medium
disabledboolean optionalSets the button to the disabled state. Default: false
loadingboolean optionalRenders a spinner over the button Default: false
iconIcon optionalRenders an icon before the label text

Example

<Button 
    label='Button' 
    onClick={clickHandler} 
    variant='secondary' 
    size='large' />

Input

Input(Component): Element

Desc

Input component

Parameters

NameTypeDescription
ComponentInputPropsprops

Returns

Element

InputProps: Interface

NameTypeDescription
valuestring optionalThe default value of the input field
typestring optionalThe input field type, Options text password number Default: text
classNamestring optionalAppends custom class name
labelstring optionalThe label above the input field
sublabelstring optionalA smaller label under the {label} prop
disabledboolean optionalDisables the component
placeholderstring optionalThe placeholder text of the input field
infostring optionalSmall informative text under the input field
errorstring optionalDisplays an error message under the input field
autoFocusboolean optionalAutofocuses the input field
readOnlyboolean optionalMakes the component uneditable
passwordVisibleboolean optionalShows or hides the password text
icon optionalAn optional icon shown on the right-hand side
onBlurfunction optionalEvent handler for the 'onBlur' event
onFocusfunction optionalEvent handler for the 'onFocus' event
onKeyPressfunction optionalEvent handler for the 'onKeyPress' event
onChangefunction optionalEvent handler for the 'onChange' event

Example

const onChange = (e) => {
    // Gets the text from the input field
    handleInput(e.target.value);
};

<Input 
    value={'My Input Component' }
    type={'text'} 
    autoFocus 
    info={'Please fill out the form'} 
    onChange={onChange}/>

Dropdown

Dropdown(Component): Element

Desc

Dropdown component

Parameters

NameTypeDescription
ComponentDropdownPropsprops

Returns

Element

DropdownProps: Interface

NameTypeDescription
itemsArray requiredThe list of the dropdown items Instances of DropdownItemProps
labelstring requiredThe label of the dropdown
classNamestring optionalAppends custom class name
defaultIndexnumber optionalIndex of the default selected item in the items array. Default: 0
disabledboolean optionalSets the dropdown input field to the disabled state. Default: false
fullWidthboolean optionalHas the dropdown input field occupy the full width of its parent Default: false
minWidthpixel-format string, ie. 12px optionalSets the minimum width for the input field Default: 0px
closeOnMouseOutboolean optionalCloses the dropdown when the mouse leaves the list Default: true
closeOnItemClickboolean optionalCloses the dropdown when an option in selected Default: true
showItemStatusboolean optionalShows a checkmark icon next to selected items Default: false
onMouseLeaveFunction optionalHandler function for when the mouse leaves the dropdown

DropdownItemProps: Interface

NameTypeDescription
titlestring requiredThe title of the list item
onClickFunction requiredThe click handler function for the list item. Provides the currently selected item as the argument (typeof DropdownItemProps)
descriptionstring optionalThe description of the list item
disabledboolean optionalSets the list item to the disabled state. Default: false
classNamestring optionalAppends custom class name
iconIcon optionalRenders an icon before the title text of the list item
hrefstring optionalThe href attribute target for the item click
targetstring optionalThe target attribute target for the item click
showItemStatusboolean optionalShows a checkmark icon next to selected item Default: false
activeboolean optionalSets the item to active state by default Default: false

Example

const dropdown_items: Array<DropdownItemProps> = [{
    title: 'My list item - one',
    icon: <Icon name='Calendar' size={12} />,
    onClick: itemClickHandler(),
    disabled: false,
    },{
    title: 'My list item - two',
    description: 'My item's description',
    icon: <Icon name='List' size={12} />,
    onClick: itemClickHandler(),
    disabled: true,
}];
<Dropdown items={dropdown_items} label='My Dropdown' closeOnMouseOut={false} />

Defined in

components/Dropdown/Dropdown.tsx:173


DroplrThemeProvider

Parameters

NameTypeDescription
themestringSwitches the theme for the components wrapped in the provider. Options: light dark Default: light

Example

<DroplrThemeProvider theme={'light'}>
      <App />
</DroplrThemeProvider>

Icon

Icons

Icon(props): Element

Parameters

NameTypeDescription
propsIconPropsThe Icon component props, instance of IconProps

Returns

Element

IconProps: Interface

NameTypeDescription
namestring requiredThe name of the icon Options Add AddPeople AddToBoard Alert AlignCenter AlignLeft AlignRight AllItems Arrow Audio Back Bell Binoculars Board Bold Browser BrowserTab CalendarTime Calendar Camera Cancel CheckCircle Check ChevronDown ChevronRight ChevronDown ChevronLeft Chrome Clipboard Close CloudUpload Code CodeBlock Comment CreateBoard Crop Cross CrossBold Cut Dashboard Delete Destruct DetachBoard Disable Documents Dots Down Download Draw DropdownDown DropdownUp Edit Elements Enable EntirePage Error ExpireTime EyeOff Eye Face Facebook FileText FileZip Folder FullScreen FullDesktop Gear HeadlineFirst HeadlineSecond Heart Hyperlink Image Info Italic Key LayoutGrid LayoutList Link LockOpen Lock Logout Mail Markdown Money More Move NewWindow Nib Notes NotesBold Notification OrderArrow OrderedList Others PadlockLock PadlockUnlock Paragraph Pause Pen Phone Photo PhotoCamera Play Plugin PlusToBoard Private Profile Public PublicFolder QuestionMark Quote Redo Refresh RemoveTag Resume Save Screenrecording Search SearchBold SelectedArea Send Separator Share Shared Sort Star Success TagFilled Tags Task Team Terminal TrashBin Twitter Typography Underline Undo UnorderedList Up Upload UploadFile Url VerticalDots Video VideoCam VideoCamPlus ViewGrid ViewList Wallet Warning WatchFolder Window Zip ZoomIn ZoomOut ZoomReset
classNamestring optionalAppends custom class name
styleCSSProperties optionalAppends a custom style to the icon component
sizenumber optionalPixel-size of the icon Default: 14
strokestring optionalSets the stroke width for the icon Default: 1
colorstring optionalThe color of the icon Default: gray

Example

<Icon 
    name={'Add'} 
    size={12} 
    color={'#000'} 
    stroke={0.75} />

Switch

Switch(props): Element

Desc

Switch component

Parameters

NameType
propsSwitchProps

Returns

Element

SwitchProps: Interface

NameTypeDescription
labelstring optionalThe label of the component
labelPositionstring optionalThe position of the label Options top bottom left right
classNamestring optionalAppends custom class name
checkedboolean requiredThe state of the switch component
disabledboolean optionalSets the component to the disabled state. Default: false
onChangeFunction optionalThe function that handles the change of state. Passes the current state as arg, typeof boolean

Example

<Switch 
    checked={true} 
    label='My Switch' 
    onChange={onChangeHandler} />

TextSwitch

TextSwitch(props): Element

Desc

TextSwitch component

Parameters

NameType
propsTextSwitchProps

Returns

Element

TextSwitchComponentProps: Interface

NameTypeDescription
itemsArray requiredThe list of the switch control items Instances of TextSwitchItemProps
labelstring requiredThe label of the component
classNamestring optionalAppends custom class name
defaultIndexnumber or string optionalIndex (or label) of the default selected item in the switch Default: 0
disabledboolean optionalSets the component to the disabled state. Default: false
onChangeFunction optionalThe function that handles the change of state. Passes the currently active item as arg, typeof TextSwitchItemProps

TextSwitchItemProps: Interface

NameTypeDescription
idnumber requiredThe ID of the switch item
labelstring requiredThe label of the switch item
iconIcon optionalAppends an icon in front of the label

Example

const switch_items = items: [
    {
        id: 0, 
        label: 'Option One'
    }, {
        id: 1,
        label: 'Option Two'
    }, {
        id: 2,
        label: 'Option Three'
        icon: <Icon name={'Clipboard'} />
    }
];

<TextSwitch 
    items={switch_items} 
    label='My Switch' 
    onChange={onChangeHandler} />

Tooltip

Tooltip(props): Element

Desc

The Tooltip component

Parameters

NameType
propsTooltipProps

Returns

Element

TooltipProps: Interface

NameTypeDescription
contentany requiredThe content of the tooltip, ideally text
onTooltipShowFunction optionalThe callback for when the tooltip is shown
onTooltipHideFunction optionalThe callback for when the tooltip is hidden
positiontop, bottom, left, right optionalThe placement of the tooltip with regards to the element it is wrapping Default: top
hideDelaynumber optionalThe delay (in ms) before hiding the tooltip Default: 250
titlestring optionalThe title text of the tooltip
closeOnClickboolean optionalEnables closing the tooltip on click, defaults to false

Example

// A simple tooltip
<Tooltip content={"Hooray!"}>
    Hover over me!
</Tooltip>

// A tooltip with a few custom properties
<Tooltip
    title={"Hey!"}
    content={"I'm down here!}
    position="bottom"
    hideDelay={500}
    onTooltipHide={() => console.log("Bye!")}
    >
    Hover over me!
</Tooltip>

Badge

Badge(props): Element

Desc

The Badge component

Parameters

NameType
propsBadgeProps

Returns

Element

BadgeProps: Interface

NameTypeDescription
variantprimary secondary success info warning alternative danger Default: primary requiredThe variant of the badge component
labelstring requiredThe text within the badge

Example

<Badge variant="info" label="My Badge" />

Toast

Toast(props): Element

Desc

The Toast component and its wrapper

Parameters

NameType
propsToastProps

Returns

Element

NewToastProps: Interface

NameTypeDescription
messagestring requiredThe content of the toast message
titlestringThe title of the toast message
variantsuccess, error, warning , infoThe color variant of the toast message
iconIconThe icon to be shown on the left side of the toast
durationnumberThe duration (in ms) of the Toast element Default: 5000
withProgressBarbooleanShows a progress bar at the bottom of the toast
clickToDismissbooleanEnables dismissing the toast by clicking on it
onClickFunctionTriggers this callback if the Toast notification is clicked

Example

// The wrapper around the app's root
<WithToast>
        <App />
</WithToast>

// You can add a top-side offset to the provider on a global level, ie. to avoid headers
<WithToast offsetTop={128}>
        <App />
</WithToast>

// Spawn the toast message
InfoToast({
    message: "This is a toast message.",
    title: "A test toast title. Have fun!",
    duration: 7500,
    clickToDismiss: true,
    onClick: () => console.log("I've been clicked away!");
    });

RadioButton

RadioButton(props): Element

Desc

The RadioButton component

Parameters

NameType
propsRadioButtonprops

Returns

Element

RadioButtonProps: Interface

NameTypeDescription
classNamestringAppends additional class names to the component
checkedbooleanThe checked state of the component
variantsuccess, danger, warning , secondaryThe color variant of the component
disabledbooleanDisables the component, becomes uninteractive
onClickFunctionThe click handler for the component

Example

<RadioButton
checked={isChecked}
onClick={() => {setIsChecked(!isChecked)}}
variant="primary"
/>

ThumbnailSwitch

ThumbnailSwitch(props): Element

Desc

ThumnailSwitch component

Parameters

NameType
propsThumbnailSwitchProps

Returns

Element

ThumbnailSwitchComponentProps: Interface

NameTypeDescription
itemsArray requiredThe list of the switch control items Instances of TextSwitchItemProps
labelstring requiredThe label of the component
classNamestring optionalAppends custom class name
defaultIndexnumber or string optionalIndex (or label) of the default selected item in the switch Default: 0
disabledboolean optionalSets the component to the disabled state. Default: false
onChangeFunction optionalThe function that handles the change of state. Passes the currently active item as arg, typeof ThumbnailSwitchItemProps

ThumbnailSwitchItemProps: Interface

NameTypeDescription
idnumber requiredThe ID of the switch item
labelstring requiredThe label of the switch item
iconIcon optionalAdds an icon to the top portion of the switch

const switch_items = items: [
    {
        id: 0, 
        label: 'Option One',
        icon: <Icon name={'RemoveTag'} />
    }, {
        id: 1,
        label: 'Option Two',
        icon: <Icon name={'Delete'} />
    }, {
        id: 2,
        label: 'Option Three',
        icon: <Icon name={'Clipboard'} />
    }
];

<ThumbnailSwitch 
    items={switch_items} 
    label='My Switch' 
    onChange={onChangeHandler} />
0.7.45

8 days ago

0.7.44

10 days ago

0.7.43

15 days ago

0.7.40

15 days ago

0.7.42

15 days ago

0.7.41

15 days ago

0.7.39-beta

15 days ago

0.7.38

22 days ago

0.7.37

23 days ago

0.7.36

23 days ago

0.7.35

24 days ago

0.7.34

24 days ago

0.7.33

30 days ago

0.7.32

1 month ago

0.7.31

1 month ago

0.7.30

1 month ago

0.7.29

1 month ago

0.7.26

1 month ago

0.7.25

1 month ago

0.7.28

1 month ago

0.7.22

1 month ago

0.7.21

1 month ago

0.7.24

1 month ago

0.7.23

1 month ago

0.7.2

1 month ago

0.7.1

1 month ago

0.7.0

1 month ago

0.6.20

1 month ago

0.6.19

1 month ago

0.6.18

1 month ago

0.6.17

2 months ago

0.6.14

2 months ago

0.6.13

2 months ago

0.6.15

2 months ago

0.6.12

2 months ago

0.6.11

2 months ago

0.6.1

2 months ago

0.6.0

2 months ago

0.5.5

3 months ago

0.5.4

3 months ago

0.5.3

4 months ago

0.5.2

4 months ago

0.5.0

5 months ago

0.5.1

5 months ago

0.4.7

6 months ago

0.4.6

6 months ago

0.4.5

7 months ago

0.4.4

9 months ago

0.4.3

10 months ago

0.4.2

11 months ago

0.3.91

12 months ago

0.4.1

12 months ago

0.4.0

12 months ago

0.3.9

12 months ago

0.3.6

1 year ago

0.3.5

1 year ago

0.3.8

1 year ago

0.3.7

1 year ago

0.3.4

1 year ago

0.3.0

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.3

1 year ago

0.2.40

1 year ago

0.2.39

1 year ago

0.2.38

1 year ago

0.2.37

1 year ago

0.2.36

1 year ago

0.2.35

1 year ago

0.2.34

1 year ago

0.2.33

1 year ago

0.2.32

1 year ago

0.2.31

1 year ago

0.2.30

1 year ago

0.2.29

1 year ago

0.2.28

1 year ago

0.2.27

1 year ago

0.2.26

1 year ago

0.2.25

1 year ago

0.2.24

1 year ago

0.2.23

1 year ago

0.2.22

2 years ago

0.2.21

2 years ago

0.2.20

2 years ago

0.2.19

2 years ago

0.2.18

2 years ago

0.2.17

2 years ago

0.2.16

2 years ago

0.2.15

2 years ago

0.2.14

2 years ago

0.2.13

2 years ago

0.2.12

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago