-
Notifications
You must be signed in to change notification settings - Fork 677
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
CSS Grid support #372
Comments
Have been noodling on this quite a bit and like most things in my life, feel conflicted. I really like airing on the side of accessibility (in this case in the form of access to non broken ui) - while it is in evergreen browsers there is also a lot of red there from my perspective. For me even 1% of users is still enough to worry about when considering the scale of the internet. I still don't know how I feel about flex box being in core either. I will definitely create an add on optional module for css grid - because while I have my beliefs about how I like to approach building the web, I don't believe everyone has to share my beliefs. This is in line with my general thoughts lately about Tachyons and the conflict I currently have internally about where to take the project in the future. As I built tachyons for myself to solve my own problems and absolutely never expected more than 20 people to use it - my general philosophy has been to not include things that I don't constantly use myself. But as the project grows I've been wrestling with whether or not to bend to the wishes of many of the awesome users utilizing tachyons even if I disagree with them. And opens up a larger point of if I should just let go of the project and have people from the community maintain it / contribute more. The only hesitation I have here is that I don't know if Tachyons would have ever come into existence if I listened to smart and awesome developers in the first place :) But recognizing that as more people use Tachyons I emotionally feel a larger obligation to let it fit their needs and recognize I can start a new project no one uses that reflects what I want / need in a css toolkit. Sorry for the long slightly unrelated response. This has definitely been weighing on me of late as I see more and more companies adopting Tachyons. Definitely interested in community thoughts. |
@mrmrs As a maintainer in a similar situation, let me say: I feel you! Speaking from experience, I suggest that you focus on what you want the project to be. If you start going down the path of merging features due to pressure, then you will (1) get a less cohesive, curated product (which is why people came to tachyons in the first place) and (2) stop having fun (which can lead to burnout and feelings of guilt). Personally, if you don't use Flexbox, I would consider removing it from core. You can add interested contributors to that repo and let them go wild. It's a win-win. I say: make tachyons whatever you want it to be. The big companies have sufficient resources already -- they can fork their own internal version if they don't like your decisions. That happens all the time with my project Rock on! 🎸 EDIT: I'm still interested to see how you'd do Grid in a tachyons-style way, if you ever get the time. But no pressure to put it in core, or to do it at all. Cheers! ❤️ |
I had a stab at this and ended up with something that seems somewhat usable, although my mnemonics approach might need some work.
Some prefixes for column start/end:
Same for row:
So for example I haven't followed through with gaps in my prototype, but I imagine a few gaps would be useful too:
Gaps would probably be most useful if they took the same scale as padding, so perhaps In actually defining the grid itself, I found that it is probably most common to write custom CSS to define the grid widths, because the grid itself is often a mix of fractions and minmax expressions. It's possible to define some grid-template-columns that e.g. repeat 1fr 6 times (to get a simple 6-column layout). This gives us something like this (with the usual
This completely ignores named areas, as they would be pretty hard to provide in a generic framework, I believe. My prototype uses sass, and a tiny excerpt is below (showing only
One glaring problem is that this doesn't work with an unlimited number of columns. And as the number of supported columns (or rows) increases, so does the size of this file. |
@mogsie It looks like you've put a lot of effort into figuring out a viable approach. I was thinking about how one might go about this a while back as well. Once I started into the mental planning phase, I realized that I was making a mistake. I think you've done the same. And if I'm being completely honest, I don't see easy solutions for (1) where to go from here or (2) how to implement an agnostic, flexible CSS Grid solution with fallbacks that can be used in a framework. CSS-based grids have always been kind of hack-ish using wrappers and widths to push things around. CSS Grid, on the other hand, is kind of radically different. The grid layout is defined in CSS. No need for rows and other extraneous markup hacks to make it all work: your markup doesn't create the grid, so you wind up with a far more rigid separation of layout and markup. Done right, CSS Grid means less CSS and not more, including media queries. Recreating that in markup is just duplicating what CSS Grid already does. One article (You do not need a CSS Grid based Grid System - Rachel Aaron) on this subject had a very poignant conclusion:
A couple others: The benefits of learning how to code layouts with CSS; The future of layout with CSS: Grid Layouts. The general direction seems to be that to fully take advantage of CSS Grid, we'll wind up hand-coding CSS layouts. Which is a good thing. In truth, it'll be likely more flexible and probably even more efficient when you consider how you need fewer media queries, markup changes to support layouts, etc. But that's still radically different. This isn't going to make frameworks obsolete. They're still useful as hell. But once people quit trying to recreate legacy stuff with CSS Grid (I'm assuming there were more than a few moments where you wanted to pull your hair out), frameworks will probably wind up divorcing components from layout as much as possible. Tachyon's components fit into a couple categories, IMO. You have what are effectively full-page layouts with the articles or 404 pages, and some others like cards that definition lists that are effectively layout and grid agnostic. Plug and play. Those components are items that get placed on a grid. Right now, some use existing float grid components internally. Most can be redone with flexbox, which can still be--and should be--used with CSS Grid to take advantage of their differences. They can compliment each other. The trickiest part, IMO, is that CSS Grid is absolutely going to change how frameworks are written. That's going to make things harder on framework developers, but it could end up making things even easier on front-end developers. Whether Tachyon should go in that very different direction is @mrmrs's call. |
Thank you for your thoughful response @bluestrike2, it's exactly the type of feedback I was hoping for. I don't see atomic css in general or tachyons specifically as a "framework" per se, more a technique with a particular implementation. It allows me to express the style of an element in the very element definition. I didn't pull my hair out implementing a standard story layout using this atomic CSS approach. Supporting IE10 was a bit difficult, however. Doing CSS grid in this way does have a few limitations, and that's probably why I'm spending so much time here, to try to see if those limitations are worth it, and if it should just be documented explicitly as no this shouldn't be done as part of a standard tachyons thing, for these reasons: or something like that. The limitations I've hit upon are:
When it comes to supporting IE (with
I do see value in defining cross browser (CSS Grid + Example code
Using this approach it's feasible to re-use the I vote for closing this issue, or perhaps documenting in the README why it's not such a great idea. |
Does this css framework currently support IE8+? |
css grids are the future and the 12 column thing will be a thing of the past. That said IE will continue to slow up progress for some years to come. Just chiming in. I am opting to start using grids now minus gaps because IE. |
Css grid is now handled by 88.17% of the browsers. See https://caniuse.com/#search=css-grid. |
@vincentdesmares I'd be interested in your thoughts regarding the comments from September 2017. Adding grid to tachyons is only partially useful IMHO. Defining grids is probably something that is hard to do in a functional way that is reusable for everyone. It is possible to define grids in a functional manner, I still haven't seen how one would do that in a reusable manner, especially when it comes to template definitions, area names etc. |
Sorry @mogsie, after reading all the comments of the thread I realize that it's indeed very difficult to find a pertinent implementation of css-grid for tachyons. I 100% agree on your answer from Sep 11, 2017. Why one would use a 12 column css-grid layout instead of a float-based? Because css-grid provides a very useful way to place an element wherever it's needed. Providing classes that do that would mean, as you said, that you would end with row X columns X window-size X properties classes. Which would bloat tachyons. After thinking a bit more about, I guess tachyons could still be useful for smaller use-cases, for example an out-of-the-box "header". But that would go against the tachyons way of composing generic styles. Those classes would be only useful in the very core of their promise. I think, after a few tachyons users will start to use css-grid, a few new abstractions will appear as easily re-usable and could be added as modules. But I agree that, right now, there is no good use cases to include css-grid in tachyons core. |
CSS Grid support just landed in Chrome, Firefox, Opera, and Safari (including iOS) in March 2017. As automatic updates go out in the coming days, Grid will be at ~72% support by the end of May (by my estimate). There is a polyfill to get support in IE9+.
CSS Grid is way more useful than Flexbox in my experience. Since Flexbox is part of core, I'd like to see Grid added as well. Or, rather than bloat core by adding classes for CSS Grid, we could remove Flexbox from core and make both Flexbox and CSS Grid into optional add-ons.
Thoughts?
(Related issue: #343)
The text was updated successfully, but these errors were encountered: