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

[UI] Add Responsive Helper Classes #1114

Open
ronnross opened this issue Sep 23, 2014 · 72 comments
Open

[UI] Add Responsive Helper Classes #1114

ronnross opened this issue Sep 23, 2014 · 72 comments

Comments

@ronnross
Copy link

I'm using semantic beta

I have an element That I only want to show in mobile view only. For example,

`


Save

`

This element shows in computer, tablet, and mobile views.

@mzbyszynski
Copy link

Hi @ronnross,

As far as I know the "mobile only" classes currently only work inside a ui grid in conjunction with the row and column tags. See an example of how it works here:

http://beta.semantic-ui.com/collections/grid.html#responsive-to-device

@ronnross
Copy link
Author

@mzbyszynski it looks like you are correct. Is there an equivalent to bootstraps hidden-XX class in semantic? I'm looking to hide elements at a more granular level than grid/row conjunction.

@mzbyszynski
Copy link

Right now I don't think there is, but it sounds like a good idea to me 👍

See #1066, that includes some workarounds suggested by @CharlesOkwuagwu as well.

@jlukic
Copy link
Member

jlukic commented Sep 23, 2014

@ronnross It seems a lot of people want to use this, but I've been a bit stubborn about "free floating" ui helper classes in Semantic UI since the spirit of the project is to define variations in the context of each element.

@jlukic jlukic changed the title Mobile only classes not working in beta. [UI] Add Responsive Helper Classes Sep 23, 2014
@jlukic jlukic added this to the 1.x Changes milestone Sep 23, 2014
@ronnross
Copy link
Author

@jlukic I respect the decision to not have "free floating" ui helper classes. What are your thoughts about having mobile, tablet, computer only classes under each collection? For example, the menu collection would allow for "mobile only" classes. This would keep them within the context of the parent collection e.g., form, grid, menu. Am I way off base?

@tmikaeld
Copy link

tmikaeld commented Mar 3, 2015

I think it makes sense to support it in the menu at least.

Right now i'm looking for a solution to showing a large button for search on mobile while on the desktop showing the whole search bar and afaik i can't do that without manually adding a mediaquery breakpoint.

@PLPeeters
Copy link
Contributor

+1 for at least supporting it in the menu.

@Ehesp
Copy link

Ehesp commented Apr 2, 2015

Would be a good feature, hiding things like icons or text as a page gets smaller is handy.

@pateketrueke
Copy link

So, when this will be ready to use?

@jlukic
Copy link
Member

jlukic commented Apr 8, 2015

Haven't started any development, probably a while.

@ch3m1c
Copy link

ch3m1c commented May 4, 2015

+1 for hidden-xx

@watzon
Copy link

watzon commented Jun 9, 2015

Have we gotten anywhere on this? Need someone to develop it? I love Semantic UI, but this seems to be the one huge thing missing. I will implement it if it's not at the top of anyone else's priority list.

@arvi
Copy link

arvi commented Jun 10, 2015

It would be great if Semantic UI has an equivalent for Zurb Foundation's Media Queries :) http://foundation.zurb.com/docs/media-queries.html

@jlukic
Copy link
Member

jlukic commented Jun 10, 2015

Named breakpoint variables are built into Semantic UI, you can use them in your own custom less.

@jlukic jlukic modified the milestones: 2.x Changes, 1.x Changes Jul 5, 2015
@listepo
Copy link

listepo commented Aug 4, 2015

+1

2 similar comments
@lancetw
Copy link

lancetw commented Aug 13, 2015

+1

@mamluka
Copy link

mamluka commented Aug 29, 2015

+1

@rachellji
Copy link

+1 ~~~ would be great if can conveniently hide any image, label or other elements .

@prijindal
Copy link

+1 On this, would be really helpful

@KonsoltCorp
Copy link

+10000 on this!

@FernandoMueller
Copy link

+1

@jokeronaldo
Copy link
Member

@scumie Thanks for the contribution 👍

@aliok
Copy link

aliok commented Mar 24, 2016

here is the @scumie 's snippet with class names consistent with Semantic UI. (ie. large monitor --> large screen, widescreen monitor --> widescreen)

