3.3.0 • Published 4 years ago

evokit-grid v3.3.0

Weekly downloads
734
License
MIT
Repository
github
Last release
4 years ago

EvoKit - Grid

npm.io npm.io

The grid for placing content on the page, has 10 columns. Contains two elements <Grid> and <Grid.Item>


Install

Peer dependencies evokit. More about install

npm install evokit-grid --save

Usage

More about usage

import React from 'react';
import { Grid } from 'evokit-grid';
import 'evokit-grid/style.css';

const App = () => (
    <Grid grid-column='3'>
        <Grid.Item>
            ...
        </Grid.Item>
    </Grid>
);

Props

Also supports other valid props of the React Element. More about use props

<Grid />

Prop nameDefault valuePossible valueDescription
grid-alignleftleft center right justifyHorizontal alignment of cells
grid-columnautoauto 1 2 3 4 5 6 7 8 9 10 expandNumber of cells in a row
grid-directionrowrow row-reverse column column-reverseCell direction
grid-displayflexflex noneDisplay type
grid-divider-columnautoauto 1 2 3 4 5 6 7 8 9 10 expandNumber of cells in a row, only use with prop grid-divider
grid-divider-indent *nonenone xxs xs s m l xl xxl 3xl 4xl 5xlIndentation between cells, only use with prop grid-divider
grid-dividernullCreate themeColor border between cells
grid-heightautoauto inherit 1-1Set the height
grid-indent *nonenone xxs xs s m l xl xxl 3xl 4xl 5xlIndentation between cells
grid-valigntoptop middle bottom baseline justifyVertical Cell Alignment
grid-wrapwrapwrap nowrap wrap-reverseWrap rules

<Grid.Item />

Prop nameDefault valuePossible valueDescription
grid-item-ordernull1 2 3 4 5 6 7 8 9 10Sets the order of the cell
grid-item-widthautoauto expand 1-1 *-2 *-3 *-4 *-5 *-6 *-7 *-8 *-9 *-10Cell width
grid-item-displayblockblock noneDisplay type

* — prop has advanced params

Customize

This set of css variables is default, if you want to override one or more value, please use the rules css-variable-usage, define them below the css import.

@custom-media --ek-grid-media-small only screen and (min-width: 480px);
@custom-media --ek-grid-media-medium only screen and (min-width: 768px);
@custom-media --ek-grid-media-large only screen and (min-width: 960px);
@custom-media --ek-grid-media-wide only screen and (min-width: 1200px);
@custom-media --ek-grid-media-huge only screen and (min-width: 1400px);

:root {
    /* prop 'grid-indent' */
    --ek-grid-indent-xxs: 5px;
    --ek-grid-indent-xs: 10px;
    --ek-grid-indent-s: 15px;
    --ek-grid-indent-m: 20px;
    --ek-grid-indent-l: 25px;
    --ek-grid-indent-xl: 30px;
    --ek-grid-indent-xxl: 35px;
    --ek-grid-indent-3xl: 40px;
    --ek-grid-indent-4xl: 45px;
    --ek-grid-indent-5xl: 50px;
}

Live demo

Edit grid-usage


grid-display

Display type

  • flex - shown as blocky
  • none - remove from a document
<Grid grid-display='none'>
    ...
</Grid>

grid-column

Number of cells in a row

  • 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - Number of cells in a row
  • auto - The width of the cells depends on the content
  • expand - The width of the cells is proportional to their count
<Grid grid-column='2'>
    <Grid.Item>
        ...
    </Grid.Item>
</Grid>

grid-indent

The property allows you to set the indentation value for all sides of an cell at once or to determine it only for specified sides.

Is calculated from content to content.

Advanced props

  1. grid-indent-x
  2. grid-indent-y

Multi values (set value separated by a space)

  • grid-indent="{1} {2}"

List of values

ValueCSS varCSS value
none---0px
xxs--ek-grid-indent-xxs5px
xs--ek-grid-indent-xs10px
s--ek-grid-indent-s15px
m--ek-grid-indent-m20px
l--ek-grid-indent-l25px
xl--ek-grid-indent-xl30px
xxl--ek-grid-indent-xxl35px
3xl--ek-grid-indent-3xl40px
4xl--ek-grid-indent-4xl45px
5xl--ek-grid-indent-5xl50px
<Grid grid-indent='xs' />
<Grid grid-indent='xs xl' />
<Grid
    grid-indent-x='xs'
    grid-indent-y='xl'
/>

grid-direction

Cell direction

  • row - Cell direction from left to right
  • row-reverse - Cell direction from right to left
  • column - Cell direction from top to bottom
  • column-reverse - Cell direction from bottom to top
<Grid grid-direction='row-reverse'>
    <Grid.Item>
        ...
    </Grid.Item>
</Grid>

grid-wrap

Wrap cell rules

  • nowrap - The location of the cells in one line
  • wrap - Cells that do not fit one line in width are shifted down
  • wrap-reverse - Similar behavior with wrap only cell offset occurs up
<Grid grid-wrap='nowrap'>
    <Grid.Item>
        ...
    </Grid.Item>
</Grid>

grid-align

Horizontal alignment of cells

  • left - Align cells to the left
  • center - Center alignment of cells
  • right - Align cells to the right
  • justify - Distributes all cells evenly across width
<Grid grid-align='center'>
    <Grid.Item>
        ...
    </Grid.Item>
</Grid>

grid-valign

Vertical cell alignment

  • top - Align cells to top
  • middle - Alignment of cells in the middle
  • bottom - Alignment of cells to the bottom
  • baseline - Align cells to baseline
  • justify - Evenly distributes all cells in height
<Grid grid-valign='middle'>
    <Grid.Item>
        ...
    </Grid.Item>
</Grid>

grid-height

Set the height

  • auto - value: auto
  • inherit - value: inherit
  • 1-1 - value: 100%
<Grid grid-height='1-1'>
    ...
</Grid>

grid-divider-indent

The property allows you to set the indentation value for all sides of an cell at once or to determine it only for specified sides. Only use with prop grid-divider.

Is calculated from the dividing line to the cell content.

Advanced props

  1. grid-divider-indent-x
  2. grid-divider-indent-y

Multi values (set value separated by a space)

  • grid-divider-indent="{1} {2}"

List of values

ValueCSS varCSS value
none---0px
xxs--ek-grid-indent-xxs5px
xs--ek-grid-indent-xs10px
s--ek-grid-indent-s15px
m--ek-grid-indent-m20px
l--ek-grid-indent-l25px
xl--ek-grid-indent-xl30px
xxl--ek-grid-indent-xxl35px
3xl--ek-grid-indent-3xl40px
4xl--ek-grid-indent-4xl45px
5xl--ek-grid-indent-5xl50px
<Grid
    grid-divider-indent='xs'
    grid-divider={THEME_NAME}
/>
<Grid
    grid-divider-indent='xs xl'
    grid-divider={THEME_NAME}
/>
<Grid
    grid-divider-indent-x='xs'
    grid-divider-indent-y='xl'
    grid-divider={THEME_NAME}
/>

grid-divider-column

Number of cells in a row. Only use with prop grid-divider.

  • 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - Number of cells in a row
  • auto - The width of the cells depends on the content
  • expand - The width of the cells is proportional to their count
<Grid grid-divider-column='2' grid-divider={THEME_NAME}>
    <Grid.Item>
        ...
    </Grid.Item>
</Grid>

grid-divider

Color border between cells

<Grid grid-divider={THEME_NAME}>
    <Grid.Item>
        ...
    </Grid.Item>
</Grid>

Set the THEME_NAME depending on the theming

grid-item-display

Display type

  • block - shown as blocky
  • none - remove from a document
<Grid >
    <Grid.Item grid-item-display='none'>
        ...
    </Grid.Item>
</Grid>

grid-item-order

Sets the order of the cell

  • 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - Determines the cell order
<Grid>
    <Grid.Item grid-item-order='2'>
        ...
    </Grid.Item>
    <Grid.Item>
        ...
    </Grid.Item>
</Grid>

grid-item-width

Cell width

  • auto - Cell width depends on content, value: auto
  • expand - Cell width occupies free space
  • See table, for example: 1-2 = 50%
12345678910
1100%50%33.33%25%20%16.66%14.28%12.5%11.11%10%
2------66.66%50%40%33.33%28.57%25%22.22%20%
3---------75%60%50%42.85%37.5%33.33%30%
4------------80%66.66%57.14%50%44.44%40%
5---------------83.33%71.42%62.5%55.55%50%
6------------------85.71%75%66.66%60%
7---------------------87.5%77.77%70%
8------------------------88.88%80%
9---------------------------90%
<Grid>
    <Grid.Item grid-item-width='expand'>
        ...
    </Grid.Item>
    <Grid.Item grid-item-width='3-10'>
        ...
    </Grid.Item>
</Grid>
3.3.0

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.0

5 years ago

3.1.0-alpha.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

3.0.0-alpha.4

5 years ago

3.0.0-alpha.3

5 years ago

3.0.0-alpha.2

5 years ago

3.0.0-alpha.1

5 years ago

3.0.0-alpha.0

5 years ago

1.0.4

5 years ago