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

Breakpoint Generator (CLI support) #13

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

zehfernandes
Copy link

@zehfernandes zehfernandes commented Oct 4, 2016

Hey,

To solve the problem of creating new breakpoints and update them along the project. I try to create the most unobtrusive breakpoint generator. I love the simplicity and the independence of each tachyons step. So I try to respect that:

  1. The generator is outside of CSS files, is optionally available in the tachyons-cli
  2. you can parse a single file or an entire directory (works for the modules or the entire build)
  3. The CLI extract the @customMedias from the file. You can use with _variables.css, _media-queries or the module css file
  4. Per default, the code don't overwrite media queries already on file, so if you modify _typography.css and forget some breakpoint, the code will maintain your code and add the new media query.
  5. The build by tachyons-css remain. Everything happens pre-build.

How it works

I wrote a generic postcss plugin called postcss-update-media-queries a specific wrap module tachyons-build-mediaquerie to help the tachyons-cli functions.

Usage

$ tachyons /src --customMedia --variables=src/_variables.css --overwrite=false

input

/*Variable.css*/
@custom-media --breakpoint-not-small screen and (min-width: 30em);
.underline { text-decoration: underline; }
.strike { text-decoration: line-through; }

output

.underline { text-decoration: underline; }
.strike { text-decoration: line-through; }
@media (--breakpoint-not-small) {
 .underline-ns { text-decoration: underline; }
 .strike-ns { text-decoration: line-through; }
}

Look at tachyons-bulild-mediaqueries to see more.

Future thoughts

Has a lot of things to improve like error messages, return promises (to have a better control), ES6 standard, decent tests, naming...

But taking a look and see if is useful for the major project.

P.S: @johnotander I read a lot of your code to have insights to do that. Thanks :)

@johno
Copy link
Member

johno commented Oct 4, 2016

@zehfernandes 100% absolutely love this. I've only just had a quick glance at the code and the concept, but this is exactly what we'd like to incorporate into the project (via options of course). We've come across use cases to not only change media queries, but to add them as well. If a project wants to have 4, 5, or even more breakpoints we would love to provide an official mechanism. Tachyons should be able to target watches and televisions, too 😎 .

This will especially fit in nicely for some future Tachyons projects we're working on:

It will be a day or two before I can give a thorough review and start the process of adding this to the next version of the cli. But, I wanted to let you know that I love where this is headed and that you can expect a more formal response with review in the next 24 to 72 hours.

Thanks! 🍻 💯

@zehfernandes zehfernandes reopened this Oct 4, 2016
@zehfernandes
Copy link
Author

OHH! This JSON config file is amazing. 😍

@zehfernandes
Copy link
Author

zehfernandes commented Jan 9, 2017

Update:

The output code of tachyons --customMedia contains whitespace in variable name

.pa0 { padding: var( --spacing-none ); }

The plugin postcss-css-variable has an issue MadLittleMods/postcss-css-variables#27 about the CSS4 spec considering --spacing : different from --spacing:


FIXED using Perfectionist compressed option to remove whitespaces.

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

Successfully merging this pull request may close these issues.

None yet

2 participants