1.0.20 • Published 3 years ago
res-shared-components v1.0.20
res-shared-components
RES Shared Components
Install
npm install --save res-shared-components
Components
ErrorBox
Interface
LoadingProps {
errors: (string|JSX.Element)[];
}
Usage
import * as React from "react";
import { ErrorBox } from "res-shared-components";
class Example extends React.Component {
errorsArray = [
"This is an error",
<p>
This is an <a>error</a>
</p>
];
render() {
return <ErrorBox errors={errorsArray} />;
}
}
Loading
Interface
LoadingProps {
location: string;
}
Usage
import * as React from "react";
import { Loading } from "res-shared-components";
class Example extends React.Component {
render() {
return <Loading location="example" />;
}
}
Modal
Interface
ModalProps {
action: () => void;
children: JSX.Element; // Html to be rendered in the modal
className?: string;
glyph?: string; // Optional icon for closing the modal defaults to 'X'
}
Usage
import * as React from "react";
import { Modal } from "res-shared-components";
class Example extends React.Component {
constructor(props) {
super(props);
this.state = {
modalOpen: false
};
this.toggleModalOpen = this.toggleModalOpen.bind(this);
}
toggleModalOpen() {
this.setState(prevState => ({ modalOpen: !prevState.modalOpen }));
}
displayModal() {
if (this.state.modalOpen) {
return (
<Modal action={this.toggleModalOpen} className='modal-classname'>
<div>Modal Content</div>
</Modal>
)
} else {
return null;
}
}
render() {
return (
<button onClick={this.toggleModalOpen}
{this.displayModal()}
)
}
}
PmsSelect / StateSelect
PMS Select and State Select work the same except for the options in the select.
Interface
PmsSelectProps / StateSelectProps {
blurFunction?: (value: string) => any; // Used if you want to validate on blur
blurString?: string; // validate field state key
selectedValue: string;
updateFunction: any;
}
Usage
import * as React from "react";
import { PmsSelect, StateSelect } from "res-shared-components";
class Example extends React.Component {
constructor(props) {
super(props);
this.state = {
pms: "",
state: "",
validatePms: false,
validatestate: false
};
this.update = this.update.bind(this);
this.allowValidation = this.allowValidation.bind(this);
}
update(field: string): any {
return (e: any) =>
this.setState({
[field]: e.currentTarget.value
});
}
allowValidation(field: string): any {
return (e: any) =>
this.setState({
[field]: true
});
}
render() {
return (
<div>
<PmsSelect
blurFunction={this.allowValidation}
blurString="validatePms"
selectedValue={this.state.pms}
updateFunction={this.update}
/>
<StateSelect
blurFunction={this.allowValidation}
blurString="validateState"
selectedValue={this.state.state}
updateFunction={this.update}
/>
</div>
);
}
}
Wizard
Interface
WizardProps {
activePage: number;
steps: WizardStep[];
}
WizardStep {
title: string;
description: string | string[]; // use array to force break string
icon?: string; //optional ex. 'far fa-check'
stepNum?: string; //optional
clickFunction?: (stepNum: number) => void; //optional
}
Usage
import React, { Component } from "react";
import { IWizardStep, Wizard } from "res-shared-components";
export default class Example extends Component {
constructor(props) {
super(props);
this.state = {
activePage: 0
};
this.handleClick = this.handleClick.bind(this);
}
handleClick(activePage: number): void {
this.setState({ activePage });
}
render() {
const steps: IWizardStep = [
{
title: "Step 1",
description: "User Login",
stepNum: "1",
clickFunction: this.handleClick
},
{ title: "Step 2", description: "Practice Info", icon = "far fa-check" }
];
return <Wizard steps={steps} activePage={this.state.activePage} />;
}
}
License
1.0.20
3 years ago
1.0.19
4 years ago
1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.12
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago