New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

hypertoxin

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hypertoxin

A themeable ReactNative component library for developing native apps

latest
Source
npmnpm
Version
0.2.2
Version published
Maintainers
1
Created
Source

Hypertoxin

Image

npm version npm downloads

A themeable and declarative React Native component library for developing native mobile apps.

Screenshots with some example themes

Dynamic theme switching

Mock up shopping app screenshots with default theme

Mock up shopping app screenshots with bubble theme

Published Open-source App Virida built with Hypertoxin component library.

Checkout Virida on the app store!

Documeantations are still WIP.

Installation

$ npm install hypertoxin --save

Demo & Showcase

Hypertoxin comes with a full demo that you can build and run on your device or simulator. All of the code examples in this README are from the demo. To build the demo for iOS,

$ cd hypertoxin/demo
npm install

This will install the required modules such as React Native, Hypertoxin, Hyperflow, and others. Then open hypertoxin/demo/ios with Xcode, select your ios simulator/device, and build. The default build scheme is release. When use successfully, you will see the following on your device or simulator.

Demo source

Usage

The imported hypertoxin object is consists of Ht, ThemeContext, and Theme. Ht is an object containing all available components. Theme is the default global theme object which is used as a reference for making custom themes. ThemeContext the a react context provider which is required for setting custom themes.

import React, { Component } from 'react';
import ReactNative from 'react-native'
import { Ht, ThemeContext, Theme as DefaultTheme } from 'hyperflow';

// All current available components with more to come. See todo list.
const {
    FlatButton,
    RaisedButton,
    AreaButton,

    AvatarImage,
    IconImage,
    CoverImage,

    TextField,
    SearchField,

    HorizontalDivider,
    VeriticalDivider,

    HeadlineText,
    TitleText,
    SubtitleText,
    InfoText,
    CaptionText,

    BodyScreen,
    HeaderScreen,

    RowLayout,
    ColumnLayout
} = Ht;

export default class App extends Component {
  render() {
      return (
          <ThemeContext.Provider value = {{
              DefaultTheme // Modify this DefaultTheme object to make your own custom theme
          }}>
              // Top level app component goes here...
          </ThemeContext.Provider>
      );
  }
}

Documentations

Button Components

Hypertoxin has three button components, FlatButton, RaisedButton, and AreaButton

Flat Button Properties

A standard button component that can be styled as an icon, a clear, or simply a flat opaque button.

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet button's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
actionstring, objectnoneSet button's onPress callback action to be defined by the parent component. This property is used when a button is set as a child search button for parent components such as SearchField, TextField, or HeaderScreen. See Using Action Property section for details
shadestring, objectthemedSet button's shade theme, can be themed, light, or dark
overlaystringthemedSet button's overlay style which can be one of themed, opaque, translucent, translucent-outline, transparent, transparent-outline
cornerstring, number, objectthemedSet button's corner styles. As a number, border radius = corner. Set corner as an object for more control. For example corner = { topLeft: 0.1, topRight: 0.1, bottomLeft: 0.1, bottomRight: 0.1}
sizestringthemedSet button's size which can be one of themed, small, normal, large
marginstring, number, objectNoneSet button's margin styles. As a number, the margin is equally set around the button. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
disabledbooleanfalseDisable the button
busybooleanfalseEnable button busy activity indicator
rippledboolean, stringthemedEnable button ripple animation
labelstringNoneButton string label
colorstringthemedSet button's color style. Can be hex string, default color name, or themed color name
debouncedbooleanfalseEnable button debouncing at 250 ms
onPressfunctionNoneCalls when button is pressed
styleobjectNoneFlat button style is an object with the following properties: container: {...}, contentLeftRoom: {...}, contentMiddleRoom: {...}, contentRightRoom: {...}, badgeRoom: {...}, activityIndicatorRoom: {...}, label: {...}, ripple: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object

Raised Button Properties

Raised button is similar to flat button with the exceptions that it has permanent drop shadow and opaque color.

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet button's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
actionstring, objectnoneSet button's onPress callback action to be defined by the parent component. This property is used when a button is set as a child search button for parent components such as SearchField, TextField, or HeaderScreen. See Using Action Property section for details
shadestring, objectthemedSet button's shade theme, can be themed, light, or dark
cornerstring, number, objectthemedSet button's corner styles. As a number, border radius = corner. Set corner as an object for more control. For example corner = { topLeft: 0.1, topRight: 0.1, bottomLeft: 0.1, bottomRight: 0.1}
sizestringthemedSet button's size which can be one of themed, small, normal, large
marginstring, number, objectNoneSet button's margin styles. As a number, the margin is equally set around the button. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
disabledbooleanfalseDisable the button
busybooleanfalseEnable button busy activity indicator
rippledboolean, stringthemedEnable button ripple animation
labelstringNoneButton string label
colorstringthemedSet button's color style. Can be hex string, default color name, or themed color name
debouncedbooleanfalseEnable button debouncing at 250 ms
onPressfunctionNoneCalls when button is pressed
styleobjectNoneRaised button style is an object with the following properties: container: {...}, contentLeftRoom: {...}, contentMiddleRoom: {...}, contentRightRoom: {...}, badgeRoom: {...}, activityIndicatorRoom: {...}, label: {...}, ripple: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object

Area Button Properties

Unlike flat or raised button, area button was intended mainly as a list item component. Therefore it works nicely as a selectable item in a typical list view.

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet button's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
actionstring, objectnoneSet button's onPress callback action to be defined by the parent component. This property is used when a button is set as a child search button for parent components such as SearchField, TextField, or HeaderScreen. See Using Action Property section for details
shadestring, objectthemedSet button's shade theme, can be themed, light, or dark
overlaystringthemedSet button's overlay style which can be one of themed, opaque, translucent, transparent
sizestringthemedSet button's size which can be one of themed, small, normal, large
marginstring, number, objectNoneSet button's margin styles. As a number, the margin is equally set around the button. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
disabledbooleanfalseDisable the button
rippledboolean, stringthemedEnable button ripple animation
debouncedbooleanfalseEnable button debouncing at 250 ms
onPressfunctionNoneCalls when button is pressed
styleobjectNoneArea button style is an object with the following properties: container: {...}, contentLeftRoom: {...}, contentRightRoom: {...}, ripple: {...}. Unlike flat and raised buttons, there is no middle room styling. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object

Note: themed property indicates using values defined by the global theme provider.

By default, flat, raised, and area button components pass shade, size, color (flat & raised only), and disabled properties down to their child components and at the same time set margin = { 0 } and indentation = { 0 } properties onto its children. This behavior can be override by child components with the exclusions property. . See Using Exclusions Property section for details.

Flat & raised button internal view compositions diagram

Area button internal view compositions diagram

Flat & raised button animated internal view composition reference names. See Animation API for details:

  • animated-container-view
  • animated-content-left-room-view
  • animated-content-middle-room-view
  • animated-content-right-room-view
  • animated-activity-indicator-room-view
  • animated-badge-room-view

Area button animated internal view composition reference names. See Animation API for details:

  • animated-container-view
  • animated-content-left-room-view
  • animated-content-right-room-view

Flat, raised & area button methods & callbacks:

  • animate - See Animation API for details
  • onPress - Button press callback
    • arguments:
      • event (object) - React Native event
    • return: None

Flat Button Examples

Standard flat buttons with colors defined by global theme

<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'default' />
<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'primary' />
<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'secondary' />
<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'accent' />

Clear buttons can be created when styling flat buttons with overlay = 'transparent' property. The component will auto-adjust the label text color accordingly.

Standard clear buttons with colors defined by global theme

<FlatButton overlay = 'transparent' label = 'BUTTON' color = 'default' />
<FlatButton overlay = 'transparent' label = 'BUTTON' color = 'primary' />
<FlatButton overlay = 'transparent' label = 'BUTTON' color = 'secondary' />
<FlatButton overlay = 'transparent' label = 'BUTTON' color = 'accent' />

Flat buttons in 3 available sizes with icon images to the left

And icon images to the right

To add icon image to button, add a child icon image component (more details for IconImage component below) with a content room property. All button components have 4 child rooms, content-left, content-middle, content-right, and badge.

Internally, a room is just a convenient way for creating child Views, thus allowing the JSX code to be less clutter and much more declarative.

<FlatButton overlay = 'opaque' size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'opaque' size = 'normal' label = 'NORMAL' color = 'secondary' >
    <IconImage  room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'opaque' size = 'large' label = 'LARGE' color = 'accent' >
    <IconImage room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'opaque' size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>
<FlatButton overlay = 'opaque' size = 'normal' label = 'NORMAL' color = 'secondary' >
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>
<FlatButton overlay = 'opaque' size = 'large' label = 'LARGE' color = 'accent' >
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>

Clear buttons in 3 available sizes with icon images to the left & right

<FlatButton overlay = 'transparent' size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'normal' label = 'NORMAL' color = 'secondary' >
    <IconImage  room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'large' label = 'LARGE' color = 'accent' >
    <IconImage room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'normal' label = 'NORMAL' color = 'secondary' >
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'large' label = 'LARGE' color = 'accent' >
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>

A few examples of corner styling

<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'primary' corner = 'sharp' />
<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'secondary' corner = 'round' />
<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'accent' corner = 'circular' />

To create a button with a badge, add a child text component with a room = 'badge'.

<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'primary' >
    <InfoText room = 'badge' color = 'white' > 0 </InfoText>
    <IconImage room = 'content-left' source = 'home' />
</FlatButton>

Flat outlined buttons when styled with `overlay = 'transparent-outline'` property

<FlatButton overlay = 'transparent-outline' size = 'small' label = 'BUTTON' color = 'primary' corner = 'sharp' >
    <IconImage room = 'content-left' source = 'star' />
</FlatButton>
<FlatButton overlay = 'transparent-outline' size = 'normal' label = 'BUTTON' color = 'secondary' corner = 'round' >
    <IconImage room = 'content-right' source = 'star' />
</FlatButton>
<FlatButton overlay = 'transparent-outline' size = 'large' label = 'BUTTON' color = 'accent' corner = 'circular' />

Flat buttons styled as icon buttons

<FlatButton overlay = 'transparent' size = 'small' color = 'primary' corner = 'circular' >
    <IconImage room = 'content-middle' source = 'favorite' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'normal' color = 'secondary' corner = 'circular' >
    <IconImage room = 'content-middle' source = 'favorite' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'large' color = 'accent' corner = 'circular' >
    <IconImage room = 'content-middle' source = 'favorite' />
</FlatButton>
<FlatButton overlay = 'transparent' color = { Theme.color.palette.purple } corner = 'circular' >
    <IconImage room = 'content-middle' source = 'smiley-face' />
</FlatButton>
<FlatButton overlay = 'transparent' color = { Theme.color.palette.green } corner = 'circular' >
    <IconImage room = 'content-middle' source = 'star' />
</FlatButton>

Raised Button Examples

Standard raised buttons with colors defined by global theme

<RaisedButton label = 'BUTTON' color = 'default' />
<RaisedButton label = 'BUTTON' color = 'primary' />
<RaisedButton label = 'BUTTON' color = 'secondary' />
<RaisedButton label = 'BUTTON' color = 'accent' />

Raised buttons in 3 available sizes with icon images to the left & right

<RaisedButton size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-left' source = 'home' />
</RaisedButton>
<RaisedButton size = 'normal' label = 'NORMAL' color = 'secondary' >
    <IconImage room = 'content-left' source = 'home' />
</RaisedButton>
<RaisedButton size = 'large' label = 'LARGE' color = 'accent' >
    <IconImage room = 'content-left' source = 'home' />
</RaisedButton>
<RaisedButton size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-right' source = 'profile' />
</RaisedButton>
<RaisedButton size = 'normal' label = 'NORMAL' color = 'secondary' >
    <IconImage room = 'content-right' source = 'profile' />
</RaisedButton>
<RaisedButton size = 'large' label = 'LARGE' color = 'accent' >
    <IconImage room = 'content-right' source = 'profile' />
</RaisedButton>

A few examples of corner styling

<RaisedButton label = 'BUTTON' color = 'primary' corner = 'sharp' />
<RaisedButton label = 'BUTTON' color = 'secondary' corner = 'round' />
<RaisedButton label = 'BUTTON' color = 'accent' corner = 'circular' />

Raised buttons styled as floating action buttons

<RaisedButton color = 'primary' corner = 'circular' size = 'large' >
    <IconImage room = 'content-middle' source = 'add' />
</RaisedButton>
<RaisedButton color = 'secondary' corner = 'circular' size = 'large' >
    <IconImage room = 'content-middle' source = 'edit' />
</RaisedButton>
<RaisedButton color = 'accent' corner = 'circular' size = 'large' >
    <IconImage room = 'content-middle' source = 'star' />
</RaisedButton>

Area Button Examples

Using area button to create selectable list items

<FlatList
    data = { animals }
    renderItem = {(listData) => {
        const animal = listData.item;
        return (
            <AreaButton shade = { shade }>
                <ColumnLayout room = 'content-left' roomAlignment = 'center' >
                    <AvatarImage room = 'content-left' source = { animal.avatarImage } dropShadowed = { false } />
                    <TitleText room = 'content-right' size = 'small' indentation = { 20 }>{ animal.name }</TitleText>
                </ColumnLayout>
                <FlatButton room = 'content-right' overlay = 'transparent' corner = 'circular' color = 'red' >
                    <IconImage room = 'content-middle' source = `favorite` />
                </FlatButton>
            </AreaButton>
        );
    }}
/>

Field Components

Hypertoxin has two field components, TextField and SearchField

Search Field Properties

Use search field to create functional search bar. Notable feature is suggestion pull-up view.

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet search field's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
shadestring, objectthemedSet search field's shade theme, can be themed, light, or dark
overlaystringthemedSet search field's overlay style which can be one of themed, opaque, translucent, translucent-outline, transparent, transparent-outline
cornerstring, number, objectthemedSet search field's corner styles. As a number, border radius = corner. Set corner as an object for more control. For example corner = { topLeft: 0.1, topRight: 0.1, bottomLeft: 0.1, bottomRight: 0.1}
sizestringthemedSet search field's size which can be one of themed, small, normal, large
marginstring, number, objectNoneSet search field's margin styles. As a number, the margin is equally set around search field container. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
dropShadowedboolean, stringthemedEnable search field's container drop shadow
autoFocusbooleantrueEnable search field's auto focus
autoCorrectbooleantrueEnable search field's auto correct spelling
suggestivebooleantrueEnable search field's suggestion pull-up view
pinnedSuggestionValuesarray of string, number, or object[]A list of pinned suggestion values
hintstringNoneSet search field's hint
styleobjectNoneSearch field style is an object with the following properties: container: {...}, box, {...}, contentLeftRoom: {...}, contentRightRoom: {...}, input: {...}, suggestion: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object
onSearchfunctionNoneCalls after search field's text input onSubmitEditing
onGetAutocompletionValuesasync functionNoneAsync retrieve autocompletion string value array for suggestion pull-up view
onEditingfunctionNoneCalls when search field's text input onChangeText
onFocusfunctionNoneCalls after search field's text input is focused
onBlurfunctionNoneCalls after search field's text input is blurred
onCollapsefunctionNoneCalls after search field view collapsed
onExpandfunctionNoneCalls after search field view expanded
onHidefunctionNoneCalls when search field view becomes hidden
onShowfunctionNoneCalls when search field view becomes visible
onHideSuggestionfunctionNoneCalls when search field's suggestion view becomes hidden
onShowSuggestionfunctionNoneCalls when search field's suggestion view becomes visible
onClearfunctionNoneCalls after search field's text input is cleared
onClearSuggestionfunctionNoneCalls after search field's suggestion is clear
renderSuggestionItemfunctionNoneTakes an item from a list of suggestion items (pinned, autocompleted, & history) and renders them into the list in pull-up suggestion view

Text Field Properties

Use text fields to create beautiful input forms. Notable features are input reformatting & validation and selectable pull-up view.

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet text field's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
shadestring, objectthemedSet text field's shade theme, can be themed, light, or dark
overlaystringthemedSet text field's overlay style which can be one of themed, opaque, translucent, translucent-outline, transparent, transparent-outline
cornerstring, number, objectthemedSet text field's corner styles. As a number, border radius = corner. Set corner as an object for more control. For example corner = { topLeft: 0.1, topRight: 0.1, bottomLeft: 0.1, bottomRight: 0.1}
sizestringthemedSet text field's size which can be one of themed, small, normal, large
marginstring, number, objectNoneSet text field's margin styles. As a number, the margin is equally set around text field container. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
autoFocusbooleantrueEnable text field's auto focus
autoCorrectbooleantrueEnable text field's auto correct spelling
securedbooleanfalseEnable text field's secure mode
underlinedboolean, stringthemedEnable text field's underlined animation
disabledbooleanfalseDisable text field's input
initialValuestring, numberNoneSet text input's initial value
selectableValuesarray of string, number, or object[]A list of selectable values
labelstringNoneSet text field's label
hintstringNoneSet text field's hint
charLimitnumber-1Set text input's max characters count. Set charLimit > -1 for no character limit. When charLimit > 1, a little character counter will be visible in the bottom right
lineLimitnumber1Set text input's max lines count. Set lineLimit > 1 for multi-lined text input
inputTypestringdefaultSet text input's type which can be one of default, numeric, monetary, phone-pad, email-address, credit-card-visa, credit-card-master, credit-card-discover, credit-card-american-express
disableValidationboolfalseDisable text input validation
disableFormattingboolfalseDisable text input formatting
styleobjectNoneText field style is an object with the following properties: container: {...}, box: {...}, contentLeftRoom: {...}, contentRightRoom: {...}, input: {...}, helper: {...}, status: {...}, label: {...}, underline: {...}, selection: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object
onValidatefunctionNoneCalls after text field's text input onChangeText or onEndEditing
onReformatfunctionNoneCalls after text field's text input onChangeText
onEditingfunctionNoneCalls when text field's text input onChangeText
onDoneEditfunctionNoneCalls when a value in text field's selectable pull-up view is selected or after text field's text input onSubmitEditing
onSelectfunctionNoneCalls when a value in text field's selectable pull-up view is selected
onFocusfunctionNoneCalls after text field's text input is focused
onBlurfunctionNoneCalls after text field's text input is blurred
onHideSelectionfunctionNoneCalls after text field's selectable pull-up view is hidden
onShowSelectionfunctionNoneCalls after text field's selectable pull-up view is visible
onClearfunctionNoneCalls after text field's text input is cleared
renderSelectableItemfunctionNoneTakes an item from a list of selectable items and renders them into the list in pull-up selection view

Note: themed property indicates using values defined by the global theme provider.

By default, text field component passes shade, size, and disabled properties down to it child components and at the same time set margin = { 0 } and indentation = { 0 } properties onto its children. By default, search field component passes shade property down to it child components and at the same time set margin = { 0 } and indentation = { 0 } properties onto its children. This behavior can be override by child components with the exclusions property. See Using Exclusions Property section for details.

Search field internal view compositions diagram

Search field animated internal view composition reference names. See Animation API for details:

  • animated-container-view
  • animated-box-view
  • animated-content-left-room-view
  • animated-content-right-room-view
  • animated-suggestion-view

Search field available actions:

  • search
  • clear
  • blur
  • focus
  • expand
  • collapse
  • show
  • show-suggestion
  • hide
  • hide-suggestion

Search field methods & callbacks:

  • animate - See Animation API for details
  • isCollapsed
    • arguments: None
    • return: bool
  • isVisible
    • arguments: None
    • return: bool
  • isSuggestionVisible
    • arguments: None
    • return: bool
  • isFocused
    • arguments: None
    • return: bool
  • collapse
    • arguments:
      • animation (object) - Collapse animation object. See Animation API for details.
    • return: None
  • expand
    • arguments:
      • animation (object) - Expand animation object. See Animation API for details
    • return: None
  • show
    • arguments:
      • animation (object) - Show animation object. See Animation API for details
    • return: None
  • showSuggestion
    • arguments:
      • animation (object) - Show animation object. See Animation API for details
    • return: None
  • hide
    • arguments:
      • animation (object) - Hide animation object. See Animation API for details
    • return: None
  • hideSuggestion
    • arguments:
      • animation (object) - Hide animation object. See Animation API for details
    • return: None
  • focus
    • arguments: None
    • return: None
  • blur
    • arguments: None
    • return: None
  • clear
    • arguments: None
    • return: None
  • clearSuggestion
    • arguments: None
    • return: None
  • onSearch
    • arguments:
      • value (string) - Submitted search text value
    • return: None
  • onGetAutocompletionValues (async)
    • arguments:
      • value (string) - Submitted search text value
    • return:
      • results (array) - An array of autocompletion text values
  • onEditing
    • arguments:
      • value (string) - Current search text value
    • return: None
  • onFocus
    • arguments: None
    • return: None
  • onBlur
    • arguments: None
    • return: None
  • onCollapse
    • arguments: None
    • return: None
  • onExpand
    • arguments: None
    • return: None
  • onHide
    • arguments: None
    • return: None
  • onShow
    • arguments: None
    • return: None
  • onHideSuggestion
    • arguments: None
    • return: None
  • onShowSuggestion
    • arguments: None
    • return: None
  • onClear
    • arguments: None
    • return: None
  • onClearSuggestion
    • arguments: None
    • return: None
  • renderSuggestionItem - Render the suggestion item component
    • arguments:
      • item (object) - Suggestion item
      • onPressSelectAndSubmit - Callback to indicate which item was selected and then submitted
        • arguments:
          • item - Selected item
        • return: None
      • onPressSelect - Callback to indicate which item was selected
        • arguments:
          • item - Selected item
        • return: None
    • return - Component

Text field internal view compositions diagram

Text field animated internal view composition reference names. See Animation API for details:

  • animated-container-view
  • animated-box-view
  • animated-label-text
  • animated-underline-focused-view
  • animated-content-left-room-view
  • animated-content-right-room-view
  • animated-selection-view

Text field available actions:

  • clear
  • blur
  • focus
  • show-selection
  • hide-selection

Text field methods & callbacks:

  • animate - See Animation API for details
  • isValidated - Check if text input's value is validated
    • arguments: None
    • return: bool
  • isSelectionVisible - Check if selectable pull-up view is visible
    • arguments: None
    • return: bool
  • isFocused - Check if text input's value is focused
    • arguments: None
    • return: bool
  • showSelection - Show selectable pull-up view if selectableValues is provided
    • arguments: None
    • return: None
  • hideSelection - Hide selectable pull-up view if selectableValues is provided
    • arguments: None
    • return: None
  • focus - Focus text input
    • arguments: None
    • return: None
  • blur - Blur text input
    • arguments: None
    • return: None
  • clear - Clear text input
    • arguments: None
    • return: None
  • onValidate - Calls after text field's text input onChangeText or onEndEditing. See default onValidate
    • arguments:
      • value (string) - Current text value
      • inputType
    • return: object - Expects return object with a validate boolean property and a status string property
  • onReformat - Calls after text field's text input onChangeText. See default onReformat
    • arguments:
      • value (string) - Current text value
    • return: string - Return reformatted value
  • onEditing - Calls when text field's text input onChangeText
    • arguments:
      • value (string) - Current text value
    • return: None
  • onDoneEdit - Calls when a value in text field's selectable pull-up view is selected or after text field's text input onSubmitEditing
    • arguments:
      • value (string) - Current text value
    • return: None
  • onSelect - Calls when a value in text field's selectable pull-up view is selected
    • arguments:
      • value (string) - Selected value
    • return: None
  • onFocus
    • arguments: None
    • return: None
  • onBlur
    • arguments: None
    • return: None
  • onHideSelection
    • arguments: None
    • return: None
  • onShowSelection
    • arguments: None
    • return: None
  • onClear
    • arguments: None
    • return: None
  • renderSelectableItem - Render an item from a list of selectable items and renders them into the list in pull-up selection view.See below for examples

Search Field Examples

Search field with suggestion using Google's autocompletes

<SearchField
    hint = 'Search...'
    pinnedSuggestionValues = {[ `Hypertoxin`, `React Native` ]}
    onGetAutocompletionValues = {async (text) => {
        if (text) {
            const response = await fetch(`http://suggestqueries.google.com/complete/search?client=firefox&q=${text}`, {
                method: `get`
            });
            const data = await response.json();
            return data[1].slice(0, 6);
        }
        return [];
    }}
    renderSuggestionItem = {(item, onPressSelectAndSubmit, onPressSelect) => {
        // item = {
        //     value: ...             String value of the suggestion item
        //     suggestionType: ..     String value to indicate the suggestion types: pin, autocompletion, or history
        // }
        // onPressSelect              Callback to indicate which item was selected
        // onPressSelectAndSubmit     Callback to indicate which item was selected and then submitted
        return (
            <AreaButton shade = { shade } overlay = 'transparent' size = 'small' onPress = {() => onPressSelectAndSubmit(item)}>
                <ColumnLayout room = 'content-left' roomAlignment = 'center'
                >
                    <IconImage
                        room = 'content-left'
                        source = {(() => {
                            switch (item.suggestionType) { // eslint-disable-line
                            case `pin`:
                                return `star`;
                            case `history`:
                                return `history`;
                            case `autocompletion`:
                                return `search`;
                            default:
                                return null;
                            }
                        })()}
                        margin = {{ left: 10 }}
                    />
                    <InfoText room = 'content-right' indentation = { 10 }>{ item.value }</InfoText>
                </ColumnLayout>
                {
                    item.suggestionType !== `pin` ?
                    <FlatButton room = 'content-right' overlay = 'transparent' corner = 'circular' onPress = {() => onPressSelect(item)} margin = {{ right: 10 }}>
                        <IconImage room = 'content-middle' source = 'recall' size = 'small' />
                    </FlatButton> : null
                }
            </AreaButton>
        );
    }}
    style = {{
        suggestion: {
            left: -10
        }
    }}
>
    <FlatButton room = 'content-left' action = 'expand' overlay = 'transparent' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'search' />
    </FlatButton>
    <FlatButton room = 'content-left' action = 'collapse' overlay = 'transparent' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'go-back' />
    </FlatButton>
    <FlatButton room = 'content-right' action = 'clear' overlay = 'transparent' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
</SearchField>

Text Field Examples

Using Text field to create simple logins

<TextField label = 'EMAIL' hint = 'user@gmail.com' inputType = 'email-address' >
    <IconImage room = 'content-left' source = 'email' />
    <FlatButton room = 'content-right' overlay = 'transparent' action = 'clear' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
</TextField>
<TextField secured = { true } label = 'PASSWORD' >
    <IconImage room = 'content-left' source = 'lock' />
    <FlatButton room = 'content-right' overlay = 'transparent' action = 'clear' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
</TextField>

Using Text field to create a simple note

<TextField label = 'ADD NOTE' charLimit = { 128 } lineLimit = { 5 }>
    <FlatButton overlay = 'transparent' room = 'content-right' action = 'clear' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
</TextField>

Text field with reformatting and validation

<TextField
    label = 'PHONE NUMBER'
    inputType = 'phone-pad'
    charLimit = { 14 }
    onValidate = {(value, inputType) => {
        let regex;
        let validated = true;
        let status = ``;

        if (value !== `` && inputType === `phone-pad`) {
            regex = /^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/;

            validated = regex.test(value);
            status = validated ? `` : `Phone number is invalid`;
        }
        return {
            validated,
            status
        };
    }}
    onReformat = {(value) => {
        return value.split(``).filter((char) => char !== `-` && char !== `(` && char !== `)` && char !== ` `).map((char, index) => {
            if (index === 0) {
                return `(${char}`;
            }
            if (index === 2) {
                return `${char}) `;
            }
            if (index === 5) {
                return `${char}-`;
            }
            return char;
        }).join(``);
    }}
>
    <FlatButton room = 'content-right' overlay = 'transparent' action = 'clear' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
</TextField>

Text field with selectable pull-up view

<TextField
    label = 'LABEL'
    selectableValues = {[ `VALUE A`, `VALUE B`, `VALUE C` ]}
    renderSelectableItem = {(item, onPressSelect) => {
        // item = {
        //     value: ...       String value of the selectable item
        //     selected: ..     Boolean to indicates that the item is selected or not
        // }
        // onPressSelect        Callback to indicate which item was selected
        return (
            <AreaButton
                shade = { shade }
                overlay = 'transparent'
                size = 'small'
                onPress = {() => onPressSelect(item)}
                contentRightRoomAlignment = 'start'
                margin = {{
                    horizontal: 10
                }}
            >
                <InfoText room = 'content-left' indentation = { 10 }>{ item.value }</InfoText>
                {
                    item.selected ? <IconImage room = 'content-right' source = 'check' /> : null
                }
            </AreaButton>
        );
    }}

    <FlatButton room = 'content-right' overlay = 'transparent' action = 'clear' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
    <FlatButton room = 'content-right' overlay = 'transparent' action = 'show-selection' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'collapse' />
    </FlatButton>
    <FlatButton room = 'content-right' overlay = 'transparent' action = 'hide-selection' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'expand' />
    </FlatButton>
</TextField>

Text Components

Text components with default theme and San-Francisco font

Text components with bubble theme and Arial font

Text components with coffee theme and Futura font

Hypertoxin has five text components, CaptionText, InfoText, SubtitleText, TitleText, HeadlineText

Text (Caption, Info, Subtitle, Title, & Headline) Properties

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet text's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media, activity-indicator. See Using Room Property section for details
shadestring, objectthemedSet text shade theme, can be themed, light, or dark
sizestringthemedSet text font's size which can be one of themed, small, normal, large
alignmentstringleftSet text's alignment which can be one of left, center, right
decorationstringnoneSet text's decoration which can be one of none, underline, line-through
fontstringthemedSet text font's family which can be themed or font family name
uppercasedbooleanFalseForce uppercased text
lowercasedbooleanFalseForce lowercased text
indentationnumber0Set text indentation
colorstringthemedSet text's color style. Can be hex string, default color name, or themed color name
styleobjectNoneStandard React Native text style properties

Note: themed property indicates using values defined by the global theme provider.

Text (caption, info, subtitle, title, & headline) animated internal view composition reference names. See Animation API for details:

  • animated-text

Text (caption, info, subtitle, title, & headline) methods & callbacks:

Text (Caption, Info, Subtitle, Title, & Headline) Examples

<HeadlineText size = 'large' color = 'default' > Headline Large </HeadlineText>
<HeadlineText size = 'normal' color = 'primary' > Headline Normal </HeadlineText>
<HeadlineText size = 'small' color = 'secondary' > Headline Small </HeadlineText>
<TitleText size = 'large' color = 'default' > Headline Large </TitleText>
<TitleText size = 'normal' color = 'primary' > Headline Normal </TitleText>
<TitleText size = 'small' color = 'secondary' > Headline Small </TitleText>
<SubtitleText size = 'large' color = 'default' > Headline Large </SubtitleText>
<SubtitleText size = 'normal' color = 'primary' > Headline Normal </SubtitleText>
<SubtitleText size = 'small' color = 'secondary' > Headline Small </SubtitleText>
<InfoText size = 'large' color = 'default' > Headline Large </InfoText>
<InfoText size = 'normal' color = 'primary' > Headline Normal </InfoText>
<InfoText size = 'small' color = 'secondary' > Headline Small </InfoText>
<CaptionText size = 'large' color = 'default' > Headline Large </CaptionText>
<CaptionText size = 'normal' color = 'primary' > Headline Normal </CaptionText>
<CaptionText size = 'small' color = 'secondary' > Headline Small </CaptionText>

Screen Components

Hypertoxin has two screen components, BodyScreen, HeaderScreen

Header Screen Properties

Use header screen to create navigation top bar.

PropTypeDefaultDescription
shadestring, objectthemedSet header screen's shade theme, can be themed, light, or dark
overlaystringthemedSet header screen's overlay style which can be one of themed, opaque, translucent, translucent-outline, transparent, transparent-outline
sizestringthemedSet header screen's size which can be one of themed, small, normal, large
dropShadowedboolean, stringthemedEnable header screen's drop shadow
coverImageSourceReact Native image sourceNoneHeader screen's background cover image source
labelstringNoneSet header screen's label
styleobjectNoneHeader screen style is an object with the following properties: container: {...}, status: {...}, navigation: {...}, contentLeftRoom: {...}, contentMiddleRoom: {...}, contentRightRoom: {...}, mediaRoom: {...}, label: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object
onHideNavigationfunctionNoneCalls when header screen's navigator view becomes hidden
onShowNavigationfunctionNoneCalls when header screen's navigator view becomes visible
onHideMediafunctionNoneCalls when header screen's media view becomes hidden
onShowMediafunctionNoneCalls when header screen's media view becomes visible

Body Screen Properties

PropTypeDefaultDescription
shadestring, objectthemedSet body screen's shade theme, can be themed, light, or dark
overlaystringthemedSet body screen's overlay style which can be one of themed, opaque, translucent, transparent
colorstringthemedSet body screen's color style. Can be hex string, default color name, or themed color name
paddingstring, number, objectNoneSet body screen's padding styles. As a number, the padding is equally set around the screen. Set padding as an object for more control. For example padding = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
coverImageSourceReact Native image sourceNoneBody screen's background cover image source
contentTopRoomAlignmentstringnoneChild component top room property, which can be one of none, start, center, end, or stretch
contentMiddleRoomAlignmentstringnoneChild component middle room property, which can be one of none, start, center, end, or stretch
contentBottomRoomAlignmentstringnoneChild component bottom room property, which can be one of none, start, center, end, or stretch
scrollablebooleanFalseEnable to allow scrolling
keyboardAvoidingbooleanFalseEnable to allow keyboard avoiding. Works best with scrollable = true
styleobjectNoneBody screen style is an object with the following properties: container: {...}, contentTopRoom: {...}, contentMiddleRoom: {...}, contentBottomRoom: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object
onScrollfunctionNoneCalls when scrolling with scrollable = true

Note: themed property indicates using values defined by the global theme provider.

By default, header screen component passes shade, size, and color properties down to it child components and at the same time set margin = { 0 } and indentation = { 0 } properties onto its children. By default, body screen component passes shade property down to it child components. This behavior can be override by child components with the exclusions property. See Using Exclusions Property section for details.

Header screen internal view compositions diagram

Header screen animated internal view composition reference names. See Animation API for details:

  • animated-container-view
  • animated-navigation-view
  • animated-content-left-room-view
  • animated-content-middle-room-view
  • animated-content-right-room-view
  • animated-media-room-view

Header screen available actions:

  • show-media
  • hide-media

Header screen methods & callbacks:

  • animate - See Animation API for details
  • isNavigationVisible - Check if header screen's navigation view is visible
    • arguments: None
    • return: bool
  • isMediaVisible - Check if header screen's media view is visible
    • arguments: None
    • return: bool
  • hideNavigation
    • arguments:
      • animation (object) - Hide animation object. See Animation API for details
    • return: None
  • showNavigation
    • arguments:
      • animation (object) - Hide animation object. See Animation API for details
    • return: None
  • showMedia
    • arguments:
      • animation (object) - Hide animation object. See Animation API for details
    • return: None
  • hideMedia
    • arguments:
      • animation (object) - Hide animation object. See Animation API for details
    • return: None
  • onHideNavigation - Calls when header screen's navigator view becomes hidden
    • arguments: None
    • return: None
  • onShowNavigation - Calls when header screen's navigator view becomes visible
    • arguments: None
    • return: None
  • onShowMedia - Calls when header screen's media view becomes hidden
    • arguments: None
    • return: None
  • onHideMedia - Calls when header screen's media view becomes visible
    • arguments: None
    • return: None

Body screen internal view compositions diagram

Body screen animated internal view composition reference names. See Animation API for details:

  • animated-content-top-room-view
  • animated-content-middle-room-view
  • animated-content-bottom-room-view

Body screen methods & callbacks:

  • animate - See Animation API for details
  • onScroll - Calls when scrolling with scrollable = true
    • arguments:
      • scrollEvent (object): Scroll event object with the following schema:
        • direction (number): 1 = scrolling up, 0 = no scrolling, -1 = scrolling down
    • return: None

Header Screen Examples

Header screen in 3 available sizes with default theme

<HeaderScreen
    // size = `small`
    size = `normal`
    // size = `large`
    label = 'HEADER SCREEN'
>
    <FlatButton room = 'content-left' overlay = 'transparent' corner = 'circular' onPress = {() => navigation.toggleDrawer()}>
        <IconImage room = 'content-middle' source = 'menu' />
    </FlatButton>
</HeaderScreen>

Header screen with media

<HeaderScreen shade = 'light' label = 'HEADER SCREEN' >
    <FlatButton room = 'content-left' overlay = 'transparent' corner = 'circular' onPress = {() => navigation.toggleDrawer()}>
        <IconImage room = 'content-middle' source = 'menu' />
    </FlatButton>
    <ColumnLayout room = 'media' overlay = 'opaque' roomAlignment = 'center' corner = 'sharp' >
        <HeadlineText room = 'content-left' shade = 'light' size = 'small' indentation = { 10 }> Media section </HeadlineText>
        <FlatButton room = 'content-right' overlay = 'transparent-outline' corner = 'circular' size = 'small' label = 'BUTTON A' color = { Theme.color.palette.teal } margin = { 10 }/>
        <FlatButton room = 'content-right' overlay = 'transparent-outline' corner = 'circular' size = 'small' label = 'BUTTON B' color = { Theme.color.palette.teal } margin = { 10 }/>
    </ColumnLayout>
</HeaderScreen>

Header screen with icon button and search field

<HeaderScreen shade = 'light' >
    <FlatButton room = 'content-left' overlay = 'transparent' corner = 'circular' onPress = {() => navigation.toggleDrawer()} >
        <IconImage room = 'content-middle' source = 'menu' />
    </FlatButton>
    <SearchField room = 'content-middle' exclusions = {[ `size` ]} size = 'small' hint = 'Search...' dropShadowed = { false } initiallyCollapsed = { false } suggestive = { false }>
        <FlatButton room = 'content-left' overlay = 'transparent' corner = 'circular' >
            <IconImage room = 'content-middle' source = 'search' />
        </FlatButton>
        <FlatButton room = 'content-right' action = 'clear' overlay = 'transparent' corner = 'circular' >
            <IconImage room = 'content-middle' source = 'cancel' />
        </FlatButton>
    </SearchField>
    <FlatButton room = 'content-right' overlay = 'transparent' corner = 'circular' >
        <IconImage room = 'content-middle' size = 'large' source = 'info' />
    </FlatButton>
</HeaderScreen>

An example of user profile header screen

<HeaderScreen shade = 'light' overlay = 'transparent' coverImageSource = { require(`../../../assets/images/geometric-wallpaper.png`) } label = 'PROFILE' >
    <FlatButton room = 'content-left' overlay = 'transparent' corner = 'circular' onPress = {() => navigation.toggleDrawer()}>
        <IconImage room = 'content-middle' source = 'menu' />
    </FlatButton>
    <ColumnLayout room = 'media' overlay = 'transparent' roomAlignment = 'center' corner = 'sharp' >
        <AvatarImage room = 'content-left' source = { require(`../../../assets/images/fox.png`) } size = 'large' dropShadowed = { false }
            margin = {{
                vertical: 5,
                right: 10
            }}
        />
        <RowLayout room = 'content-left' overlay = 'transparent'
            margin = {{
                vertical: 5,
                right: 10
            }}
        >
            <TitleText room = 'content-top' shade = 'light' size = 'small' > Mr. Fantastic Fox </TitleText>
            <SubtitleText room = 'content-middle' > A cool fox! </SubtitleText>
        </RowLayout>
        <FlatButton room = 'content-right' overlay = 'transparent-outline' corner = 'circular' size = 'small' label = 'LIKE' color = { Theme.color.palette.teal }
            margin = {{
                right: 10,
                vertical: 5
            }}
        />
    </ColumnLayout>
    <FlatButton room = 'content-right' overlay = 'transparent' corner = 'circular' >
        <IconImage room = 'content-middle' size = 'large' source = 'info' />
    </FlatButton>
</HeaderScreen>

Body Screen Examples

Below is an example of a basic app view that consists of a header and body screen where the render function returns an array of header and body screen component.

render () {
    return ([
        <HeaderScreen key = 'header-screen' label = 'MY APP' />,
        <BodyScreen key = 'body-screen'>
            <HeadlineText room = 'content-top' size = 'large'> Hello World! </HeadlineText>
        </BodyScreen>
    ]);
}

Another example where you want the header screen to minimize (hide navigation view) when the body screen is scrolling down and maximize when scrolling up. This is achieved calling hideNavigation & showNavigation functions inside the onScroll callback of body screen component. onScroll provides scrolling direction that determines when to call hideNavigation or showNavigation function.

render () {
    return ([
        <HeaderScreen key = 'header-screen' label = 'MY APP'
            ref = {(componentRef) => {
                this.headerScreenRef = componentRef;
            }}
        />,
        <BodyScreen key = 'body-screen' scrollable = { true }
            onScroll = {({
                direction
            }) => {
                if (direction === -1 && this.headerScreenRef.isNavigationVisible()) {
                    this.headerScreenRef.hideNavigation();
                }
                if (direction === 1 && !this.headerScreenRef.isNavigationVisible()) {
                    this.headerScreenRef.showNavigation();
                }
            }}
        >
            <HeadlineText room = 'content-top' size = 'large'> Hello World! </HeadlineText>
        </BodyScreen>
    ]);
}

Layout Components

Hypertoxin has two layout components, RowLayout, ColumnLayout

Row Layout Properties

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet row layout's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
shadestring, objectthemedSet row layout's shade theme, can be themed, light, or dark
overlaystringthemedSet row layout's overlay style which can be one of themed, opaque, translucent, translucent-outline, transparent, transparent-outline
cornerstring, number, objectthemedSet row layout's corner styles. As a number, border radius = corner. Set corner as an object for more control. For example corner = { topLeft: 0.1, topRight: 0.1, bottomLeft: 0.1, bottomRight: 0.1}
paddingstring, number, objectNoneSet row layout's padding styles. As a number, the padding is equally set around the layout. Set padding as an object for more control. For example padding = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
marginstring, number, objectNoneSet row layout's margin styles. As a number, the margin is equally set around the layout. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
colorstringthemedSet row layout's color style. Can be hex string, default color name, or themed color name
dropShadowedboolean, stringthemedEnable row layout's drop shadow
roomAlignmentstringnoneComponent self's room property with respect to parent component's room, which can be one of none, start, center, end, or stretch
contentTopRoomAlignmentstringnoneChild component top room property, which can be one of none, start, center, end, or stretch
contentMiddleRoomAlignmentstringnoneChild component middle room property, which can be one of none, start, center, end, or stretch
contentBottomRoomAlignmentstringnoneChild component bottom room property, which can be one of none, start, center, end, or stretch
scrollablebooleanFalseEnable to allow scrolling
styleobjectNoneRow layout style is an object with the following properties: container: {...}, contentTopRoom: {...}, contentMiddleRoom: {...}, contentBottomRoom: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object
onScrollfunctionNoneCalls when scrolling with scrollable = true. Takes scroll direction object as argument

Column Layout Properties

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet column layout's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
shadestring, objectthemedSet column layout's shade theme, can be themed, light, or dark
overlaystringthemedSet column layout's overlay style which can be one of themed, opaque, translucent, translucent-outline, transparent, transparent-outline
cornerstring, number, objectthemedSet column layout's corner styles. As a number, border radius = corner. Set corner as an object for more control. For example corner = { topLeft: 0.1, topRight: 0.1, bottomLeft: 0.1, bottomRight: 0.1}
paddingstring, number, objectNoneSet column layout's padding styles. As a number, the padding is equally set around the layout. Set padding as an object for more control. For example padding = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
marginstring, number, objectNoneSet column layout's margin styles. As a number, the margin is equally set around the layout. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
colorstringthemedSet column layout's color style. Can be hex string, default color name, or themed color name
dropShadowedboolean, stringthemedEnable column layout's drop shadow
roomAlignmentstringnoneComponent self's room property with respect to parent component's room, which can be one of none, start, center, end, or stretch
contentLeftRoomAlignmentstringnoneChild component left room property, which can be one of none, start, center, end, or stretch
contentMiddleRoomAlignmentstringnoneChild component middle room property, which can be one of none, start, center, end, or stretch
contentRightRoomAlignmentstringnoneChild component right room property, which can be one of none, start, center, end, or stretch
scrollablebooleanFalseEnable to allow scrolling
styleobjectNoneColumn layout style is an object with the following properties: container: {...}, contentLeftRoom: {...}, contentMiddleRoom: {...}, contentRightRoom: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object
onScrollfunctionNoneCalls when scrolling with scrollable = true. Takes scroll direction object as argument

Note: themed property indicates using values defined by the global theme provider.

By default, row and column layout components pass shade property down to their child components. This behavior can be override by child components with the exclusions property. See Using Exclusions Property section for details.

Row layout internal view compositions diagram

Row layout animated internal view composition reference names. See Animation API for details:

  • animated-container-view
  • animated-content-top-room-view
  • animated-content-middle-room-view
  • animated-content-bottom-room-view

Row layout methods & callbacks:

  • animate - See Animation API for details
  • onScroll - Calls when scrolling with scrollable = true
    • arguments:
      • scrollEvent (object): Scroll event object with the following schema:
        • direction (number): 1 = scrolling up, 0 = no scrolling, -1 = scrolling down
    • return: None

Column layout internal view compositions diagram

Column layout animated internal view composition reference names. See Animation API for details:

  • animated-container-view
  • animated-content-left-room-view
  • animated-content-middle-room-view
  • animated-content-right-room-view

Column layout Methods & Callbacks:

  • animate - See Animation API for details
  • onScroll - Calls when scrolling with scrollable = true
    • arguments:
      • scrollEvent (object): Scroll event object with the following schema:
        • direction (number): 1 = scrolling up, 0 = no scrolling, -1 = scrolling down
    • return: None

Image Components

Hypertoxin has three image components, AvatarImage, IconImage, and CoverImage

Avatar Image Properties

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet avatar image's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media, activity-indicator. See Using Room Property section for details
shadestring, objectthemedSet avatar image's shade theme, can be themed, light, or dark
overlaystringthemedSet avatar image's overlay style which can be one of themed, opaque, translucent, translucent-outline, transparent, transparent-outline
sizestringthemedSet avatar image's size which can be one of themed, small, normal, large
marginstring, number, objectNoneSet avatar image's margin styles. As a number, the margin is equally set around avatar image container. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
dropShadowedboolean, stringthemedEnable avatar image drop shadow
colorstringthemedSet avatar's color style. Can be hex string, default color name, or themed color name
sourceReact Native image sourceNoneImage source
defaultSourceReact Native image sourceNoneImage source
styleobjectNoneStandard React Native style properties. Changes to these properties will override the global theme. See default style object

Icon Image Properties

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet icon image's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media, activity-indicator. See Using Room Property section for details
shadestring, objectthemedSet icon image's shade theme, can be themed, light, or dark
sizestringthemedSet icon image's size which can be one of themed, small, normal, large
marginstring, number, objectNoneSet icon image's margin styles. As a number, the margin is equally set around icon image container. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
dropShadowedboolean, stringthemedEnable icon image drop shadow
colorstringthemedSet icon image's color style. Can be hex string, default color name, or themed color name
sourceReact Native image sourceNoneImage source or icon name in provided preset. See Theme Customization for details
defaultSourceReact Native image sourceNoneImage source or icon name in provided preset. See Theme Customization for details
styleobjectNoneStandard React Native style properties. Changes to these properties will override the global theme. See default style object

Cover Image Properties

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet cover image's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media, activity-indicator. See Using Room Property section for details
shadestring, objectthemedSet cover image's shade theme, can be themed, light, or dark
marginstring, number, objectNoneSet cover image's margin styles. As a number, the margin is equally set around icon image container. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
widthnumberNoneSet cover image's width
heightnumberNoneSet cover image's height
cornerstring, number, objectthemedSet cover image's corner styles. As a number, border radius = corner. Set corner as an object for more control. For example corner = { topLeft: 0.1, topRight: 0.1, bottomLeft: 0.1, bottomRight: 0.1}
dropShadowedboolean, stringthemedEnable cover image drop shadow
resizeModestringcontainReact Native image resize property
sourceReact Native image sourceNoneImage source
defaultSourceReact Native image sourceNoneImage source
styleobjectNoneStandard React Native style properties. Changes to these properties will override the global theme. See default style object

Note: themed property indicates using values defined by the global theme provider.

Avatar Image Examples

Avatar images in 3 available sizes with colors defined by global theme

<AvatarImage source = { require(`../../../assets/images/fox.png`) } size = 'small' color = 'default' dropShadowed = { true }/>
<AvatarImage source = { require(`../../../assets/images/fox.png`) } size = 'normal' color = 'primary' dropShadowed = { true }/>
<AvatarImage source = { require(`../../../assets/images/fox.png`) } size = 'large' color = 'secondary' dropShadowed = { true }/>

Same but with border outlines

<AvatarImage source = { require(`../../../assets/images/fox.png`) } overlay = 'transparent-outline' size = 'small' color = 'default' />
<AvatarImage source = { require(`../../../assets/images/fox.png`) } overlay = 'transparent-outline' size = 'normal' color = 'primary' />
<AvatarImage source = { require(`../../../assets/images/fox.png`) } overlay = 'transparent-outline' size = 'large' color = 'secondary' />

Icon Image Examples

Some icon images with various colors

<IconImage source = 'socialShare' color = 'default' dropShadowed = { false } margin = { 10 }/>
<IconImage source = 'facebook' color = 'default' dropShadowed = { false } margin = { 10 }/>
<IconImage source = 'twitter' color = 'primary' dropShadowed = { false } margin = { 10 }/>
<IconImage source = 'googlePlus' color = 'primary' dropShadowed = { false } margin = { 10 }/>
<IconImage source = 'github' color = 'secondary' dropShadowed = { false } margin = { 10 }/>
<IconImage source = 'home' color = 'secondary' dropShadowed = { false } margin = { 10 }/>
<IconImage source = 'profile' color = 'accent' dropShadowed = { false } margin = { 10 }/>
<IconImage source = 'ellipsis' color = 'accent' dropShadowed = { false } margin = { 10 }/>

Divider Components

Hypertoxin has two divider components, HorizontalDivider, VeriticalDivider

Divider (Horizontal and Vertical) Properties

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet divider's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
shadestring, objectthemedSet divider shade theme, can be themed, light, or dark
thicknessnumber, stringthemedSet divider line thickness
edgeToEdgebooleanfalseForce divider line to the edges of screen
marginstring, number, objectNoneSet text field's margin styles. As a number, the margin is equally set around text field container. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
colorstringthemedSet divider's color style. Can be hex string, default color name, or themed color name
styleobjectNoneStandard React Native view style properties

Note: themed property indicates using values defined by the global theme provider.

Using Room Property

Rooms are predefined child views of the component and because Hypertoxin is a themed component library, all layouts of child views with any component are retricted. And room property helps enforce this restriction. Another reason for this is to keep JSX code short and concise while maintaining a consistent theme for all buttons globally. For example, JSX code for a flat button with left and right icons using room property.

<FlatButton overlay = 'opaque' size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-left' source = 'home' />
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>

JSX code for a flat button with left and right icons without using room property.

<FlatButton overlay = 'opaque' size = 'small' label = 'SMALL' color = 'primary' >
    <View style = {{
        flexDirection: `row`,
        alignItems: `center`,
        justifyContent: `center`,
        backgroundColor: `transparent`
    }}>
        <IconImage source = 'home' />
    </View>
    <View style = {{
        flexDirection: `row`,
        alignItems: `center`,
        justifyContent: `center`,
        backgroundColor: `transparent`
    }}>
        <IconImage source = 'profile' />
    </View>
</FlatButton>

Using Action Property

This property is design as a short cut for attaching a specifics callback to the component. It help keeping the code less clutter. For example, text field component has a clear method and we want to connect onPress callback of the button component to the clear method. Without using action property, you would need to use reference like below.

<TextField
    ref = {(componentRef) => {
        this.emailTextFieldRef = componentRef;
    }}
    label = 'EMAIL' hint = 'user@gmail.com' inputType = 'email-address'
>
    <IconImage room = 'content-left' source = 'email' />
    <FlatButton room = 'content-right' overlay = 'transparent' corner = 'circular'
        onPress = {() => this.emailTextFieldRef.clear()}
    >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
</TextField>

But with action property, you only need to assign the action clear of the text field component to the child button component's action property. This make the JSX code a bit cleaner and shorter. See below.

<TextField label = 'EMAIL' hint = 'user@gmail.com' inputType = 'email-address' >
    <IconImage room = 'content-left' source = 'email' />
    <FlatButton room = 'content-right' overlay = 'transparent' action = 'clear' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
</TextField>

Using Exclusions Property

By default, parent component would pass down theme properties (size, color, etc) to child components. For example, if you want the icon image of the normal size button to be small, you must include exclusions = {[ size ]} so that the property size = 'small' of icon image component is not overwritten by the parent flat button component.

<FlatButton overlay = 'opaque' size = 'normal' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-left' exclusions = {[ `size` ]} size = 'small' source = 'home' />
</FlatButton>

Animation API

All components, except for HorizontalDivider, VeriticalDivider, and CoverImage, have an animate method. Internally, Hypertoxin uses react-native-animatable library for animation transition.

Method animate takes an object as argument with the following default property values.

  • arguments:
    • animation (object) - Animation object that has the following schema:
      • refName (string) - Animated reference name of cild component composite
      • transitions (array) - An array of transition object with the following schema:
        • to (object) - Transition to object
        • from (object) - Transition from object
        • option (object) - Transition option with the following schema:
          • duration (number) - Transition duration (ms)
          • delay (number) - Transition delay (ms)
          • easing (string) - Transition easing. See react-native-animatable docs for all available easing types.
        • onTransitionBegin (function) - Callback when a transition begins. Takes transition index as argument
        • onTransitionEnd (function) - Callback when a transition ends. Takes transition index as argument
        • onAnimationBegin (function) - Callback when an animation begins (before the first transition in sequence started)
        • onAnimationEnd (function) - Callback when an animation ends (after the last transition in sequence ended)
  • return: Promise

For a more elaborate animation sequence transitions, use onTransitionBegin, onTransitionEnd, onAnimationBegin, and onAnimationEnd callbacks to chain multiple animations together. The method also returns a promise that resolve between the transitions and animations which can be use if callback is not preferred.

Now to see how use the animate method, let's do a simple send mail button animation shown here below.

The animation sequences of this button are onPress -> fade out SEND label and email icon -> fade in activity indicator and button in busy mode -> fade out activity indicator -> fade in SENT label with different color and a check icon to the left. First let's create a raised button inside some other parent component. The parent component with track the raised button ref with raisedButtonRef, and also have two states, mailSent and sendingMail. Property color switches value that depends on the state mailSent. Property label

<RaisedButton
    ref = {(componentRef) => {
        component.raisedButtonRef = componentRef;
    }}
    busy = { sendingMail }
    rippled = { false }
    room = 'content-right'
    color = { mailSent ? `secondary` : `accent` }
    label = { mailSent ? `SENT` : sendingMail ? `` : `SEND` }
    margin = { 10 }
>
    <ActivityIndicator
        room = 'activity-indicator'
        size = 'small'
        color = { Theme.color.palette.pink }
    />
    <IconImage
        room = 'content-left'
        source = { !mailSent ? `email` : `check` }
    />
</RaisedButton>

Next, defines the onPress button that triggers the animation sequences.

onPress = {() => {
    if (!mailSent) {
        // Fade out the left email icon
        component.raisedButtonRef.animate({
            refName: `animated-content-left-room-view`,
            transitions: [{
                from: { opacity: 1 },
                to: { opacity: 0 },
                option: { duration: 300 }
            }]
        });
        // Fade out the center label
        component.raisedButtonRef.animate({
            refName: `animated-content-middle-room-view`,
            transitions: [{
                from: { opacity: 1 },
                to: { opacity: 0 },
                option: { duration: 300 }
            }],
            onAnimationEnd: () => {
                component.setState(() => { sendingMail: true }, () => {
                    // Let the activity indicator runs for 2s. Using setTimeout to emulate waiting for server response.
                    setTimeout(() => {
                        component.setState(() => { mailSent: true, sendingMail: false }, () => {
                            // Fade in the check icon
                            component.raisedButton1Ref.animate({
                                refName: `animated-content-left-room-view`,
                                transitions: [{
                                    from: { opacity: 0 },
                                    to: { opacity: 1 },
                                    option: { duration: 300 }
                                }]
                            });
                            // Fade in the center label
                            component.raisedButton1Ref.animate({
                                refName: `animated-content-middle-room-view`,
                                transitions: [{
                                    from: { opacity: 0 },
                                    to: { opacity: 1 },
                                    option: { duration: 300 }
                                }]
                            });
                        });
                    }, 2000);
                });
            }
        });
    }
}}

Below are a few more examples of animations and code.

An example of animation sequences of payment submit button. Source

An example of animation sequences of an expanding FAB menu. Source

An example of animation sequences for popup menu. Source

An example of animation sequences for header screen entry & exit. Source

Theme Customization

Hypertoxin global theme is highly customizable and one of the way to make your own customized theme is to modify the default theme.

Default global theme object schema:

For example, import the Theme object from hyperflow as DefaultTheme.

import { ThemeContext, Theme as DefaultTheme } from 'hyperflow';

Next modify the DefaultTheme object using standard object destructuring method. For example, adding a customized global button corner theme called semi-sharp

const MyTheme = {
    ...DefaultTheme,
    button: {
        ...DefaultTheme.button,
        flat: {
            ...DefaultTheme.button.flat,
            corner: `semi-round`
        },
        raised: {
            ...DefaultTheme.button.raised,
            corner: `semi-round`
        },
        corner: {
            ...DefaultTheme.button.corner,
            flat: {
                ...DefaultTheme.button.corner.flat,
                semiRound: 0.1
            },
            raised: {
                ...DefaultTheme.button.corner.raised,
                semiRound: 0.1
            }

        }
    }
};

Or using lodash library merge function.

const MyTheme = _.merge(DefaultTheme, {
    button: {
        flat: {
            corner: `semi-round`
        },
        raised: {
            corner: `semi-round`
        },
        corner: {
            flat: {
                semiRound: 0.1
            },
            raised: {
                semiRound: 0.1
            }

        }
    }
});

And to apply custom theme, simply set the top level ThemeContext provider value of your app.

<ThemeContext.Provider value = {{ MyTheme }}>
    <App/>
</ThemeContext.Provider>

To setup custom icon preset, simply import your icon images to icon property of your custom theme object like so below.

MyTheme.icon = {
    home: require(`my_home_icon.png`)
    profile: require(`my_profile_icon.png`)
}

And to use your custom icon, just set the source property of icon image component to the name of the icon. This behavior is only applied to icon image component.

<IconImage source = 'home' />
<IconImage source = 'profile' />

Hypertoxin demo has three custom theme examples that you can take a look for references. Bubble Theme, Coffee Theme, and Wire Theme

Todo:

  • Use React Hooks
  • Add Switcher (Button group) component
  • Add expand/collapse actions to row and column layout components
  • Add proper testings
  • More mockup app examples

Change Log:

License

Hyperflow is MIT licensed.

Keywords

hypertoxin

FAQs

Package last updated on 21 Aug 2019

Related posts