Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Media query boundaries #26

Open
rosshulford opened this issue Oct 24, 2018 · 3 comments
Open

Media query boundaries #26

rosshulford opened this issue Oct 24, 2018 · 3 comments

Comments

@rosshulford
Copy link

rosshulford commented Oct 24, 2018

I have the following custom breakpoints

Vue.use(VueMq, {
  breakpoints: {
    xsmall: 500,
    small: 768,
    medium: 1024,
    large: 1360,
    xlarge: 1800
  }
});

I want to do the following

 <span v-if="$mq==='small'>
       some text
            </span>
    <span v-else>
           diffrent text
 </span>

The text does change but as soon as I resize to the 'medium' breakpoint it reverts.

This would work but is a bit messy, is there not a way to check for small or above?

 <span v-if="$mq==='small' || $mq=='medium || $mq == 'large' || $mq == 'xlarge">
       some text
            </span>
    <span v-else>
           diffrent text
 </span>
@MarcoGomesr
Copy link

MarcoGomesr commented Oct 29, 2018

$mq property provide a wrapper component to facilitate conditional rendering with media queries.

<mq-layout :mq="['small', 'medium', 'large','xlarge']">
  <span> Display on small medium large and xlarge</span>
</mq-layout>

or

<mq-layout mq="small+">
  <span> Display on md and larger </span>
</mq-layout>

@entioentio
Copy link

entioentio commented May 22, 2019

meanwhile
...Shouldn't it be closed?

@Kezhich
Copy link

Kezhich commented Nov 23, 2020

$mq property provide a wrapper component to facilitate conditional rendering with media queries.

<mq-layout :mq="['small', 'medium', 'large','xlarge']">
  <span> Display on small medium large and xlarge</span>
</mq-layout>

or

<mq-layout mq="small+">
  <span> Display on md and larger </span>
</mq-layout>

Hi!
Can I make it simplier inside a computed property?

Like:

computed: {
getText() { return this.$mq === "sm" && this.$mq === "tb" ? "small text" : "large text"}
}

To:

computed: {
getText() { return this.$mq >= "tb" ? "small text" : "large text"}
}

Or something like that.

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

No branches or pull requests

4 participants