Grd – A CSS grid framework using Flexbox in 512 bytes gzipped
1000ch.github.io
1000ch.github.io
If you want to put things beside each other, make them whatever widths you want and have a flex row.
What do 'grid systems' add apart from visual classes in HTML and negative margin hacks?
Hell, the only reason I use Bootstrap is for it's buttons and forms, etc. which nowadays I've replaced with PureCSS; and the best part about PureCSS is that I can use the bits I want and ignore the rest. Bootstrap can also do that, but requires a preprocessor like Sass or Less (v4 and v3 respectively).
http://getbootstrap.com/customize/
Just untick the boxes for the stuff you don't want, and hey, Bob's your uncle. No Less or Sass required.
a) The concept of a typographic grid is a print layout design tool fundamentally unsuitable for coding flexible component-based layouts on today's web (it probably always was, but talking about a "grid" can give designers an air of technical mystique they quite enjoy ;)
b) Flexbox was invented to move beyond the grid. We don't want or need a grid anymore.
c) It takes less than 1 day's effort to learn the vanilla CSS flexbox API and you can re-create this "grid" if you really need it with a few lines of plain CSS. No framework dependencies, other developers don't have to learn the framework, and no polluting your markup with global utility classes.
This SO answer says [1]:
> a name must begin with an underscore (_), a hyphen (-), or a letter(a–z), followed by any number of hyphens, underscores, letters, or numbers. There is a catch: if the first character is a hyphen, the second character must be a letter or underscore, and the name must be at least 2 characters long.
[1]: http://stackoverflow.com/a/449000
Which references the CSS Grammar spec [2].
I've been enjoying Lost (https://github.com/peterramsing/lost) with PostCSS for grids recently - it has Flexbox support which works well and keeps grid class names out of my markup.
Re: this post
Grd doesn't do anything interesting at all. Everyone is blindly obsessed with flexbox. Grd doesn't even concern itself with gutters.
Here's something I cooked up in 5 minutes that does more with less code: http://codepen.io/corysimmons/pen/eZgZzz?editors=1100
.Grid.\-stretch { align-items: stretch; }[1] = https://www.w3.org/TR/CSS21/syndata.html#vendor-keywords
It means that this `.-stretch` needs a class `.Grid` on the same element
The source leverages calc for simple width percentages, so on android browser below 47 these values won't calculate at all: http://caniuse.com/#feat=calc.
> Partial support in Android Browser 4.4 refers to the browser lacking the ability to multiply and divide values.
Why wouldn't the author change this to:
.Cell.\-1of12 { width: calc(100% * 3 / 12); }
to
.Cell.\-1of12 { width: 25% ; }
It seems silly to go through the trouble of installing a lib when it gives you less browser support than flexbox itself.
It's a pretty odd use for a preprocessor.
Each mixin is only used once (so why bother?) and the calcs are turned into percentages by the compiler (so why bother?)
I have a CSS code that looks like this for a good reason:
left: calc(100% + 2em)
that I'd like it to be changed to support legacy stock Android browsers.Size and therefore speed is important on the web, but it seems an easy mental trap to optimize it at the expense of the other important things.
The live demo doesn't work for me
The only problem here is that "who cares" if it is a "cute name". This isn't really DRY in a non-trivial sense. I mean, yet another grid system that calls grid-like things "grids". Yergh! Go read Brian Cantwell Smith's paper on "semiotic alchemy". More practically, I would say that all the points about filesize and what not are sadly irrelevant as true sources of anger. I honestly see this as no different as someone getting angry with someone else because they bought a foreign part to put in an American car. More puffery!
We have 7 "big" problems in CSS today:
Global Namespaces,
Dependencies,
Dead Code Elimination,
Minification,
Sharing Constants,
Non-deterministic Resolution,
Isolation.
What happened to the pursuit of truth? Alright. You put a framework on your résumé? But are you a computer scientist? Are you defending an idea? Or simply leveraging an old one?We take and depend on a lot of code today. But now we are taking and depending on higher order concepts or principles to give the illusion of pursuit... of something.
This is a "grid system" only in name insofar as it surely is detached from the idea of why grid systems were invented, mostly assuredly, to solve problems.
The "filesize" problem of CSS is like the "filesize" problem of Bitcoin. It's just that nobody really likes CSS or knows they can build Turing Machines in it, so they hate you for it. Whereas in Bitcoin, it gets you a seed round to test yr vaporware. At least these little CSS publications don't cost society that much, I guess..
Typically when I venture down this path of "system building" in CSS land, I use Organic CSS[0] because it promotes fun, thinking, creativity, and gives me a scientific scheme within which to treat those 7 problems listed above.
Does this grid framework solve any of those problems listed above? Is it even concerned with them? Are devshops aching to refactor to the next tiniest grid system? Are we really looking to shave off submilliseconds from our HTTP requests? I mean, we have HTTP/2... so do those submilliseconds really matter these days?
er mah GRD, it's amazing!
You DO NOT NEED to use bower or npm to install this, you can easily find the source and bring it in to your project if you want to use this. Npm does provide you with a way to upgrade this without digging around, but you don't have to use it, so stfu, go find your file on the Internet, copy it to your css directory.
A reason a flex grid could be cool, it provides you a standard across your application. When you one-off every time you need to have elements behave in a grid-like fashion, you run a much higher risk of ending up with inconsistencies. Unless you yourself write some code that reliably makes things behave like a grid, hey that's called a grid.
I get that there are a lot of tools available, but this recent attitude of just slamming people because they created something that isn't aligned with your ideals is not healthy or progressive. There is no implication that because this exists anyone else has to use it. It's just code someone wrote and happened to end up here. Let it be.
We are in 2016. If you are a front end developer and you do not have at least one terminal opened in the front end directory of your website ready to run NPM or Bower and you are still managing your dependancies manually, there is something very wrong with your workflow.
The vicious cycle of furious evolution in JavaScript is proving "too fast for comfort" for many of us. We do not all live entirely in the JavaScript ecosystem and no longer have the capacity to keep up with it. However remains the only language we can use in the browser so we are forced to use it and as it continues to accelerate, it becomes like an uncomfortably aggressive personal trainer screaming at us to "push harder" and trying to goad us into moving quicker.
We do not have the choice to use JavaScript or not, so when it feels like is it angers us. We feel the parts of the JavaScript development community that push this ever faster, have taken no one else into account and are no longer interested in being good citizens of the web in cooperation with all us other developers. We feel understandably uncomfortable with this sudden "aggressive independence" in the JavaScript community.
I'm quite sure a non trivial portion of the support for WebAssembly is because we want an alternative to JavaScript that enables us to escape from this situation. Many developers I talk to are eager to see their language of choice integrated via WASM so the are no longer forced to use JavaScript and much of the desire stems from being ever more unhappy with the direction of the JavaScript community.
Everyone is entitled to their opinion, so many of us are glad we will soon have a place where our opinion matters too, not only the opinions of JavaScript developers.
I get that the javascript world moves pretty fast. On the other hand, what you seem to be saying is, "I don't understand this, _and I do not want to expend the effort to understand it_, so therefore it is bad".
There's a lot of things I don't understand, and frankly don't have the time, energy, or training to understand. I leave those things to the engineers who actually worry about them. Example: I can write and optimize SQL queries, but I don't want to work on postgres internals. If you want to be a javascript developer, you should pay attention to the state of the art.
FWIW: npm isn't in control of modern javascript development. You are still able to manually find new libraries, download them, add them to your assets directory, include them, and so on. This workflow never stopped working. All npm does is provide a centralized list of library versions and their locations, along with a syntax for declaring dependencies. My current project needs to do some image manipulation, so npm handles downloading and building the mmagic libraries for my development architecture. I could do this on my own, but this is just easier.
If it's too hard for you, just do it the old-fashioned way. If you choose to publish a library and not provide npm/bower support because you're old-fashioned, however, don't expect wide adoption.
While I'm sure that some as you say "do not want to expend the effort"... I and many others do not have the time left in our days to expend the effort in. As you go on to say, an individual's time and energy are finite. In my case and many other developers cases, the thing we are skilled at is/was web development, which was fine until the effort necessary to keep up with JavaScript and 'client side web development' grew to outpace our remaining time.
I want to continue to be a web developer, I have years of practice with this... which apparently means fuck all to most people hiring these days because despite being a good python developer that knows my way around the Django web framework, I can't find the time to work on Django, all the other things I do, like the spare time I've spent learning Django's ORM well enough to begin trying to write a RethinkDB back-end for it... AND after all that, start to rapidly learn the last 3 years of JavaScript in order to catch up to other 'web devs' and become competitive in the job market as web developer again?
Because I don't live and breath Ember, Angular, React or whatever new one comes out tomorrow... I'm not a good web developer? "Web developer" suddenly transformed into "JavaScript Developer" while me and others like me weren't looking...? Last time I checked, the web is more than JavaScript, yet we are marginalised by the web development community because the bulk of them are off gazing ever deeper into their own navels. I don't even mean that insultingly, "navel gazing" as a euphemism for being 'introspective' is about the only way to explain the 'staring inwards' that seems to be going on in the JS community, the transpilers, then Babel, ES6, ES7, and onwards, before they are done with one version there are transpilers from the next ultra experimental one to come from the future, to the one from yesterday, in order to implement the one from last Tuesday... which is the one that transforms all my CSS into JavaScript... and I'm already losing myself in my description of how convoluted the ecosystem can get.
From where I sit, though, it isn't necessarily about react, ember, angular, or whatever. It is about javascript in particular. The shiny parts of the webworld are moving from CRUD style server side apps to client side rendering and SPAs.
For regular CRUD apps and a lot of other places, a server language like Python, Ruby, or Java are still pretty useful. But it really does seem like the future is interactivity, which for the time being means JavaScript. Languages like Python are likely destined to be (modulo wasm) backend ones that generate API endpoints and straightforward, noninteractive CRUD pages.
Of course that definition of 'future' is fleeting. In a few years I'll be bemoaning the churn in whatever new language ecosystem has turned the exponential corner.
Those are simply two tools used by the JS community to manage its dependancies. There are a lot[1] of them.
Where I work, everything was pushed by the back-end guys for a long time. This made the front-end developer dependant on them. With tools that use front-end languages (JavaScript), the front-end team is now free to experiment with package management and build systems (Grunt.js, Gulp.js). This made it so that we now have a very complex but quick and useful front-end workflow. We wouldn't have this if we had not freed the front end team dependancy on the back end team for builds, dependancies, etc.
[1] https://www.npmjs.com/ http://bower.io/ http://duojs.org/ http://webpack.github.io/ https://github.com/componentjs/component http://enderjs.com/ http://jamjs.org/ http://volojs.org/ etc.
All of those are valid:
{ "dependencies" :
{
"foo" : "1.0.0 - 2.9999.9999",
"bar" : ">=1.0.2 <2.1.2",
"baz" : ">1.0.2 <=2.3.4",
"boo" : "2.0.1",
"qux" : "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0",
"til" : "~1.2",
"elf" : "~1.2.3",
"two" : "2.x",
"thr" : "3.3.x",
"lat" : "latest"
}
}Which would be, go to where project is hosted, find out what version you're looking for, click until you find actual source, copy text or download file, move file from downloads to your repo, or paste in to a new file in your repo.
TMPDIR=$(BASEDIR)/tmp
THEME=$(BASEDIR)/theme
THEME_CSS=$(THEME)/css
THEME_FONT=$(THEME)/fonts
THEME_JS=$(THEME)/js
VER_BOOTSTRAP=3.3.6
VER_FONTAWESOME=4.5.0
VER_JQUERY=2.2.1
updatedeps: $(TMPDIR) bootstrap fontawesome jquery
bootstrap:
curl -L -o $(TMPDIR)/bs.zip https://github.com/twbs/bootstrap/releases/download/v$(VER_BOOTSTRAP)/bootstrap-$(VER_BOOTSTRAP)-dist.zip
unzip -j $(TMPDIR)/bs.zip bootstrap-*/js/bootstrap.min.js -d $(THEME_JS)
unzip -j $(TMPDIR)/bs.zip bootstrap-*/css/bootstrap.min.css -d $(THEME_CSS)
fontawesome:
curl -L -o $(TMPDIR)/fa.zip https://fortawesome.github.io/Font-Awesome/assets/font-awesome-$(VER_FONTAWESOME).zip
unzip -j $(TMPDIR)/fa.zip font-awesome-*/css/*.min.css -d $(THEME_CSS)
unzip -j $(TMPDIR)/fa.zip font-awesome-*/fonts/*webfont* -d $(THEME_FONT)
jquery:
curl -L -o $(THEME_JS)/jquery.min.js http://code.jquery.com/jquery-$(VER_JQUERY).min.js <Makefile sed -E 's/.*:$//; s/\(|\)//g; s/^updatedeps:.*/mkdir -p $TMPDIR/' > update-deps.sh
BASEDIR=$PWD sh ./update-deps.sh
Make is for generating output from interdependent input. It can be used for minifying your JS, or compiling your CoffeeScript in to js, or your sass (but that is handled mostly by respective compilers, tho I prefer running the compiler myself) (also, I don't use coffeescript or sass, so IDK if I'm mistaken).Nowadays, and quite suddenly, javascript is at the center of everything. Java applets? Flash? Everything's imploded. On top of that, we're revolutionizing the language (block-lexical scoping, classical OO syntactical sugar, standardizing import/export, promises, generators, async/await, optional type annotations) in a way that improves productivity and the reach of the language.
There's a lot of churn in tooling and tools, because things are new. I've been doing software since before the STL and generics in c++, and I can say that I've seen this kind of churn before. It happens with lots of languages when they turn the corner in real exponential growth. I'd say it used to be the case that there were far fewer programmers in general, and they were a far more homogeneous lot than they are now (we still have a long way to go on that front, of course), so standardizing around autoconf and make was easier than standardizing around (say) ant vs maven or grunt vs gulp.
To the original issue - I've been doing a lot of flexbox work lately, and one of the more annoying issues is dealing specifically with grids. If you just use flex-grow like a good flexboxer, stuff doesn't align well in columnar format on your page. Flexbox is great for some things, but handy macros for making a grid out of flex boxes are pretty useful. Useful enough that I ended up writing pretty much the same thing myself anyway, and useful enough that it makes sense to hoist some of that code out into a standalone library. That way, you can encapsulate fixes for browser quirks (shakes fist safariiiiiii!), and have the option to pull the whole thing into new projects or leave it out if you don't need it.
People can complain about making a spiffy project page for a small library, but hey. People complain about a lot of things. Those kids, for example, on my lawn. I installed a motion-controlled sprinkler to keep them off, but those wacky kids are still on my lawn.
Grunt gulp bower less sass npm node yeoman brunch underscore moustache… Whenever our frontend devs insist they need whatever deployed on all our servers yesterday, I nod and smile and count the days until they've completely forgotten about it and yell for the next shiney new toy that's totally going revolutionize JS development. This time for real.
Meanwhile I'll stick to my makefiles, thank you very much.
You included underscore, which might as well be named "utils.js", alongside moustache, which is a templating tool, and Grunt/Gulp/Bower/npm, which are build or dependency management tools that have some real complexity.
These things are not like each other! It seems like you're just complaining about a bunch of things based on little more than what their name is.
I only know the name, because they disappear faster from our tool chain than I (as strictly ops/backend person) can keep up with familiarizing myself with them. The tool churn in the frontend world is insane.
Aha!
Vagrant, Docker, Chef, Ansible, Fabric, Puppet, Jenkins, Octopus, TeamCity, Sentry, SVN, Git, AWS, Azure...
We all have monkeys on our backs. We all search for the best tools to use to make our lives easier and our products better and more reliable. When something new or improved comes out, we evaluate it, we weigh its use against everything from performance to code quality to backwards compatibility to having everyone learn yet another tool/library. If the benefits outweigh the drawbacks, then we make the switch. If not, then we leave our tool chain as it is.
Are there people who blindly switch to the Next Big Thing (tm) every 3 months? Yes. But I've found that in general they are few and far between. Perhaps you happen to work with one or more, but know that the entire web-dev community discourages that behavior.
We've done the jQuery -> Angular -> React mambo. The RoR -> Node.js mambo. The Grunt -> Gulp -> Webpack mambo. The underscore -> lowdash mambo... I could go on. That's without even counting the CSS related fads.
Another thing I've noticed is that we've gone from projects trying to optimize for minimal JS and are light on browser resources, to installing multiple megabytes of Bower/Webpack/NPM dependencies and pages that perform (pardon my French) like crap. Famously, one of our backend devs wrote a Chrome extension that would disable the animated backgrounds in a bunch of stuff because they sucked our laptops' batteries.
So I feel the pain of poster who said it's become almost impossible to support JS projects unless that's your daily job. The tool churn is too big and don't get me started on all the new terms ("isomorphic websites", "polyfills", "shims", etc.) that seem to pop up every couple months.
I understand it's growing pains of a maturing ecosystem, it's just that the churn speed is insane.
Fair point! Although I'm just as tired of the rat race there, too. Of all the things listed, we're only using Git. I've looked at most, but I'm not bothering implementing it unless it's a huge benefit over the status quo. Chances are, better solutions will be around before we've finished migrating to the last Next Big Thing. I wish development finally got that memo.
There is a metastasis of so-called tools in the web-dev world nowadays. Setting up a moderate C project is way easier and less tools-involved than setting up a HTML-CSS thingy following the fashion of today. This one project in particular sports upwards of ten files to distribute what's worth a half page of CSS.
If there's a library that I use across all my projects, then I just subscribe to its syndication (mostly VCS RSS feeds for me). And then I fetch it if the changes are of my interest, or there are bugfixes. All these other tools are completely superfluous. How many hours are lost in your shop setting these pieces of crap up instead of just downloading the file and putting it in your assets directory? The whole web dev business of today is a big stupid mess of people who have no clue what they're doing.
The amount of hours lost setting up "these pieces of crap" is effectively zero, I type `npm install --save <insert lib>` and I'm on my way. If I need changes that are of interest to me, I type `npm update <insert lib>`. But guess what, that's not the only way to do things. I also download files and drop them in. I analyze each situation and make a decision. I am glad you think we don't know what we're doing, because it shows that you have no idea what we're doing either.
I like package managers because it saves me having to clutter up my git repositories with copies of my dependencies' JS files. You just have one package.json file for NPM, run npm install and you're done...
This is why I don't hang out with developers
I think we're blessed that the discussions in this forum are usually constructive & critical but respectful at the same time.
Where does this recent comment of mine fall? It is snarky but isn't it also substantive? I guess I could have left out the snark.
"I love it. We had servers, then we had clouds, and now we have personal clouds. Uh, isn't that a server?"
Syntax error at line 109 while loading: unexpected character: U+0060
grid.className = `Grid ${align.value}The framework itself looks handy and simple enough, but there's probably already about 10 other flexbox layout frameworks out there that works just as good too. Here's another one: http://gridlex.devlint.fr/
I actually think it was nice of the developer to say "Hey, you can install this with npm or bower". And if you don't like either, you can grab the source yourself. Or you can just not use it and move on.
I wouldn't use this myself just because I think using flexbox on its own is great. And there are plenty of problems in web development today. But calling it "insane" just feels like you were looking for something trivial to get upset about.
But I do agree that web dev tooling could use a lot of work. Grd did not set out to solve that.
A 4 page static website, for example, shouldn't need model view controller, package manager, routing, etc.
I tend to err on the side working as simple as possible. Adding tools only when things seem like they can get out of hand, not before.
https://raw.githubusercontent.com/1000ch/grd/gh-pages/dist/g...
I'm honestly not seeing what is there to complain about.
Imagine someone posting a repo of their alternatively-named C integer typedefs on here.
nt
An integer framework using stdint.h
Simple
It's just a header file
Light-weight
It's like 10 lines
Flexible
You can do anything
...
#include <stdint.h>
typedef int32_t nt32;
...There was once a time when you could mock ridiculous things without being "traumatized" by them.
It's a clear sign of people with no clue about proper software engineering, which is glaring in today's front end world where dependencies and tools have gone amok to manage mere hundreds lines of CSS or Javascript.
Just provide a download link to the min file and be done with it.
Similar to the prejudice that every high-level programmer from so many idiot low-level programmers who think because they mess about with pointers all day they are "real" programmers.
I just started to use npm (and indeed package managers in general) for my work recently and it's opened my eyes. It makes sense to me that this will be the preferred way of working for every dev/designer. Just as we mostly all use git now. It's hard to imagine that time when we just shared files via FTP and didnt use version control. I'd encourage anybody like me who was resistant, or working on a large code base that doesn't use those tools - give it a fair try on a side project.
And if you entire dependency chain for your project is half a Kb of CSS that's a valid point, I'd like to see that project though.
Dependency management for front-end/browser assets is sorely needed, the problem at the moment is that we have too many of them and no clear standards have emerged yet, npm/require() is as close as we've got though and I'll take it for now.
have you ever taken on a code base with thousands of lines of copy pasta code?
tried to update or workout dependencies/conflicts when the dude before you just dumped a bunch of jquery plugins (some hacked) in a directory?
give me a package.json any day! mmmm.. structured data.. nom nom nom
Some of the times. What I am bitching about is that I can't get around NPM/Bower and other bullshit, I have to use it for a lot of these libs, regardless of me needing them.
I am the only one who should judge what are the best practices for the project I am working on, not some clueless Javascript hacker (cheap shot I know). What I'm complaining about is that front end "developers" seem to all be unaware of a few staple principle of software engineering: keep it simple and right tool for right job. I've used NPM, Bower, Gulp, and others, when it was needed but from over a decade of experience in the web I can assure you that 90% of the time, it's superfluous.
It generates developers who don't know how their own code works or interact, and who for the major part end up over engineering everything they touch for no goddamn reason.
Plus I always end up spending more time dealing with those stupid tools than coding, and if Java taught me anything it's that this is the clear sign of a very ill and insane dev culture.
You do realize that downloading the CSS/JS for these libs is trivial, nothing is forcing you to use Bower/NPM/<insert lib management tool here>.
You may find this article to your agreement: http://www.satisfice.com/blog/archives/27
Not that hard right?
This isn't a complicated, full featured grid... those definitely need dependency management.
If you are new to flexbox, the CSS file is a helpful demonstration I guess. Flexbox is way more powerful, and far more flexible, than this grid alone though.
Why does everything have to be this huge library to be used? Why can't I pull in 30 small libs that composed? I'm a Node.js developer, our ecosystem is built around small focused modules that do one thing and one thing well. Sometimes you can write the 1 line yourself, or pull in a module and know that if anything changes that could affect that line of code, someone somewhere will notice it before you and update the module. Congratulations you just saved yourself hours of debugging because someone else did it for you.
In this case, however, we are talking about pretty basic CSS. There are some standards for page layout, but there is no One True Way to design a web page front end... all designs are different. Small CSS like this (as a library) in effect make design decisions for you and I don't think CSS is difficult enough for this to be justified.
As an example (without manually editing the CSS at least, which defeats the point of the NPM / Bower installs), this grid CSS locks you in to arbitrary divisions of 12. What if your grid requires 5 evenly spaced columns? You can't do that.
YOU don't think it is. Neither does my buddy who works in CSS/SASS, but I do. Because I don't do styling. I'm mostly a backend developer.
> What if your grid requires 5 evenly spaced columns? You can't do that.
I just did it easily by 5 elements and putting them as `-fill`. 5 evenly spaced columns. I wouldn't have been able to do that without this lib because I don't know CSS that well, nor flexbox. This library just saved me tons of time, just to do what you said it can't.
Granted, in this case the library is exceptionally lightweight, but its still a 3rd party dependency and should be treated as such. It still gets injected into the codebase at the end of the day, and can be vendored if required.
Don't like micro frameworks? Install bootstrap or foundation.
Why would anyone even want anything like it?
E: Nice to see again how childish HN is, downvoting when someone points out that the thing is broken and asks a serious question. This is why I originally left this place.
(I guess this is largely culture related thing, but e.g. among my peers (high educated 30s Europeans) gender-biased words actually cause more distraction.)
And anyway, I think you'd have been better off just saying, "I wish we could all agree...."