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

defining generateMedia breakpoints using type Number #30

Open
yairEO opened this issue Feb 18, 2021 · 2 comments
Open

defining generateMedia breakpoints using type Number #30

yairEO opened this issue Feb 18, 2021 · 2 comments
Milestone

Comments

@yairEO
Copy link

yairEO commented Feb 18, 2021

Hi, I love this package and would like to ask to allow configuring the generateMedia object with numbers instead of strings with units, so internally you will check the type and if it's a number you'll convert it to string and add px.

I ask this because this is how I use your package:

import { generateMedia } from 'styled-media-query' 

export const viewports = {
  mobile: "460px",
  l     : "1200px",
  xl    : "1800px",
  huge  : "2200px"
}

const media = generateMedia(viewports)

media.below = media.lessThan
media.above = media.greaterThan

export default media

As you can see, I renamed the methods because I didn't like the long names, I keep forgetting them, so the shorter the better for me. anyway, I am exporting the viewports variable because I need to use it in javascript as well, and I would prefer your library to understand the numbers mean pixels so I won't have to do the transformation on my end:

export const viewports = {
  mobile: 460,
  l     : 1200,
  xl    : 1800,
  huge  : 2200
}

it would be useful for others as well, this is why I ask this, instead of countless devs making it work with numbers, it would be useful if supported out-of-the-box as my request is not something out of the ordinary and many times there should be coupling because css and js values. (working DRY, avoiding possible bugs)

Thanks :)

@ApacheEx ApacheEx added this to the 2.3.0 milestone Mar 3, 2021
@ApacheEx
Copy link
Collaborator

ApacheEx commented Mar 3, 2021

Hello, this is a really nice idea 👍

Feel free to create a PR

@yairEO
Copy link
Author

yairEO commented Mar 4, 2021

Sorry but I have no time for PR since I am the owner of countless other repos and I have a TON of issues myself to to deal with in my own repos before coding for other's repos :) priorities... I simply gave you the suggestion for you to think about and hopefully code yourself or wait for another random person to come code it as a PR

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

2 participants