1.0.3 • Published 5 years ago

react-simple-extra v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

react-simple-extra

A collection of miscellaneous components I use within my projects

npm.io npm.io npm.io

Install

npm i -D react-simple-extra

Usage

Breadcrumbs

This is a navigation component which shows the current path a user is withing your app. It also allows navigation to previous paths.

import { Breadcrumbs, BreadcrumbItem } from "react-simple-extra";

export const MyPage = () => {
    return (
        <div>
            <Breadcrumbs onRedirect={action("Breadcrumbs redirect")}>
                <BreadcrumbItem to="/path/to/1">Home</BreadcrumbItem>
                <BreadcrumbItem to="/path/to/2">Organizations</BreadcrumbItem>
                <BreadcrumbItem to="/path/to/3">Training Programs</BreadcrumbItem>
                <BreadcrumbItem to="/path/to/4">Registered programs</BreadcrumbItem>
                <BreadcrumbItem>Teachers</BreadcrumbItem>
            </Breadcrumbs>
        </div>
    );
};

The props for the Breadcrumb component are show below:

PropTypeDescription
onRedirect(path: string) => voidA function that is called when any of the breadcrumb child items is clicked. It is passed the path of that item. You can then put your specific routing process in this function
childrenanyThe children of the Breadcrumb should be one or more BreadcrumbItem component(s)

The props from the BreadcrumbItemcomponent are show below:

PropTypeDescription
tostringThe path to be redirected to when clicked. If not specified, clicking is disabled for that BreadcrumbItem
childrenanyThe child of the BreadcrumbItem

The component also allows customization by way of CSS variables. These are described in the table below:

VariableDescription
--simple-breadcrumb-item-bgThe default background color of each breadcrumb item
--simple-breadcrumb-item-colorThe default text color of each breadcrumb item
--simple-breadcrumb-item-first-bgThe background color of the first breadcrumb item
--simple-breadcrumb-item-hover-bgThe background color of each breadcrumb item when the cursor is over it
--simple-breadcrumb-item-active-bgThe background color of the last breadcrumb item
--simple-breadcrumb-item-active-colorThe text color of the last breadcrumb item

ConfirmModal

A convenience component that displays a modal requesting for confirmation from the user before executing some specified function

import { ConfirmModal } from "react-simple-extra";

export const MyPage = () => {
    return (
        <div>
            <ConfirmModal
                isLoading={false}
                classes={["btn btn-primary btn-sm", "btn btn-primary btn-block", "btn btn-link btn-block"]}
                content={["Start", "Confirm start", "Cancel"]}
                onConfirm={action("Start confirmed")}
            />
        </div>
    );
};

The props for this component are show below:

PropTypeDescription
classes[string, string, string]A list of CSS classes for each button assigned in the order of the trigger button, the confirm button and the cancel button
content[any, any, any]A list of JSX content for each button assigned in the order of the trigger button, the confirm button and the cancel button
isLoadingbooleanWhen true, the buttons are disabled and a loading indicator is displayed. This is useful if the component is used to trigger a long-running action (E.g. a network action)
loadingMessageanyText to display by the loading indicator. Defaults to "Please wait..."
expandOnRenderbooleanIf true, the component will be in its triggered state when it renders. Defaults to false
onConfirm() => voidThe function that is called when the confirm button is clicked

Storybook

The project uses Storybook to visually test the components

To run these stories:

  1. Clone the repository
  2. Run npm install to install dependencies
  3. Run npm run storybook to start the storybook server.

For more information on Storybook, click here

Maintainers

Support

If you'd like to support this project, you can do so by becoming a patreon on Patreon

It would be really helpful if you can star the project on Github

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago