1.2.10 • Published 5 years ago

@blueeast/bluerain-plugin-responsive-components v1.2.10

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

Bluerain Responsive Components Plugin

This plugin adds responsive components in BlueRainContext. Wrapping page or view in ResponsiveLayout makes it responsive.https://blueeast.gitbook.io/bluerain-plugin-responsive-components

🌏 Web🖥 Electron📱 React Native
✔️✔️TBD

Installation

Run the following command in the plugin directoy:

yarn add  @blueeast/bluerain-plugin-responsive-components

Example

import BR from '@blueeast/bluerain-os';

<BR.Components.ResponsiveLayout default={DesktopComponent}  {...props} />  
  <BR.Components.Container  {...props}>
    <BR.Components.Row  {...props}>
       <BR.Components.Column sm={12} md={6} xs={9} lg={2} xl={2}  {...props}>
      </BR.Components.Column>
    </BR.Components.Row>
  </BR.Components.Container>
</BR.Components.ResponsiveLayout>

Components

This plugin registers following components in BlueRain context:

Column

Props

NameDefaultTypeDescription
xsnumberThe width of the column on extra small screen
xsOffsetnumberThe number of columns to offset on extra small screen
xsHiddenbooleanHide this column on extra small screen
smnumberThe width of the column on small screen.
smOffsetnumberThe number of columns to offset on small screen.
smHiddenbooleanHide this column on small screen.
mdnumberThe width of the column on medium screen.
mdOffsetnumberThe number of columns to offset on medium screen.
mdHiddenbooleanHide this column on medium screen.
lgnumberThe width of the column on large screen.
mdHiddenbooleanHide this column on medium screen.
lgOffsetnumberThe number of columns to offset on large screen.
lgHiddenbooleanHide this column on large screen.
xlnumberThe width of the column on extra large screen.
xlOffsetnumberThe number of columns to offset on extra large screen.
xlHiddenbooleanThe number of columns to offset on extra large screen.
childrenNodeIt can wrap another component in itself.
bluerainobjectThis is used to give bluerain context
windowSizenumberIt is used to give window size.
sizeobjectNumber of columns parent row has.
gutternumberSpacing between 2 columns.

Container

Props

NameDefaultTypeDescription
bluerainobjectThis is used to give bluerain context
widthsnumberIt Provides width of Container
windowSizenumberIt is used to give window size
styleobjectIt is used for styling container

ResponsiveLayout

Props

NameDefaultTypeDescription
bluerainobjectThis is used to give bluerain context
widthsnumberIt Provides width of Container
xsReact.ComponentTypeThe component to render when the screen size is extra-small
smReact.ComponentTypeThe component to render when the screen size is small
lgReact.ComponentTypeThe component to render when the screen size is large
xlReact.ComponentTypeThe component to render when the screen size is extra-large
defaultReact.ComponentTypeThe default component to render, if a current size component is not given

Row

Props

NameDefaultTypeDescription
bluerainobjectThis is used to give bluerain context
windowSizenumberIt is used to give window size
styleobjectIt is used for styling row
sizenumberTotal number of columns this Row can have. Defaults to 12.
gutternumberThe gutter width, i.e. padding between columns. Defaults to 30 (15 on each side)
nowrapbooleanAccepts a boolean. This boolean defines the style property flexWrap.
alignItemsstringDefines the javascript style property alignItems of the component
justifyContentstringDefines the javascript style property justifyContent of the componen

WindowInfo

Props

NameDefaultTypeDescription
setWindowDimentionsobjectThis is used to give height and width of the window

withWindowSize

Props

NameDefaultTypeDescription
windowSizeobjectThis is used to give height and width of the window

Hooks

This plugin adds its functions in following hooks:

bluerain.redux.reducers.bluerain

Window reducers are added through this hook to modify the nested bluerain reducer.

Parameters:

NameTypeDescription
reducersobjectTh is contains window size(height and width)

Returns:

NameTypeDescription
WindowReducerobjectThis adds window reducer in reducers

bluerain.redux.initialState

This hook gives the ability to modify the initial state sent to the redux store. Responsive component plugin uses this hook to set initial state of window to bluerain object.

Parameters:

NameTypeDescription
initialstateobjectIt provides initial state of window

Returns:

NameTypeDescription
windowobjectIt updates the state of window in reducer to initialstate

bluerain.redux.middlewares

This plugin adds custom middlewares to the main redux store. The custom middleware takes store as argument, then compares window previous and current sizes. If size is changed, it emits an event with 'plugin.window_info.resize' string.

Parameters:

NameTypeDescription
middlewaresobjectmiddlewaresare added in redux store

Returns:

NameTypeDescription
windowobjectIt updates the state of window in reducer to initialstate of window

bluerain.system.plugins.initialized

Once the plugins are initialized in the system, Responsive Plugin uses this hook to adjust component layout by comparing the new and old screen dimensions, hence re-renders the component.

Parameters:

NameTypeDescription
ComponentReact.Componentmiddlewaresare added in redux store

Returns:

NameTypeDescription
ComponentReact.ComponentIt is used to render new component with new window size

API

ResponsiveComponentsPlugin

Properties

  • pluginName string "ResponsiveComponentsPlugin"
  • slug string "responsive-components"
1.2.10

5 years ago

1.2.9

6 years ago

1.2.8

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.0

6 years ago