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

[Feature request] $mq should work as a function #46

Open
AndrewBogdanovTSS opened this issue Jan 27, 2020 · 4 comments
Open

[Feature request] $mq should work as a function #46

AndrewBogdanovTSS opened this issue Jan 27, 2020 · 4 comments

Comments

@AndrewBogdanovTSS
Copy link

AndrewBogdanovTSS commented Jan 27, 2020

Right now $mq is just a string - that is limiting its behavior significantly. I suggest to turn it into a function that could accept a string. That will enable true mobile-first experience. If an argument of specified breakpoint is passed - it should return true if it's currently within that breakpoint.
If a minus is added to the string - it will also include every breakpoint below the specified one.
If a plus is added to the string - it will also include every breakpoint above the specified one. Something like:

this.$mq('md') // will return true if screen width is == 'md'
this.$mq('md-') // will return true if screen width is <= 'md'
this.$mq('md+') // will return true if screen width is >= 'md'
this.$mq() // will return current breakpoint similar to how it's working now
@resu511
Copy link

resu511 commented Feb 16, 2020

Hello,
To achieve what you describe while not modifying the whole thing, I personally just defined my breakpoints starting from the letter of the latin alphabet, so that the comparison with > and < would work :

breakpoints: {
      a_xxs: 320,
      b_xs: 481,
      c_sma: 640,
      c_smb: 768,
      d_md: 1024,
      e_lg: 1280,
      f_xl: 1440,
      g_xxl: Infinity
 }

Salute

@madebycaliper
Copy link

@AndrewBogdanovTSS I totally agree..I love this package but it's sometimes a nightmare to use. I often use these two patterns:

['xs','sm'].includes($mq)`
// and
!['md','lg','xl'].includes($mq)

usage in templates like :

<component :class="[{ 'someClass': ['xs'].includes($mq) }]" />

you can wrap those statements into computed properties and I've even considered writing a mixin or attaching them to the Vue.prototype obj.

@AndrewBogdanovTSS
Copy link
Author

I guess the best solution would be a PR to this package 🙂

@madebycaliper
Copy link

Yea! @AlexandreBonaventure doesn't seem to be responding to community efforts. There are 11 PRs waiting to be approved...maybe its time someone forks this to an actively-maintained repo...?

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

3 participants