// Semantic UI has these classes, however they're only applicable to
// grids, containers, rows and columns.
// plus, there isn't any `mobile hidden`, `X hidden` class.
// this snippet is using the same class names and same approach
// plus a bit more but to all elements.
//
// see https://github.com/Semantic-Org/Semantic-UI/issues/1114

/* Mobile */
@media only screen and (max-width: 767px) {
  [class*="mobile hidden"],
  [class*="tablet only"]:not(.mobile),
  [class*="computer only"]:not(.mobile),
  [class*="large screen only"]:not(.mobile),
  [class*="widescreen only"]:not(.mobile),
  [class*="or lower hidden"] {
    display: none !important;
  }
}

/* Tablet / iPad Portrait */
@media only screen and (min-width: 768px) and (max-width: 991px) {
  [class*="mobile only"]:not(.tablet),
  [class*="tablet hidden"],
  [class*="computer only"]:not(.tablet),
  [class*="large screen only"]:not(.tablet),
  [class*="widescreen only"]:not(.tablet),
  [class*="or lower hidden"]:not(.mobile) {
    display: none !important;
  }
}

/* Computer / Desktop / iPad Landscape */
@media only screen and (min-width: 992px) and (max-width: 1199px) {
  [class*="mobile only"]:not(.computer),
  [class*="tablet only"]:not(.computer),
  [class*="computer hidden"],
  [class*="large screen only"]:not(.computer),
  [class*="widescreen only"]:not(.computer),
  [class*="or lower hidden"]:not(.tablet):not(.mobile) {
    display: none !important;
  }
}

/* Large Monitor */
@media only screen and (min-width: 1200px) and (max-width: 1919px) {
  [class*="mobile only"]:not([class*="large screen"]),
  [class*="tablet only"]:not([class*="large screen"]),
  [class*="computer only"]:not([class*="large screen"]),
  [class*="large screen hidden"],
  [class*="widescreen only"]:not([class*="large screen"]),
  [class*="or lower hidden"]:not(.computer):not(.tablet):not(.mobile) {
    display: none !important;
  }
}

/* Widescreen Monitor */
@media only screen and (min-width: 1920px) {
  [class*="mobile only"]:not([class*="widescreen"]),
  [class*="tablet only"]:not([class*="widescreen"]),
  [class*="computer only"]:not([class*="widescreen"]),
  [class*="large screen only"]:not([class*="widescreen"]),
  [class*="widescreen hidden"],
  [class*="widescreen or lower hidden"] {
    display: none !important;
  }
}

@paladin2005
Copy link

You saved my life guys

@bwmarrin
Copy link

+1 :)

@chrisinajar
Copy link

+1, especially to match bootstrap functionality

Here's that same snippet with the Semantic variables used. If you include in the site vars you can use this....

// Semantic UI has these classes, however they're only applicable to
// grids, containers, rows and columns.
// plus, there isn't any `mobile hidden`, `X hidden` class.
// this snippet is using the same class names and same approach
// plus a bit more but to all elements.
//
// see https://github.com/Semantic-Org/Semantic-UI/issues/1114

/* Mobile */
@media only screen and (max-width: (@tabletBreakpoint - 1)) {
  [class*="mobile hidden"],
  [class*="tablet only"]:not(.mobile),
  [class*="computer only"]:not(.mobile),
  [class*="large screen only"]:not(.mobile),
  [class*="widescreen only"]:not(.mobile),
  [class*="or lower hidden"] {
    display: none !important;
  }
}

/* Tablet / iPad Portrait */
@media only screen and (min-width: @tabletBreakpoint) and (max-width: (@computerBreakpoint - 1)) {
  [class*="mobile only"]:not(.tablet),
  [class*="tablet hidden"],
  [class*="computer only"]:not(.tablet),
  [class*="large screen only"]:not(.tablet),
  [class*="widescreen only"]:not(.tablet),
  [class*="or lower hidden"]:not(.mobile) {
    display: none !important;
  }
}

/* Computer / Desktop / iPad Landscape */
@media only screen and (min-width: @computerBreakpoint) and (max-width: (@largeMonitorBreakpoint - 1)) {
  [class*="mobile only"]:not(.computer),
  [class*="tablet only"]:not(.computer),
  [class*="computer hidden"],
  [class*="large screen only"]:not(.computer),
  [class*="widescreen only"]:not(.computer),
  [class*="or lower hidden"]:not(.tablet):not(.mobile) {
    display: none !important;
  }
}

/* Large Monitor */
@media only screen and (min-width: @largeMonitorBreakpoint) and (max-width: (@widescreenMonitorBreakpoint - 1)) {
  [class*="mobile only"]:not([class*="large screen"]),
  [class*="tablet only"]:not([class*="large screen"]),
  [class*="computer only"]:not([class*="large screen"]),
  [class*="large screen hidden"],
  [class*="widescreen only"]:not([class*="large screen"]),
  [class*="or lower hidden"]:not(.computer):not(.tablet):not(.mobile) {
    display: none !important;
  }
}

/* Widescreen Monitor */
@media only screen and (min-width: @widescreenMonitorBreakpoint) {
  [class*="mobile only"]:not([class*="widescreen"]),
  [class*="tablet only"]:not([class*="widescreen"]),
  [class*="computer only"]:not([class*="widescreen"]),
  [class*="large screen only"]:not([class*="widescreen"]),
  [class*="widescreen hidden"],
  [class*="widescreen or lower hidden"] {
    display: none !important;
  }
}

@hdrdavies
Copy link

+1

@Ryuno-Ki
Copy link

Quoting @sstok:

Please use the GitHub Reactions to vote https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments instead of posting +1 it will prevent informing everyone over no usable update

@ciokan
Copy link

ciokan commented May 26, 2016

👍

@alexshin
Copy link

+1

@YamiOdymel
Copy link

YamiOdymel commented Aug 13, 2016

The workaround with ui large screen only button makes the button larger,

wrap the buttons with an extra <div> to solve the issue:

<div class="large screen only">
    <button class="ui button"></button>
</div>

@sgeraldes
Copy link

@YamiOdymel That is intended... see my comment on Feb 9.

@vinayakkulkarni
Copy link
Member

Any updates regarding this? It'd be really awesome if it's included in the next release 😁

@vsg24
Copy link

vsg24 commented Oct 21, 2016

This is sooooooo needed.

@cdaringe
Copy link

cdaringe commented Dec 6, 2016

@chrisinajar, thanks for the less.

can someone provide a practical example where

<root>
   <a class="shows only when mobile or tablet" />
   <b class="shows only when computer or larger" />
   <!-- e.g. toggle a & b! -->
</root>

using the above css?

@cdaringe
Copy link

cdaringe commented Dec 6, 2016

nm, got it

<root>
   <a class="tablet or lower hidden" />
   <b class="mobile tablet only" />
</root>

@dwenaus
Copy link

dwenaus commented Apr 21, 2017

Seems like the authors (bless them) have a philosophical difference with something like this being included. Nevertheless it is handy is certain situations. For example I was able to use the above trick to turn off a sticky menu on mobile. very handy and I could find no other way to do it with built in styles.

@jkasun
Copy link

jkasun commented Jun 13, 2017

+1

@GuacheSuede
Copy link

#6109

@stale
Copy link

stale bot commented Apr 28, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 28, 2018
@Panman82
Copy link

Bump, due to stale bot. Still needed for sure!

@stale stale bot removed the stale label Apr 30, 2018
@bwmarrin
Copy link

bwmarrin commented May 1, 2018

Somehow, I suspect if this wasn't done in the last 4 years, it probably isn't getting done.

@jlukic
Copy link
Member

jlukic commented Oct 7, 2018

All modifiers in SUI are scoped to UI components. This helps make sure class names for SUI dont leak into other CSS in people's projects and can apply to each component differently.

This is similar to linguistics with examples like "small planet" vs "large ant". Which is bigger? Neither size modifier represents an exact size that can be defined in isolation, but only in context of the word they modify.

@sgeraldes
Copy link

Just scope it as you see fit and get back to us with a proposal. When this was dropped here, the documentation was slim and confusing, needing a masters degree to implement some of it. At the time of writing this, semantic UI didn't have anything like this either and name schema was all over the place, and as the thread clearly shows, how the modifiers were at the beginning of this thread changed considerably with the years.

@bitvilag
Copy link

Any progress on this issue?

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

No branches or pull requests