Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Grid to v1 API #351

Merged
merged 34 commits into from
Aug 4, 2016
Merged

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Jul 27, 2016

Update <Grid> to v1 API.
http://semantic-ui.com/collections/grid.html


Types

Grid

A basic grid

<div class="ui grid">
  <div class="column"></div>
</div>
<Grid>
  <Grid.Column></Grid.Column>
</Grid>

Divided

A grid can have dividers between its columns

<div class="ui three column divided grid">
  <div class="column"></div>
</div>
<Grid column={3} divided>
  <Grid.Column></Grid.Column>
</Grid>
<Grid column='three' divided>
  <Grid.Column></Grid.Column>
</Grid>

Vertically Divided

A grid can have dividers between rows

<div class="ui vertically divided grid"></div>
<Grid column={3} divided='vertically' />

Celled

A grid can have rows divided into cells

<div class="ui celled grid"></div>
<Grid celled />

Internally Celled

A grid can have rows divisions only between internal rows

<div class="ui internally celled grid"></div>
<Grid celled='internally' />

Content

Skip

Variations

Floated

A column can sit flush against the left or right edge of a row

<div class="ui grid">
  <div class="left floated column"></div>
  <div class="right floated column"</div>
</div>
<Grid>
  <Grid.Column floated='left' />
  <Grid.Column floated='right' />
</Grid>

Column Width

A column can vary in width taking up more than a single grid column

Skip

Column Count

A grid can have a different number of columns per row

Skip

Equal Width

A row can automatically resize all elements to split the available width evenly

<div class="ui equal width grid"></div>
<Grid width='equal' />

Stretched

An can stretch its contents to take up the entire column height

<div class="stretched row"></div>
<Grid.Row stretched />

Padded

A grid can preserve its vertical and horizontal gutters on first and last columns

<div class="ui padded grid"></div>
<div class="ui vertically padded grid"></div>
<div class="ui horizontally padded grid"></div>
<Grid padded />
<Grid padded='vertically' />
<Grid padded='horizontally' />

Relaxed

A grid can increase its gutters to allow for more negative space

<div class="ui relaxed grid"></div>
<div class="ui very relaxed grid"></div>
<Grid relaxed />
<Grid relaxed='very' />

Colored

A grid row or column can be colored

<div class="ui red column"></div>
<div class="ui red row"></div>
<Grid.Column color='red' />
<Grid.Row  color='red' />

Centered

A grid can increase its gutters to allow for more negative space

<div class="ui centered grid"></div>
<Grid centered />

Text Alignment

A grid, row, or column can specify its text alignment

<div class="ui left aligned grid"></div>
<div class="center aligned row"></div>
<div class="right aligned column"></div>
<div class="justified row"></div>
<Grid aligned='left' />
<Grid.Row aligned='center' />
<Grid.Column aligned='right' />
<Grid.Row aligned='justified' />

Vertical Alignment

A grid, row, or column can specify its vertical alignment to have all its columns vertically centered

(!) Problem. Vertical aligment uses same class name as text alignment, but we can't pass two aligned props 😄 So, I propose use vertical prop.

<div class="ui bottom aligned grid"></div>
<div class="middle aligned row"></div>
<div class="top aligned column"></div>
<Grid aligned='bottom' />
<Grid.Row aligned='middle' />
<Grid.Column aligned='top' />

Responsive Variations

Doubling

A grid can double its column width on tablet and mobile sizes

<div class="ui doubling grid"></div>
<Grid doubling />

Stackable

A grid can have its columns stack on-top of each other after reaching mobile breakpoints

<div class="ui stackable grid"></div>
<Grid stackable />

Reversed

A grid or row can specify that its columns should reverse order at different device sizes

See docs

Device Visibility

A columns or row can appear only for a specific device, or screen sizes

See docs

Responsive Width

A column can specify a width for a specific device

See docs

@codecov-io
Copy link

codecov-io commented Jul 27, 2016

Current coverage is 92.87% (diff: 100%)

No coverage report found for master at 0c2edfb.

Powered by Codecov. Last update 0c2edfb...04285f3

@layershifter
Copy link
Member Author

Reference #269

@layershifter
Copy link
Member Author

Docs finished 😄 Open for discussion.

Take a look, pay attention on Responsive Variations, there are mistakes in SUI docs.

@levithomason
Copy link
Member

Awesome! Will review tomorrow :D

@layershifter
Copy link
Member Author

I've added test, you can see problems with prop naming, so I'm open to ideas 😄

import React from 'react'
import { Image, Grid } from 'stardust'

const columns = _.range(0, 16).map((i) => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_.times can be used here:

_.range(0, 16).map((i) => {})

// becomes

_.times(16, (i) => {})

@layershifter
Copy link
Member Author

Vertical Alignment

I've updated usage of aligned prop, renamed commonTests and propUtils, added new functions.

@layershifter
Copy link
Member Author

Column Count & Equal Width

Updated as you asked 😄

@layershifter
Copy link
Member Author

Reversed, Device Visibility & Responsive Width

I think I'm missing the error

Reverved might be Resersed and some other errors in SUI docs.


Take a look on Responsive Width implementation, prop naming really correct (mobile, largeScreen, widescreen, etc)? If it's okay, I've update implementsNumberToWordProp test to support different class name (see commented test on GridColumn-test.js).


const { Column, Row } = Grid

const GridReversedMobileVerticallyExamples = () => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mobile should be computer here.

*/
export const useColumnsProp = (val, canEqual = false) => val === 'equal' && canEqual
? 'equal width'
: useValueAndKey(numberToWord(val), 'column')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these!

it('adds "justified" without "aligned" to className', () => {
shallow(<Component { ...requiredProps } aligned='justified' />)
.should.have.className('justified')
it('adds prop value to className', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this test now uses numberToWord to convert the value. Let's update the assertion to

-    it('adds prop value to className',
+    it('adds numberToWord value to className'

// common.implementsNumberToWordProp(GridColumn, 'tablet')
common.implementsTextAlignProp(GridColumn)
common.implementsVerticalAlignProp(GridColumn)
// common.implementsNumberToWordProp(GridColumn, 'widescreen')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need to do in order to get these tests working?

Copy link
Member Author

@layershifter layershifter Aug 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems, it was my mistake, I'll make commit soon

@levithomason
Copy link
Member

I think we're good to go on this PR. Is there anything else you wanted to hit before merging? If not, merge master and I'll give it a final once over and merge.

@layershifter
Copy link
Member Author

Updated to origin, seems we're ready 😸

@layershifter
Copy link
Member Author

Updated again ✌️

@levithomason
Copy link
Member

I believe this is good to go, I've looked at it too many times! Merging, we can iterate on any oversights. Thanks for the massive amount of work here 🍻

@levithomason levithomason merged commit d17b252 into Semantic-Org:master Aug 4, 2016
@levithomason
Copy link
Member

Released in v0.28.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants