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

[Grid] Add visibility classes #2435

Closed
joshblack opened this issue May 3, 2019 · 10 comments · Fixed by #11786
Closed

[Grid] Add visibility classes #2435

joshblack opened this issue May 3, 2019 · 10 comments · Fixed by #11786

Comments

@joshblack
Copy link
Contributor

From @DusanMilko:

I would like to request carbon team to add visibility classes for breakpoints so you could do:
bx--col-xs-1 bx--col-lg-hidden <- this hides for lg and up, could also add bx--col-lg-only-hidden to hide for that breakpoint only. I can make a pr if you would prefer, let me know

Like foundation has done:
https://foundation.zurb.com/sites/docs/visibility.html

@carbon-bot carbon-bot transferred this issue from carbon-design-system/carbon-elements May 9, 2019
@joshblack joshblack added the package: elements @carbon/elements label May 9, 2019
@DusanMilko
Copy link
Contributor

Will add p/r today

@stale
Copy link

stale bot commented Jun 9, 2019

We've marked this issue as stale because there hasn't been any activity for a couple of weeks. If there's no further activity on this issue in the next three days then we'll close it. You can keep the conversation going with just a short comment. Thanks for your contributions.

@stale stale bot added the status: inactive Will close if there's no further activity within a given time label Jun 9, 2019
@stale
Copy link

stale bot commented Jun 12, 2019

As there's been no activity since this issue was marked as stale, we are auto-closing it.

@stale stale bot closed this as completed Jun 12, 2019
joshblack added a commit that referenced this issue Jan 20, 2020
* docs(Grid): add example of hiding columns

* feat(grid): add hiding columns with width 0

Adds functionality requested in (#2435) with more convenient syntax.

Originally from PR #4894.

* fix(Grid): code impl in wrong location

* fix(Grid): update to not allow "-1" span

* fix(Grid): revert unintentional scss changes

* chore(components): update grid snapshots

Co-authored-by: Josh Black <josh@josh.black>
joshblack added a commit that referenced this issue Jan 29, 2020
* feat(grid): add hiding columns with width 0

Adds functionality requested in (#2435) with more convenient syntax

* docs(grid): add example of hiding columns

* docs(grid): fix incorrect `bleed` info and typos

* docs(grid): add link to live demo website

Change requested here in (#2803)

* feat(grid): implement functional React component

* chore(grid): add generated files

* fix(docs): storybook support load CSF & add sort

* docs(Grid): update valid props

additionally:
- fix oneOf not using array
- label default props as undefined
- convert col width from str -> num
- add range func

* docs(Grid): add initial story & style margins

* docs(Grid): clean up doc styles & knob controls

* docs(Grid): add color knobs, pass thru params

* docs(Grid): fix minor fullwidth disp bug

* test(Grid): add smoke tests for root el

* test(Grid): add basic row and col tests

* test(Grid): fix wrappers & update index snapshot

* feat(Grid): use layout's breakpoints

* chore(Grid): port all tests, add 'as' prop

* docs(Grid): include stories from #3892

* feat(Grid): support obj syntax & rm offset props

* fix(Grid): add missing @carbon/layout pkg

* feat(Grid): rm `noGutter` prop for later PR

* chore(Grid): revert storybook to 5.2.1

* chore(Grid): convert to recommended syntax

* chore(Grid): inline array gen helper

* fix(Grid): update incorrect prop types

* chore(Grid): update import format

* Revert sass.md

* Revert _mixins.scss

* Revert App.js

* refactor(grid): split out files and update Column

* refactor(grid): update test suite for grid components

* docs(grid): update story for grid

* fix(react): update entrypoint with grid components

* fix(grid): convert story offset to prop obj

* fix(react): update with missing prop values

* chore(project): sync offline mirror

Co-authored-by: Josh Black <josh@josh.black>
@fabpico
Copy link
Contributor

fabpico commented Nov 23, 2021

@joshblack I would like to reactivate this issue, I also would like to have such classes.

@joshblack
Copy link
Contributor Author

Hi there @FabianPiconeDev! I believe these should be available under the "0 column span" classes. Let me know if I'm misunderstanding or you're looking for something else! 👀

@fabpico
Copy link
Contributor

fabpico commented Dec 3, 2021

@joshblack Ok but, when I have:

<div className={'bx--col-sm-0'}>{icon.large}</div>
<div className={'bx--col-lg-0'}>{icon.small}</div>

I would expect that the element with class bx--col-sm-0 would be visible in large view. But it is never visible because the CSS behind it is without any media query limitation.

.bx--col-sm-0 {
    display: none;
}

The element is not in a grid (so my request is not exclusively grid related). When the element is not in a grid, I wouldn't want to use grid classes.

I see I could make something like:

<div className={'bx--col-lg-12 bx--col-sm-0'}>{icon.large}</div>
<div className={'bx--col-sm-12 bx--col-lg-0'}>{icon.small}</div>

but this is less readable and implicits a wrapping grid (which is optional), compared to having classes like small-only, medium-up, large-only, and so on.

@joshblack joshblack reopened this Dec 6, 2021
@joshblack
Copy link
Contributor Author

Got it, @FabianPiconeDev! That totally makes sense to me 👍 I'll re-open and we can make sure to guard these declarations with max-width in media queries.

Thanks so much for clarifying, it was super helpful and I appreciate it.

@joshblack joshblack moved this to ⏱ Backlog in Design System Dec 6, 2021
@joshblack joshblack added package: grid @carbon/grid type: bug 🐛 and removed status: inactive Will close if there's no further activity within a given time labels Dec 6, 2021
@tw15egan
Copy link
Collaborator

tw15egan commented Jun 28, 2022

@fabpico are you thinking of entirely new grid classes (bx-col-sm-0-only), that only hide content at specific breakpoints? Or do you think we should add media queries to the 0 column span classes (bx--col-sm-0) so that they should only hide content at that breakpoint?

Since you say you are not using it inside of a grid, perhaps these make even more sense living outside of the grid package, as a utility class inside @carbon/styles in the breakpoint.scss file. This would be a convenient way to hide things at different breakpoints outside of the grid context

@joshblack do you have any preferences? I think I am leaning towards adding utility classes to breakpoints.scss in the @carbon/styles since it can be done in the grid context already e.g. bx--col-lg-12 bx--col-sm-0

@tw15egan
Copy link
Collaborator

POC up in #11786

@fabpico
Copy link
Contributor

fabpico commented Jul 29, 2022

@tw15egan

@fabpico are you thinking of entirely new grid classes (bx-col-sm-0-only), that only hide content at specific breakpoints?

I was thinking about entirely new visibility classes outside of the grid context, but breakpoint aware. Like small-only, medium-up, large-only.

I am already using such custom classes:

.medium-down {
  @media (min-width: $carbon--grid-breakpoint-large-width) {
    display: none;
  }
}

.small-only {
  @media (min-width: $carbon--grid-breakpoint-medium-width) {
    display: none;
  }
}

Since you say you are not using it inside of a grid, perhaps these make even more sense living outside of the grid package, as a utility class inside @carbon/styles in the breakpoint.scss file.

I totally agree.

@kodiakhq kodiakhq bot closed this as completed in #11786 Jul 29, 2022
Repository owner moved this from ⏱ Backlog to ✅ Done in Design System Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants