README
React-es
Library of common React components used on the front-end applications developed for eSpeakers.
When developing on a local machine run this
$ yarn run test
When ready to publish a new version. Use Semantic Versioning to determine the version number. i.e.
$ yarn run prod-patch #for bug fixes, cleanup or other backwards-compatible changes
$ yarn run prod-minor #adding new features in a backwards compatable way
$ yarn run prod-major #breaking changes, including things like updating to a react version that has breaking changes
Installation
To install, use yarn or npm
yarn install espeakers
Then you can use the various components in your projects
import {
actions,
reducers,
redux,
components,
exceptions,
forms,
utils
} from 'espeakers';
or
import { Text } from 'espeakers/forms';
import { Constants } from 'espeakers/utils';
import { Balboa } from 'espeakers/actions';
import { BalboaReducer } from 'espeakers/reducers';
import { AsyncComponent } from 'espeakers/components';
Components
AsyncComponent
Loads the component only when it is requested. Useful when building with modules so the browser doesn't have to load every component/page in a single file.
import { AsyncComponent } from 'espeakers/components';
const AsyncHomePage = AsyncComponent(<HomePage />);
Calendar
Displays the date in a calendar icon. Useful for events and calendar items.
import { Calendar } from 'espeakers/components';
<Calendar date={"2019-01-15"} format={"YYYY-MM-DD"} />
LoadingEllipsis
Displays an animated ellipses, useful when loading content on a page
import { LoadingEllipsis } from 'espeakers/components';
<LoadingEllipsis />
LoadingIndicator
Displays an animated loading circle similar to Google

import { LoadingIndicator } from 'espeakers/components';
<LoadingIndicator />
OauthButtons
Implementation of signon buttons for Google, Facebook, LinkedIn, and Mpi. Used to sign on through Oauth
import { Oauth } from 'espeakers/components';
// Define the callback function that will receive the state from the Oauth service
const callback = (service) => (
window.location.protocol + "//" + window.location.host + "/oauth-callback/" + service + "/"
);
...
// Render the buttons on the page
<Oauth.Google onSuccess={"/home"} redirect={callback}><div className={"btn btn-danger"}>Google</div></Oauth.Google>
<Oauth.Facebook onSuccess={"/home"} redirect={callback}><div className={"btn btn-primary"}>Facebook</div></Oauth.Facebook>
<Oauth.LinkedIn onSuccess={"/home"} redirect={callback}><div className={"btn btn-warning"}>LinkedIn</div></Oauth.Google>
<Oauth.Mpi onSuccess={"/home"} redirect={callback}><div className={"btn btn-default"}>Mpi</div></Oauth.Google>
PopoverMenu
Displays a menu inside a Bootstrap popover. Very useful to show a form field inside a popover
import { PopoverMenu } from 'espeakers/components';
// Render the buttons on the page
<OverlayTrigger trigger="click" placement="bottom" overlay={
<PopoverMenu>
<Dropdown.Item>Item #1</Dropdown.Item>
<Dropdown.Item>Item #2</Dropdown.Item>
<Dropdown.Item>Item #3</Dropdown.Item>
</PopoverMenu>
}>
<Button>Click me</Button>
</OverlayTrigger>
Exceptions
AuthenticationException
Thrown when a username or password is incorrect
import { AuthenticationException } from 'espeakers/exceptions';
throw new AuthenticationException('Invalid username or password');
AuthorizationException
Thrown when a user does not have access to a resource
import { AuthorizationException } from 'espeakers/exceptions';
throw new AuthorizationException('Not authorized');
SpeakerMissingException
Thrown when a speaker is loaded but they do not exist, or their profile is private, or their profile is not linked to the bureau.
It's recommended to show a 404 page or suggestsions for other speakers if this is thrown.
import { SpeakerMissingException } from 'espeakers/exceptions';
throw new SpeakerMissingException('Speaker not found');
TokenException
Thrown when an api token is invalid or expired. It's recommended to have the user login again or refresh their token.
import { TokenException } from 'espeakers/exceptions';
throw new TokenException('Token expired');
Forms
Many redux-forms components that can be used when building forms
Amount
Displays an amount with a $. Also validates that only numbers are entered
import { Amount } from 'espeakers/forms';
<Field
name="name"
component={Amount}
/>
Checkbox
Displays an chekbox
import { Checkbox } from 'espeakers/forms';
<Field
name="name"
component={Checkbox}
/>
CheckboxDropdown
Displays an list of checkboxes using PopoverMenu
import { CheckboxDropdown } from 'espeakers/forms';
<Field
name="name"
component={CheckboxDropdown}
/>
ColorPicker
Displays a button that opens the system color picker
import { ColorPicker } from 'espeakers/forms';
<Field
name="name"
component={ColorPicker}
/>
DateRangePickerField
Displays an instance of the bootstrap-daterangepicker component
import { DateRangePickerField } from 'espeakers/forms';
<Field
name="name"
type={text|button}
startDate={"01/01/2019"}
format={"MM/DD/YYYY"}
component={DateRangePickerField}
/>
EmailConsent
Displays checkbox agreeing to receive emails
import { EmailConsent } from 'espeakers/forms';
<Field
name="name"
component={EmailConsent}
/>
FileUpoad
Displays file upload control using react-dropzone
import { FileUpoad } from 'espeakers/forms';
<Field
name="name"
component={FileUpoad}
/>
Initials
Displays a textbox for user initials, along with their name and date
import { Initials } from 'espeakers/forms';
<Field
name="name"
component={Initials}
/>
Message
Displays a textarea
import { Message } from 'espeakers/forms';
<Field
name="name"
rows={5}
component={Message}
/>
OfferAmount
Displays an <Amount /> with $ USD in the input-group-addon
import { OfferAmount } from 'espeakers/forms';
<Field
name="name"
component={OfferAmount}
/>
Password
Displays a password field
import { Password } from 'espeakers/forms';
<Field
name="name"
component={Password}
/>
Phone
Displays a phone nubmer field that automatically formats domestic and international phone numbers
import { Phone } from 'espeakers/forms';
<Field
name="name"
component={Phone}
/>
Radio
Displays a radio button field
import { Radio } from 'espeakers/forms';
<Field
name="name"
component={Radio}
/>
Rating
Displays multiple stars for saving a rating
import { Rating } from 'espeakers/forms';
<Field
placeholder="Select a rating"
label="Rate me"
count={7}
value={5}
help_text="Click on a star to rate"
component={Rating}
size={"5x"}
name="rating"
/>
Reason
Displays radio buttons in a group
import { Reason } from 'espeakers/forms';
<Field
name="color"
component={Reason}
label="Red"
/>
<Field
name="color"
component={Reason}
label="Green"
/>
<Field
name="color"
component={Reason}
label="Blue"
/>
SearchSort
Displays a dropdown to select sorting
import { SearchSort } from 'espeakers/forms';
<Field
name="sort"
component={SearchSort}
/>
Selectize
Displays a select component using react-select
import { Selectize } from 'espeakers/forms';
const countries = [
{label: "United States", value: "US"},
{label: "Canada", value: "CA"},
{label: "Mexico", value: "MX"},
];
...
<Field
name="country"
component={Selectize}
options={countries}
normalize={(value) => (_.get(value, ["value"], value))}
format={(value) => ({
label: _.get(_.keyBy(countries, "value"), [value, "label"], value),
value: value
})}
/>
SliderDropdown
Displays a slider within a PopoverMenu
import { SliderDropdown } from 'espeakers/forms';
const marks = {
0: "Free",
2: "$1,000",
5: "$2,500",
10: "$5,000",
15: "$7,500",
20: "$10,000",
30: "$15,000",
40: "$20,000",
50: "$20,000+"
};
...
<Field
component={SliderDropdown}
name="budget"
placeholder="- Any budget -"
width="medium"
defaultValue={[10,20]}
any_placeholder="Any Budget"
min={0}
max={50}
step={5}
dots={true}
marks={marks}
/>
Text
Displays a standard text field
import { Text } from 'espeakers/forms';
<Field
component={Text}
name="name"
label="Name:"
/>
TextWithInputGroup
Displays a standard text field with an input-group-addon before and/or after it
import { TextWithInputGroup } from 'espeakers/forms';
<Field
component={TextWithInputGroup}
name="amount"
label="Amount:"
input_group_before={<span className="input-group-addon">