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

merge libs? #1

Open
yocontra opened this issue Jan 13, 2015 · 11 comments
Open

merge libs? #1

yocontra opened this issue Jan 13, 2015 · 11 comments

Comments

@yocontra
Copy link

Hey there -

Your lib looks cool, I want to use it instead of some stuff I wrote for react-responsive

Here is my stuff:

https://github.com/wearefractal/react-responsive/blob/master/src/toQuery.js

I think negation might be the only missing feature from json2mq - want to have a look at the code and see if there are any other gaps?

@akiran
Copy link
Owner

akiran commented Jan 14, 2015

Hey,

Its cool. Let us discuss to cleanup API.

The main difference between toQuery.js and json2mq now is
json2mq turns {type: 'screen' , maxWidth: 1200} -> 'screen and (max-width: 1200px)'
toQuery turns {screen: true, maxWidth: 1200} -> 'screen and (max-width: 1200px)'
Am I right ?

In addition to not keyword , media query also support only keyword . How should we handle it ?

I introduced type in json2mq because I am doubtful whether
{screen: true} should turn into'screen'or 'only screen'.

With type users can add not and only keywords in string format
{type: 'only screen'}
{type: 'screen and not (handheld)'} etc.

What do you think ?

@yocontra
Copy link
Author

@akiran I think that only and not are details of the media query that the user shouldn't need to know about. The whole idea is to hide that ugliness away from the user so they can stick to what they already know, JSON - right?

@akiran
Copy link
Owner

akiran commented Jan 15, 2015

@contra, I agree. It would be nice if every thing is in JSON.

API for not keyword is straight forward.
{handheld: false} turns into not (handheld)

API for only keyword is slightly tricky.
{screen: true} should it turn into 'screen' or 'only screen'
Any ideas for solving this ?

@yocontra
Copy link
Author

@akiran What exactly does the only keyword do?

@akiran
Copy link
Owner

akiran commented Jan 15, 2015

From this article

The only keyword prevents older browsers that do not support media queries with media features from applying the given styles

From what I understand, only keyword is required for old browser support.
Can we ignore only for now and mention in the docs that json2mq supports only modern browsers ?

@yocontra
Copy link
Author

@akiran So it doesn't actually change he behavior of a media query? That seems kind of silly...

@akiran
Copy link
Owner

akiran commented Jan 15, 2015

Yes, at least that what I understood from that article.

@akiran
Copy link
Owner

akiran commented Jan 15, 2015

from the css-tricks article

Note the only keyword was intended to prevent non-media-query supporting browsers to not load the stylesheet or use the styles. Not sure how useful that ever was / still is

@yocontra
Copy link
Author

@akiran I think we can ignore that, it doesn't seem like something in effect today

@akiran
Copy link
Owner

akiran commented Jan 15, 2015

I will go ahead and make the changes .
API will be
{ screen: true, maxWidth: 1000} -> 'screen and (max-width: 1000px)'
{handheld: false, maxWidth: 1000} -> 'not handheld and (max-width: 1000px)'

@akiran
Copy link
Owner

akiran commented Jan 15, 2015

@contra Made a 0.2.0 npm release
Checkout and let me know your feedback

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

No branches or pull requests

2 participants