-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat(Grid): Add grid support for multiple device visibility breakpoints #1347
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1347 +/- ##
=======================================
Coverage 99.74% 99.74%
=======================================
Files 141 141
Lines 2354 2354
=======================================
Hits 2348 2348
Misses 6 6
Continue to review full report at Codecov.
|
❤️ |
@levithomason I've added examples to docs, so you can pull and give me the review when you will have time. <Grid.Row onlyLarger='mobile' /> // => <div class="tablet computer only"></div>
<Grid.Row onlyLarger='tablet' /> // => <div class="computer only"></div>
<Grid.Row onlyLarger='computer' /> // => <div class="large screen widescreen only"></div>
<Grid.Row onlyLarger='largeScreen' /> // => <div class="widescreen only"></div>
<Grid.Row onlySmaller='computer' /> // => <div class="mobile tablet only"></div>
<Grid.Row onlySmaller='tablet' /> // => <div class="mobile only"></div> If we go to SUI CSS, you will undertand my logic there 😄 We can't do behaviour below, because <Grid.Row onlySmaller='largeScreen' /> // => <div class="mobile tablet computer only"></div> Resuming. After this I do not think it's a good idea, it looks very confusing. |
I've plotted out the
I want to include something like this in the docs along with some more explanation on the classes as they are pretty confusing without going through this exercise. However, now that we have this chart, we can map the classes. |
I'll take a short break to rethink this 🤔 However, the ideas with table is awesome. |
I think we need to change our initial idea about // will include `tablet`, `computer`
// `largeScreen` and `wideScreen` is unnecessary there
<Grid.Row onlyLarger='mobile' />
<Grid.Row only='tablet computer' />
// will include `computer`
// `largeScreen` and `wideScreen` is unnecessary there
<Grid.Row onlyLarger='tablet' />
<Grid.Row only='computer' />
// will include `largeScreen` and `widescreen`
<Grid.Row onlyLarger='computer' />
<Grid.Row only='largeScreen widescreen' />
// will include only `widescreen`, so it's unnecessary
<Grid.Row onlyLarger='largeScreen' />
<Grid.Row only='widescreen' />
// will include nothing
<Grid.Row onlyLarger='widecreen' /> // we need to include there `computer` and `largeScreen`, but it doesn't make sence
<Grid.Row onlySmaller='widescreen' />
// we need to include there `computer`, but it doesn't make sence
<Grid.Row onlySmaller='largeScreen' />
// will include `mobile` and `tablet`
<Grid.Row onlySmaller='computer' />
<Grid.Row only='mobile tablet' />
// will include `mobile`
<Grid.Row onlySmaller='tablet' />
<Grid.Row only='mobile' />
// will include nothing
<Grid.Row onlySmaller='mobile' />
<Grid.Row only='mobile' /> After this small analysis we can see, that there are only three variants that makes sence:
My proposal is to add them as independent props:
It will be much cleaner I think. Also, I think we need to standartize @levithomason I'm glad to hear your feedback. |
Super helpful analysis, thank you. I think given the inconsistencies, we should just not implement
On another note, I believe when I checked this PR previously the classNames were generated like so: only='mobile tablet'
// => "mobile tablet only" However, grid.css defines these classes as order dependent classNames where only='mobile tablet'
// => "only mobile only tablet" |
…React into feat/grid-only # Conflicts: # src/collections/Grid/index.d.ts
It's ready 😄 I've added |
What do you think about keeping We do also have other multiple word prop values that are not camel cased, such as: <Input labelPosition='right corner' />
<Sidebar animation='scale down' />
<Popup position='bottom center' /> It may make sense to keep the values as two words. |
I see only one way how we can keep <Grid.Row only='tablet' />
<Grid.Row only=['tablet', 'computer'] />
<Grid.Row only=['large screen', 'widescreen'] /> And it makes sence. |
@levithomason Can you give a feedback there? |
We could a bit of parsing on the string: const only = 'mobile tablet computer large screen widescreen'
only
.replace('large screen', 'large-screen')
.split(' ')
.map(x => `only ${x.replace('-', ' ')}`)
.join(' ')
// => 'only mobile only tablet only computer only large screen only widescreen' |
This looks great, thanks! |
Released in |
Can you update the docs with the proper syntax to account for multiple device visibility? It currently isn't clear based on this issue or #1024 which is the proper way to implement "computer and up" |
@Samiam519 please open a ticket if there is an issue with documentation. Commenting on a PR that was merged three years ago isn't going to help anyone. |
Fixes #1024.