18 |
19 |
20 |
23 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/index.js:
--------------------------------------------------------------------------------
1 | // https://vitepress.dev/guide/custom-theme
2 | import { h } from "vue";
3 | import HomeImage from "./HomeImage.vue";
4 | import DefaultTheme from "vitepress/theme";
5 | import "./style.css";
6 | import { Vue3Mq } from "../../../src";
7 |
8 | /** @type {import('vitepress').Theme} */
9 | export default {
10 | extends: DefaultTheme,
11 | Layout: () => {
12 | return h(DefaultTheme.Layout, null, {
13 | // https://vitepress.dev/guide/extending-default-theme#layout-slots
14 | "home-hero-image": () => h(HomeImage),
15 | });
16 | },
17 | enhanceApp({ app, router, siteData }) {
18 | app.use(Vue3Mq);
19 | },
20 | };
21 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/style.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Customize default theme styling by overriding CSS variables:
3 | * https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css
4 | */
5 |
6 | /**
7 | * Colors
8 | *
9 | * Each colors have exact same color scale system with 3 levels of solid
10 | * colors with different brightness, and 1 soft color.
11 | *
12 | * - `XXX-1`: The most solid color used mainly for colored text. It must
13 | * satisfy the contrast ratio against when used on top of `XXX-soft`.
14 | *
15 | * - `XXX-2`: The color used mainly for hover state of the button.
16 | *
17 | * - `XXX-3`: The color for solid background, such as bg color of the button.
18 | * It must satisfy the contrast ratio with pure white (#ffffff) text on
19 | * top of it.
20 | *
21 | * - `XXX-soft`: The color used for subtle background such as custom container
22 | * or badges. It must satisfy the contrast ratio when putting `XXX-1` colors
23 | * on top of it.
24 | *
25 | * The soft color must be semi transparent alpha channel. This is crucial
26 | * because it allows adding multiple "soft" colors on top of each other
27 | * to create a accent, such as when having inline code block inside
28 | * custom containers.
29 | *
30 | * - `default`: The color used purely for subtle indication without any
31 | * special meanings attched to it such as bg color for menu hover state.
32 | *
33 | * - `brand`: Used for primary brand colors, such as link text, button with
34 | * brand theme, etc.
35 | *
36 | * - `tip`: Used to indicate useful information. The default theme uses the
37 | * brand color for this by default.
38 | *
39 | * - `warning`: Used to indicate warning to the users. Used in custom
40 | * container, badges, etc.
41 | *
42 | * - `danger`: Used to show error, or dangerous message to the users. Used
43 | * in custom container, badges, etc.
44 | * -------------------------------------------------------------------------- */
45 |
46 | :root {
47 | --vp-c-default-1: var(--vp-c-gray-1);
48 | --vp-c-default-2: var(--vp-c-gray-2);
49 | --vp-c-default-3: var(--vp-c-gray-3);
50 | --vp-c-default-soft: var(--vp-c-gray-soft);
51 |
52 | --vp-c-brand-1: #065f46;
53 | --vp-c-brand-2: #047857;
54 | --vp-c-brand-3: #10b981;
55 | --vp-c-brand-soft: #a7f3d0;
56 |
57 | --vp-c-tip-1: var(--vp-c-brand-1);
58 | --vp-c-tip-2: var(--vp-c-brand-2);
59 | --vp-c-tip-3: var(--vp-c-brand-3);
60 | --vp-c-tip-soft: var(--vp-c-brand-soft);
61 |
62 | --vp-c-warning-1: var(--vp-c-yellow-1);
63 | --vp-c-warning-2: var(--vp-c-yellow-2);
64 | --vp-c-warning-3: var(--vp-c-yellow-3);
65 | --vp-c-warning-soft: var(--vp-c-yellow-soft);
66 |
67 | --vp-c-danger-1: var(--vp-c-red-1);
68 | --vp-c-danger-2: var(--vp-c-red-2);
69 | --vp-c-danger-3: var(--vp-c-red-3);
70 | --vp-c-danger-soft: var(--vp-c-red-soft);
71 | }
72 |
73 | html.dark {
74 | --vp-c-brand-1: #6ee7b7;
75 | --vp-c-brand-soft: #064e3b;
76 | }
77 |
78 | /**
79 | * Component: Button
80 | * -------------------------------------------------------------------------- */
81 |
82 | :root {
83 | --vp-button-brand-border: transparent;
84 | --vp-button-brand-text: var(--vp-c-white);
85 | --vp-button-brand-bg: var(--vp-c-brand-3);
86 | --vp-button-brand-hover-border: transparent;
87 | --vp-button-brand-hover-text: var(--vp-c-white);
88 | --vp-button-brand-hover-bg: var(--vp-c-brand-2);
89 | --vp-button-brand-active-border: transparent;
90 | --vp-button-brand-active-text: var(--vp-c-white);
91 | --vp-button-brand-active-bg: var(--vp-c-brand-1);
92 | }
93 |
94 | /**
95 | * Component: Home
96 | * -------------------------------------------------------------------------- */
97 |
98 | :root {
99 | --vp-home-hero-name-color: transparent;
100 | --vp-home-hero-name-background: -webkit-linear-gradient(
101 | 120deg,
102 | #44c38a 30%,
103 | #047857
104 | );
105 |
106 | --vp-home-hero-image-background-image: none;
107 | --vp-home-hero-image-filter: blur(44px);
108 | }
109 |
110 | @media (min-width: 640px) {
111 | :root {
112 | --vp-home-hero-image-filter: blur(56px);
113 | }
114 | }
115 |
116 | @media (min-width: 960px) {
117 | :root {
118 | --vp-home-hero-image-filter: blur(68px);
119 | }
120 | }
121 |
122 | /**
123 | * Component: Custom Block
124 | * -------------------------------------------------------------------------- */
125 |
126 | :root {
127 | --vp-custom-block-tip-border: transparent;
128 | --vp-custom-block-tip-text: var(--vp-c-text-1);
129 | --vp-custom-block-tip-bg: var(--vp-c-brand-soft);
130 | --vp-custom-block-tip-code-bg: var(--vp-c-brand-soft);
131 | }
132 |
133 | /**
134 | * Component: Algolia
135 | * -------------------------------------------------------------------------- */
136 |
137 | .DocSearch {
138 | --docsearch-primary-color: var(--vp-c-brand-1) !important;
139 | }
140 |
141 | .block {
142 | display: block;
143 | }
144 |
--------------------------------------------------------------------------------
/docs/changelog/v2.1.0.md:
--------------------------------------------------------------------------------
1 | # v2.1.0: Update Breakpoints
2 |
3 | An update function is now provided by the plugin which allows components to dynamically change the breakpoints that are responded to.
--------------------------------------------------------------------------------
/docs/changelog/v2.2.0.md:
--------------------------------------------------------------------------------
1 | # v2.2.0: New `` Minus and Range Prop Selectors
2 |
3 | When using the `` component within your Vue 3 app, you'll now be able to use 2 additional selector types:
4 |
5 | - Minus: `mq="lg-"` - Will render on lg or below breakpoints... NEW
6 | - Range: `mq="xs-md"` - Will render on any screen sizes between xs and md... NEW
7 | - Plus: `mq="md+"` - Renders on any screen sizes above md
8 | - Single: `mq="lg"` - Only renders on lg screen sizes
9 | - Array: `:mq="['xs','sm','xl']"` - Renders on xs, sm and xl screen sizes
10 |
--------------------------------------------------------------------------------
/docs/changelog/v2.3.0.md:
--------------------------------------------------------------------------------
1 | # v2.3.0 Breakpoint slots for the `MqLayout` component
2 |
3 | In addition to the mq="sm" property on the component, you can now also use breakpoint slots which can combine with Transition Groups for more powerful and complex renderings.
4 |
5 | ```vue
6 |
7 | For small screens only
8 | For medium to extra-large screens only
9 | Another slot for small screens only
10 | For large and smaller screens
11 |
12 | ```
--------------------------------------------------------------------------------
/docs/changelog/v2.3.3.md:
--------------------------------------------------------------------------------
1 | # v2.3.3 Bug Fixes
2 |
3 | - Fixed issue with the mq prop when using a minus modifier
4 | - Added tests for store.js for shouldRender
5 |
--------------------------------------------------------------------------------
/docs/changelog/v3.0.0.md:
--------------------------------------------------------------------------------
1 | # v3.0.0: The Reimagining
2 |
3 | Vue 3 MQ was initially a fork of [Alexandre Bonaventure's](https://alexandrebonaventure.github.io/vue-mq) Vue MQ project with a few coding changes to help it to work with Vue 3 complete with a couple of extra features sprinkled on top.
4 |
5 | Version 3 is a complete reimagining of the plugin. The code has been re-written from the group up to ensure it takes full advantage of the power of Vue 3 and offers a simple, yet powerful way to respond to vast number of environments your application has to operate in.
6 |
7 | See our [v2-3 migration guide for full details](/migration/from-version-2.md), but key changes are:
8 |
9 | - Global objects and components have been dropped in favour of imports/injections. This helps your app's size and performance by reducing overhead where it's not needed.
10 | - Support for detecting orientation ( landscape / portrait ) and theme ( dark / light)
11 | - The helper is now and the mq prop has become target.
12 | - mq is no longer a responsive value, but a full-blown reactive object. Quickly react to breakpoints, orientation and theme with a wide range of boolean values. Rendering on a mobile could be as simple as `if (mq.mdMinus) { ... }`
13 | - Choose from common presets (Bootstrap, Vuetify, Tailwind) to quickly get Vue3 MQ up and running with your UI of choice.
14 | - Full support for both Options API and Composition API builds of Vue3.
15 |
--------------------------------------------------------------------------------
/docs/changelog/v3.0.2.md:
--------------------------------------------------------------------------------
1 | # Version 3.0.2
2 |
3 | Cleaned up production dependencies and fixed some minor typos.
--------------------------------------------------------------------------------
/docs/changelog/v3.0.3.md:
--------------------------------------------------------------------------------
1 | # Version 3.0.3
2 |
3 | - Added Wordpress preset for breakpoints, which provides the following settings:
4 |
5 | ```js
6 | app.use(Vue3Mq, {
7 | preset: 'wordpress'
8 | })
9 | ```
10 |
11 | | Name | Minimum width |
12 | | ------- | ------------- |
13 | | mobile | 0 |
14 | | small | 600 |
15 | | medium | 782 |
16 | | large | 960 |
17 | | xlarge | 1080 |
18 | | wide | 1280 |
19 | | huge | 1440 |
--------------------------------------------------------------------------------
/docs/changelog/v3.1.0.md:
--------------------------------------------------------------------------------
1 | # Version 3.1.0
2 |
3 | ## Prefers Reduced Motion support added
4 |
5 | - Added props of `inert` and `motion` for rendering according to `(prefers-reduced-motion)` @media query. `inert` will render only when preference is `reduce` whereas `motion` will render only when `no-preference` is given or assumed.
6 | - `inert` and `motion` are also available as slot names when used inside a `` element.
7 | - For SSR support, `defaultMotion` can be passed in the Vue3Mq configuration object with a value of either `reduce` or `no-preference` with the latter being default.
8 | - `motionPreference`, `isMotion` and `isInert` properties added to MQ object.
9 |
10 | ```html
11 |
12 | This user prefers reduced motion
13 |
14 | ```
--------------------------------------------------------------------------------
/docs/changelog/v3.2.0.md:
--------------------------------------------------------------------------------
1 | # Version 3.2.0
2 |
3 | ## New `global` option for global installation
4 |
5 | You can now use the `global` config option for the plugin to install the `` component and the `$mq` object globally in your application.
6 |
7 | ```js
8 | import { createApp } from "vue";
9 | import { Vue3Mq } from "vue3-mq";
10 |
11 | const app = createApp();
12 | app.use(Vue3Mq, {
13 | global: true,
14 | });
15 |
16 | app.mount("#app");
17 | ```
18 |
19 | Then in your templates:
20 |
21 | ```vue
22 |
23 | Large
24 |
Large
25 |
26 | ```
27 |
--------------------------------------------------------------------------------
/docs/changelog/v4.0.0.md:
--------------------------------------------------------------------------------
1 | # Version 4.0.0
2 |
3 | ## New `vuetify3` preset available
4 |
5 | The Vuetify 3 breakpoints are now available as a preset for Vue3 MQ. These feature tweaked large and x-large breakpoints as well as a new xx-large breakpoint. For more information, see [Vuetify 3: Breakpoints and Thresholds](https://vuetifyjs.com/en/features/display-and-platform/#breakpoints-and-thresholds)
6 |
7 | ```js
8 | import { createApp } from "vue";
9 | import { Vue3Mq } from "vue3-mq";
10 |
11 | const app = createApp();
12 | app.use(Vue3Mq, {
13 | preset: "vuetify3",
14 | });
15 |
16 | app.mount("#app");
17 | ```
18 |
19 | ## BugFix: Fix MqResponsive is not referenced error
20 |
21 | Thanks to https://github.com/rfostii for the fix
22 |
23 | ## A Modern Stack
24 |
25 | - The project has been upgrade to ESM-first which meant up bumping to v4 as a precaution
26 | - We're also trying out building some types for the library courtesy of JSDoc
27 | - Jest has been dropped in favour of Vitest
28 | - Eslint 9's flat config is now used
29 |
--------------------------------------------------------------------------------
/docs/component/index.md:
--------------------------------------------------------------------------------
1 | # MQ-Responsive Component
2 |
3 | For convenience, an `` component is available for use in your app. You can import it like so:
4 |
5 | ::: code-group
6 |
7 | ```vue [Composition API]
8 |
11 | ```
12 |
13 | ```vue [Options API]
14 |
23 | ```
24 |
25 | :::
26 |
--------------------------------------------------------------------------------
/docs/component/props.md:
--------------------------------------------------------------------------------
1 | # MQ Responsive Props
2 |
3 | ## Target
4 |
5 | Content inside the component's slot will render when the current breakpoint matches the target
6 |
7 | ::: tip
8 | This prop accepts either a String or an Array
9 | :::
10 |
11 | ##### Single breakpoint
12 | ```vue
13 |
14 |
15 |
52 |
53 |
54 | ```
55 |
56 | ## Landscape
57 |
58 | Will only render when the screen is in landscape mode (i.e. its width is greater than its height)
59 |
60 | ::: tip
61 | This prop accepts a Boolean
62 | :::
63 |
64 | ```vue
65 |
66 |
67 |
This screen is in landscape mode
68 |
69 |
70 | ```
71 |
72 | ## Portrait
73 |
74 | Will render only when the screen is in portrait mode (i.e. its height is greater than its width)
75 |
76 | ::: tip
77 | This prop accepts a Boolean
78 | :::
79 |
80 | ```vue
81 |
82 |
83 |
This screen is in portrait mode
84 |
85 |
86 | ```
87 |
88 | ## Dark
89 |
90 | Uses the OS/browser-provided `prefers-color-scheme` media query to render only when dark mode is preferred.
91 |
92 | ::: tip
93 | This prop accepts a Boolean
94 | :::
95 |
96 | ```vue
97 |
98 |
99 |
This screen is in dark mode
100 |
101 |
102 | ```
103 |
104 | ## Light
105 |
106 | Uses the OS/browser-provided `prefers-color-scheme` media query to render only when light mode is preferred.
107 |
108 | ::: tip
109 | This prop accepts a Boolean
110 | :::
111 |
112 | ```vue
113 |
114 |
115 |
This screen is in light mode
116 |
117 |
118 | ```
119 |
120 | ## Inert
121 |
122 | Uses the OS/browser-provided `prefers-reduced-motion` media query to render only when reduced motion is preferred.
123 |
124 | ::: tip
125 | This prop accepts a Boolean
126 | :::
127 |
128 | ```vue
129 |
130 |
131 |
This user prefers reduced motion
132 |
133 |
134 | ```
135 |
136 | ## Motion
137 |
138 | Uses the OS/browser-provided `prefers-reduced-motion` media query to render only when no motion preference is stated.
139 |
140 | ::: tip
141 | This prop accepts a Boolean
142 | :::
143 |
144 | ```vue
145 |
146 |
147 |
This user has no motion preference
148 |
149 |
150 | ```
151 |
152 | ## Tag
153 |
154 | Sets the HTML tag to be used to wrap the contained content
155 |
156 | ::: tip
157 | This prop accepts a String
158 |
159 | Default: `div`
160 | :::
161 |
162 | ```vue
163 |
164 |
165 |
My parent element will be a 'section' element
166 |
167 |
168 | ```
169 |
170 | ## Group
171 |
172 | Creates a transition group which allows advanced use of list [rendering slots](./slots.md).
173 |
174 | Since this uses Vue's `TransitionGroup`, it will pass through any props to that component. See the [Vue3 API Reference](https://v3.vuejs.org/api/built-in-components.html#component) for more details.
175 |
176 | ::: tip
177 | This prop accepts a Boolean
178 | :::
179 |
180 | ```vue
181 |
182 |
183 | This screen is small
184 |
185 |
186 | ```
187 |
188 | ## List Tag
189 |
190 | ::: tip
191 | This prop accepts a String
192 | :::
193 |
194 | ```vue
195 |
196 |
197 | This list element will render on x-small screens with an 'li' tag
198 | This list element will render on small screens with an 'li' tag
199 | This list element will render on medium screens with an 'li' tag
200 | This list element will render on large screens with an 'li' tag
201 | This list element will render on x-large screens with an 'li' tag
202 |
203 |
204 | ```
--------------------------------------------------------------------------------
/docs/component/slots.md:
--------------------------------------------------------------------------------
1 | # MqResponsive Group slots
2 |
3 | ::: tip
4 | Group slots become available when `` has the `group` prop applied.
5 | :::
6 |
7 | When using an MqResponsive group, you can create complex lists which can factor in breakpoints, orientation or theme to decide whether to render the slot's content.
8 |
9 | Slot names are created dynamically based upon your provided breakpoints.
10 |
11 | ```vue
12 |
13 |
14 | This list element will render on x-small screens with an 'li' tag
15 | This list element will render on small screens with an 'li' tag
16 | This list element will render on medium screens with an 'li' tag
17 | This list element will render on large screens with an 'li' tag
18 | This list element will render on x-large screens with an 'li' tag
19 | This list element will render when dark mode is preferred
20 | This list element will render when light mode is preferred
21 | This list element will render when reduced motion is preferred
22 | This list element will render when no motion preference is given
23 | This list element will render when in portrait mode
24 | This list element will render when in light mode
25 |
26 |
27 | ```
28 |
29 | ## Chaining props
30 |
31 | You can chain props onto your slot names by using the `:` separator.
32 |
33 | ```vue
34 |
35 |
36 | Shown on x-small, portrait screens in dark mode
37 | Shown on small screens in light mode
38 | Shown on small to large screens in portrait orientation
39 |
40 |
41 | ```
42 |
43 | ## Multiple slots on same breakpoint
44 |
45 | Since Vue doesn't allow multiple slots with the same name, we can workaround this by adding a number as a suffix
46 |
47 | ```vue
48 |
49 |
50 | Shown on x-small screens
51 | Shown on small screens in light mode
52 | Shown on x-small screens as well
53 |
54 |
55 | ```
56 |
57 |
--------------------------------------------------------------------------------
/docs/configure/dynamic.md:
--------------------------------------------------------------------------------
1 | # Dynamic Breakpoints
2 |
3 | Need to change your breakpoint presets on the go? Then good news everyone, Vue3 Mq supports dynamically updating your application's breakpoints.
4 |
5 | Simply import or inject the provided function and pass your new configuration object.
6 |
7 | ::: code-group
8 |
9 | ```vue [Composition API]
10 |
24 | ```
25 |
26 | ```vue [Options API]
27 |
41 | ```
42 |
43 | :::
44 |
45 | Or you can switch to any of the [breakpoint presets](/configure/presets.md) available.
46 |
--------------------------------------------------------------------------------
/docs/configure/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Configuring the Plugin
3 | ---
4 | # Configuring Vue3-Mq
5 |
6 | When installing Vue3-Mq, you can pass a config object with any of the options below:
7 |
8 | ```js
9 | app.use(Vue3Mq, {
10 | // config options here
11 | })
12 | ```
13 |
14 | | Name | Type | Default | Description |
15 | | ------------------ | ------- | ------------ | ----------------------------------------------------------------------------------------------- |
16 | | preset | String | "bootstrap5" | Use breakpoints preset. Options are: bootstrap3, bootstrap4, vuetify, tailwind or devices. |
17 | | breakpoints | Object | null | Custom breakpoints config. Object keys and values = breakpoint name and min-width respectively. |
18 | | defaultBreakpoint | String | null | Screen breakpoint to use before browser window is available (i.e. in SSR) |
19 | | defaultOrientation | String | null | Screen orientation to use before browser window is available. [`landscape` or `portrait`] |
20 | | defaultTheme | String | null | OS / browser theme to use before browser window is available. [`light` or `dark`] |
21 | | defaultMotion | String | null | Motion preference to assume before browser window is available. [`reduce` or `no-preference`] |
--------------------------------------------------------------------------------
/docs/configure/presets.md:
--------------------------------------------------------------------------------
1 | # Available presets
2 |
3 | Under the `preset` option, you can pass any of the following:
4 |
5 | ## Bootstrap 5 (default)
6 |
7 | ```js
8 | app.use(Vue3Mq, {
9 | preset: "bootstrap5",
10 | });
11 | ```
12 |
13 | | Name | Minimum width |
14 | | ---- | ------------- |
15 | | xs | 0 |
16 | | sm | 576 |
17 | | md | 768 |
18 | | lg | 992 |
19 | | xl | 1200 |
20 | | xxl | 1400 |
21 |
22 | ## Tailwind
23 |
24 | ```js
25 | app.use(Vue3Mq, {
26 | preset: "tailwind",
27 | });
28 | ```
29 |
30 | | Name | Minimum width |
31 | | ---- | ------------- |
32 | | xs | 0 |
33 | | sm | 640 |
34 | | md | 768 |
35 | | lg | 1024 |
36 | | xl | 1280 |
37 | | xxl | 1536 |
38 |
39 | ## Vuetify 3
40 |
41 | ```js
42 | app.use(Vue3Mq, {
43 | preset: "vuetify3",
44 | });
45 | ```
46 |
47 | | Name | Minimum width |
48 | | ---- | ------------- |
49 | | xs | 0 |
50 | | sm | 600 |
51 | | md | 960 |
52 | | lg | 1280 |
53 | | xl | 1920 |
54 | | xxl | 2560 |
55 |
56 | ## Vuetify
57 |
58 | ```js
59 | app.use(Vue3Mq, {
60 | preset: "vuetify",
61 | });
62 | ```
63 |
64 | | Name | Minimum width |
65 | | ---- | ------------- |
66 | | xs | 0 |
67 | | sm | 600 |
68 | | md | 960 |
69 | | lg | 1264 |
70 | | xl | 1904 |
71 |
72 | ## Devices
73 |
74 | ```js
75 | app.use(Vue3Mq, {
76 | preset: "devices",
77 | });
78 | ```
79 |
80 | | Name | Minimum width |
81 | | ------- | ------------- |
82 | | phone | 0 |
83 | | tablet | 768 |
84 | | laptop | 1370 |
85 | | desktop | 1906 |
86 |
87 | ## Wordpress
88 |
89 | ```js
90 | app.use(Vue3Mq, {
91 | preset: "wordpress",
92 | });
93 | ```
94 |
95 | | Name | Minimum width |
96 | | ------ | ------------- |
97 | | mobile | 0 |
98 | | small | 600 |
99 | | medium | 782 |
100 | | large | 960 |
101 | | xlarge | 1080 |
102 | | wide | 1280 |
103 | | huge | 1440 |
104 |
105 | ## Bootstrap 4
106 |
107 | ```js
108 | app.use(Vue3Mq, {
109 | preset: "bootstrap4",
110 | });
111 | ```
112 |
113 | | Name | Minimum width |
114 | | ---- | ------------- |
115 | | xs | 0 |
116 | | sm | 576 |
117 | | md | 768 |
118 | | lg | 992 |
119 | | xl | 1200 |
120 |
121 | ## Bootstrap 3
122 |
123 | ```js
124 | app.use(Vue3Mq, {
125 | preset: "bootstrap3",
126 | });
127 | ```
128 |
129 | | Name | Minimum width |
130 | | ---- | ------------- |
131 | | xs | 0 |
132 | | sm | 768 |
133 | | md | 992 |
134 | | lg | 1200 |
135 |
--------------------------------------------------------------------------------
/docs/faq.md:
--------------------------------------------------------------------------------
1 | # Frequently Asked Questions
2 |
3 | ## Does this package support Vue 2?
4 |
5 | No, and it never will. Vue3-Mq was based on the excellent [Vue-Mq](https://github.com/AlexandreBonaventure/vue-mq) project by [Alexandre Bonaventure](https://alexandrebonaventure.github.io/vue-mq), who's got your Vue 2 needs covered.
6 |
7 | ## Any plans for Typescript support?
8 |
9 | I don't currently work with Typescript (it's on the to-do list, or maybe the to-do list is in Typescript). But if anyone feels compelled to add them, I'll happily accept a pull request on the project's [Github](https://github.com/craigrileyuk/vue3-mq) page.
10 |
11 | ## What can I use for my breakpoint keys?
12 |
13 | Breakpoint keys must start with a letter and contain only alphanumeric characters and underscores `[a-zA-Z0-9_]`. No hyphens are allowed since these are used to denote breakpoint ranges.
14 |
15 | ## I'm getting a hydration warning on SSR...
16 |
17 | It's a known issue when the provided `defaultBreakpoint` differs from the actual breakpoint on the client's device. At the moment, the only workaround is to wait until the app is mounted before initiating the changeover. However, this would result in a flash of alternate content and it only really does what Vue's internal engine handles automatically.
18 |
19 | Awaiting a better solution, if one can be found.
20 |
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | # https://vitepress.dev/reference/default-theme-home-page
3 | layout: home
4 |
5 | hero:
6 | name: "Vue3 MQ"
7 | text: "Plugin for Vue3"
8 | tagline: Bring fully reactive, responsive design to your Vue 3 project with Vue3-MQ, a plugin which allows your components and pages to adapt and react to changes in the browser environment.
9 | actions:
10 | - theme: brand
11 | text: Getting Started
12 | link: /installation
13 | - theme: alt
14 | text: Sponsor
15 | link: https://github.com/sponsors/craigrileyuk/
16 |
17 | features:
18 | - title: Reactive Object
19 | details: Respond to changes in browser environment in real-time: be it screen dimensions; dark or light theming; motion preferences; or screen orientation
20 | - title: Component
21 | details: Easy-to-use Vue component included with built in support for transitions and dynamic slots to allow you to switch content out in an instant
22 | - title: Composition & Options API Support
23 | details: Use composables in your setup functions, or simply inject the objects/functions you need if you prefer the Options API
24 | ---
25 |
--------------------------------------------------------------------------------
/docs/installation.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Installation
3 | ---
4 |
5 | # Install Vue3-MQ using a package manager
6 |
7 | To add Vue3-Mq to your Vue 3 app, first install it using your chosen package manager.
8 |
9 | ::: code-group
10 |
11 | ```bash [NPM]
12 | npm install vue3-mq
13 | ```
14 |
15 | ```bash [YARN]
16 | yarn add vue3-mq
17 | ```
18 |
19 | ```bash [PNPM]
20 | pnpm add vue3-mq
21 | ```
22 |
23 | :::
24 |
25 | ## Standard Installation
26 |
27 | Now add the plugin to your app entry file
28 |
29 | ```js
30 | import { createApp } from "vue";
31 | import { Vue3Mq } from "vue3-mq";
32 | const app = createApp({});
33 | app.use(Vue3Mq);
34 | app.mount("#app");
35 | ```
36 |
37 | ## Global Installation
38 |
39 | You can now use the `global` config option for the plugin to install the `` component and the `$mq` object globally in your application.
40 |
41 | ```js
42 | import { createApp } from "vue";
43 | import { Vue3Mq } from "vue3-mq";
44 |
45 | const app = createApp();
46 | app.use(Vue3Mq, {
47 | global: true,
48 | });
49 |
50 | app.mount("#app");
51 | ```
52 |
53 | Then in your templates:
54 |
55 | ```vue
56 |
57 | Large
58 |
Large
59 |
60 | ```
61 |
--------------------------------------------------------------------------------
/docs/migration/from-version-2.md:
--------------------------------------------------------------------------------
1 | # Migrating from Vue3 Mq version 2 to 3
2 |
3 | Vue3 MQ version 3 has been rewritten from the ground up to provide a plugin that is custom designed for both Options API and Composition API builds of Vue 3 and in line with best practices.
4 |
5 | As such, there've been a fair few changes around here.
6 |
7 | ## Installation Method
8 |
9 | There is no longer a default export from the vue3-mq package. All exports are now named. Therefore, the installation process requires using destructured imports:
10 |
11 | ```js
12 | import { createApp } from "vue";
13 | import { Vue3Mq } from "vue3-mq";
14 |
15 | const app = createApp();
16 | app.use(Vue3Mq);
17 |
18 | app.mount("#app");
19 | ```
20 |
21 | ## Now Using Minimum Widths for Breakpoints
22 |
23 | Customising your breakpoints in version 2 required setting your breakpoints using a key and the maximum width (in px) that the screen could be in order to be counted as that breakpoint. This tended to be be pretty confusing given it required the use of something along the lines of a `{ xxl: Infinity }` breakpoint. This was also something of an anti-pattern when compared to setting up common CSS frameworks since it was not "mobile-first".
24 |
25 | Version 3 requires using the **minimum** width you want a breakpoint to become active on. For example, a custom setup might go like so:
26 |
27 | ```js
28 | app.use(Vue3Mq, {
29 | breakpoints: {
30 | xs: 0,
31 | sm: 600,
32 | md: 960,
33 | lg: 1264,
34 | xl: 1904,
35 | }
36 | }
37 | ```
38 |
39 | This means that from a screen width of 0-599, the `xs` breakpoint is active. From 600-959, the `sm` breakpoint is active and so on. The `xl` breakpoint will be active from 1904 pixels wide and above.
40 |
41 | You should **always** have a breakpoint of `0` when declaring custom breakpoints.
42 |
43 | ## Removal of Global Properties and Functions
44 |
45 | Because of the performance and build-size benefits of tree-shaking, the Vue 3 ecosystem is increasingly embracing the practice of using local imports rather than global functions and properties. As such, $mq has been removed as a global property and must now be injected into components that require it.
46 |
47 | ::: code-group
48 |
49 | ```vue [Composition API]
50 |
57 | ```
58 |
59 | ```vue [Options API]
60 |
70 | ```
71 |
72 | :::
73 |
74 | The same goes for the `updateBreakpoints` function. This should also be injected or imported into your component.
75 |
76 | ::: code-group
77 |
78 | ```vue [Composition API]
79 |
86 | ```
87 |
88 | ```vue [Options API]
89 |
99 | ```
100 |
101 | :::
102 |
103 | ## Component `` Becomes `` and Goes Local
104 |
105 | The Vue3 Mq helper component has changed name from `` to `` to better reflect its function.
106 |
107 | Additionally, the prop `mq` – which designated the breakpoints on which the contents should render – is now called `target` to better fit alongside the new orientation / theme functionality.
108 |
109 | ```vue
110 |
111 | This will render on "md" and above screens
112 |
113 | ```
114 |
115 | This helper component won't automatically be available globally in version 3. You must either make it a global component yourself, or import it locally when you want to use it inside a Vue component/application.
116 |
117 | ::: code-group
118 |
119 | ```vue [Local Import]
120 |
129 | ```
130 |
131 | ```js [Global Installation]
132 | import { createApp } from "vue";
133 | import { Vue3Mq, MqResponsive } from "vue3-mq";
134 |
135 | const app = createApp();
136 | app.use(Vue3Mq);
137 | app.component("mq-responsive", MqResponsive);
138 |
139 | app.mount("#app");
140 | ```
141 |
142 | :::
143 |
144 | ## MQ Changes to a Reactive Object
145 |
146 | In version 2, calling `this.$mq` simply told you the current breakpoint. In version 3, injecting `mq` gives you access to a far more powerful reactive object that can instantly tell your app information about the browser environment. New boolean properties allow you to easily make calculations using the likes of `mq.lgPlus` or `mq.mdMinus`.
147 |
148 | This is the current reactive data for your browser window based on the Bootstrap 5 preset:
149 |
150 |
151 |
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module",
3 | "scripts": {
4 | "dev": "vitepress dev",
5 | "build": "vitepress build",
6 | "preview": "vitepress preview"
7 | },
8 | "devDependencies": {
9 | "fast-glob": "^3.3.2",
10 | "vitepress": "^1.3.4",
11 | "vue": "^3.5.6"
12 | }
13 | }
--------------------------------------------------------------------------------
/docs/pnpm-lock.yaml:
--------------------------------------------------------------------------------
1 | lockfileVersion: '6.0'
2 |
3 | settings:
4 | autoInstallPeers: true
5 | excludeLinksFromLockfile: false
6 |
7 | dependencies:
8 | vue:
9 | specifier: ^3.4.15
10 | version: 3.4.15
11 |
12 | packages:
13 |
14 | /@babel/helper-string-parser@7.23.4:
15 | resolution: {integrity: sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==}
16 | engines: {node: '>=6.9.0'}
17 | dev: false
18 |
19 | /@babel/helper-validator-identifier@7.22.20:
20 | resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==}
21 | engines: {node: '>=6.9.0'}
22 | dev: false
23 |
24 | /@babel/parser@7.23.9:
25 | resolution: {integrity: sha512-9tcKgqKbs3xGJ+NtKF2ndOBBLVwPjl1SHxPQkd36r3Dlirw3xWUeGaTbqr7uGZcTaxkVNwc+03SVP7aCdWrTlA==}
26 | engines: {node: '>=6.0.0'}
27 | hasBin: true
28 | dependencies:
29 | '@babel/types': 7.23.9
30 | dev: false
31 |
32 | /@babel/types@7.23.9:
33 | resolution: {integrity: sha512-dQjSq/7HaSjRM43FFGnv5keM2HsxpmyV1PfaSVm0nzzjwwTmjOe6J4bC8e3+pTEIgHaHj+1ZlLThRJ2auc/w1Q==}
34 | engines: {node: '>=6.9.0'}
35 | dependencies:
36 | '@babel/helper-string-parser': 7.23.4
37 | '@babel/helper-validator-identifier': 7.22.20
38 | to-fast-properties: 2.0.0
39 | dev: false
40 |
41 | /@jridgewell/sourcemap-codec@1.4.15:
42 | resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==}
43 | dev: false
44 |
45 | /@vue/compiler-core@3.4.15:
46 | resolution: {integrity: sha512-XcJQVOaxTKCnth1vCxEChteGuwG6wqnUHxAm1DO3gCz0+uXKaJNx8/digSz4dLALCy8n2lKq24jSUs8segoqIw==}
47 | dependencies:
48 | '@babel/parser': 7.23.9
49 | '@vue/shared': 3.4.15
50 | entities: 4.5.0
51 | estree-walker: 2.0.2
52 | source-map-js: 1.0.2
53 | dev: false
54 |
55 | /@vue/compiler-dom@3.4.15:
56 | resolution: {integrity: sha512-wox0aasVV74zoXyblarOM3AZQz/Z+OunYcIHe1OsGclCHt8RsRm04DObjefaI82u6XDzv+qGWZ24tIsRAIi5MQ==}
57 | dependencies:
58 | '@vue/compiler-core': 3.4.15
59 | '@vue/shared': 3.4.15
60 | dev: false
61 |
62 | /@vue/compiler-sfc@3.4.15:
63 | resolution: {integrity: sha512-LCn5M6QpkpFsh3GQvs2mJUOAlBQcCco8D60Bcqmf3O3w5a+KWS5GvYbrrJBkgvL1BDnTp+e8q0lXCLgHhKguBA==}
64 | dependencies:
65 | '@babel/parser': 7.23.9
66 | '@vue/compiler-core': 3.4.15
67 | '@vue/compiler-dom': 3.4.15
68 | '@vue/compiler-ssr': 3.4.15
69 | '@vue/shared': 3.4.15
70 | estree-walker: 2.0.2
71 | magic-string: 0.30.7
72 | postcss: 8.4.34
73 | source-map-js: 1.0.2
74 | dev: false
75 |
76 | /@vue/compiler-ssr@3.4.15:
77 | resolution: {integrity: sha512-1jdeQyiGznr8gjFDadVmOJqZiLNSsMa5ZgqavkPZ8O2wjHv0tVuAEsw5hTdUoUW4232vpBbL/wJhzVW/JwY1Uw==}
78 | dependencies:
79 | '@vue/compiler-dom': 3.4.15
80 | '@vue/shared': 3.4.15
81 | dev: false
82 |
83 | /@vue/reactivity@3.4.15:
84 | resolution: {integrity: sha512-55yJh2bsff20K5O84MxSvXKPHHt17I2EomHznvFiJCAZpJTNW8IuLj1xZWMLELRhBK3kkFV/1ErZGHJfah7i7w==}
85 | dependencies:
86 | '@vue/shared': 3.4.15
87 | dev: false
88 |
89 | /@vue/runtime-core@3.4.15:
90 | resolution: {integrity: sha512-6E3by5m6v1AkW0McCeAyhHTw+3y17YCOKG0U0HDKDscV4Hs0kgNT5G+GCHak16jKgcCDHpI9xe5NKb8sdLCLdw==}
91 | dependencies:
92 | '@vue/reactivity': 3.4.15
93 | '@vue/shared': 3.4.15
94 | dev: false
95 |
96 | /@vue/runtime-dom@3.4.15:
97 | resolution: {integrity: sha512-EVW8D6vfFVq3V/yDKNPBFkZKGMFSvZrUQmx196o/v2tHKdwWdiZjYUBS+0Ez3+ohRyF8Njwy/6FH5gYJ75liUw==}
98 | dependencies:
99 | '@vue/runtime-core': 3.4.15
100 | '@vue/shared': 3.4.15
101 | csstype: 3.1.3
102 | dev: false
103 |
104 | /@vue/server-renderer@3.4.15(vue@3.4.15):
105 | resolution: {integrity: sha512-3HYzaidu9cHjrT+qGUuDhFYvF/j643bHC6uUN9BgM11DVy+pM6ATsG6uPBLnkwOgs7BpJABReLmpL3ZPAsUaqw==}
106 | peerDependencies:
107 | vue: 3.4.15
108 | dependencies:
109 | '@vue/compiler-ssr': 3.4.15
110 | '@vue/shared': 3.4.15
111 | vue: 3.4.15
112 | dev: false
113 |
114 | /@vue/shared@3.4.15:
115 | resolution: {integrity: sha512-KzfPTxVaWfB+eGcGdbSf4CWdaXcGDqckoeXUh7SB3fZdEtzPCK2Vq9B/lRRL3yutax/LWITz+SwvgyOxz5V75g==}
116 | dev: false
117 |
118 | /csstype@3.1.3:
119 | resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
120 | dev: false
121 |
122 | /entities@4.5.0:
123 | resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
124 | engines: {node: '>=0.12'}
125 | dev: false
126 |
127 | /estree-walker@2.0.2:
128 | resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
129 | dev: false
130 |
131 | /magic-string@0.30.7:
132 | resolution: {integrity: sha512-8vBuFF/I/+OSLRmdf2wwFCJCz+nSn0m6DPvGH1fS/KiQoSaR+sETbov0eIk9KhEKy8CYqIkIAnbohxT/4H0kuA==}
133 | engines: {node: '>=12'}
134 | dependencies:
135 | '@jridgewell/sourcemap-codec': 1.4.15
136 | dev: false
137 |
138 | /nanoid@3.3.7:
139 | resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==}
140 | engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
141 | hasBin: true
142 | dev: false
143 |
144 | /picocolors@1.0.0:
145 | resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==}
146 | dev: false
147 |
148 | /postcss@8.4.34:
149 | resolution: {integrity: sha512-4eLTO36woPSocqZ1zIrFD2K1v6wH7pY1uBh0JIM2KKfrVtGvPFiAku6aNOP0W1Wr9qwnaCsF0Z+CrVnryB2A8Q==}
150 | engines: {node: ^10 || ^12 || >=14}
151 | dependencies:
152 | nanoid: 3.3.7
153 | picocolors: 1.0.0
154 | source-map-js: 1.0.2
155 | dev: false
156 |
157 | /source-map-js@1.0.2:
158 | resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
159 | engines: {node: '>=0.10.0'}
160 | dev: false
161 |
162 | /to-fast-properties@2.0.0:
163 | resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==}
164 | engines: {node: '>=4'}
165 | dev: false
166 |
167 | /vue@3.4.15:
168 | resolution: {integrity: sha512-jC0GH4KkWLWJOEQjOpkqU1bQsBwf4R1rsFtw5GQJbjHVKWDzO6P0nWWBTmjp1xSemAioDFj1jdaK1qa3DnMQoQ==}
169 | peerDependencies:
170 | typescript: '*'
171 | peerDependenciesMeta:
172 | typescript:
173 | optional: true
174 | dependencies:
175 | '@vue/compiler-dom': 3.4.15
176 | '@vue/compiler-sfc': 3.4.15
177 | '@vue/runtime-dom': 3.4.15
178 | '@vue/server-renderer': 3.4.15(vue@3.4.15)
179 | '@vue/shared': 3.4.15
180 | dev: false
181 |
--------------------------------------------------------------------------------
/docs/postcss.config.js:
--------------------------------------------------------------------------------
1 | export default {};
2 |
--------------------------------------------------------------------------------
/docs/public/images/desktop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/craigrileyuk/vue3-mq/da1a66bf1640e50cc850ba97b7818de6e1a983b0/docs/public/images/desktop.png
--------------------------------------------------------------------------------
/docs/public/images/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/craigrileyuk/vue3-mq/da1a66bf1640e50cc850ba97b7818de6e1a983b0/docs/public/images/favicon.png
--------------------------------------------------------------------------------
/docs/public/images/ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/craigrileyuk/vue3-mq/da1a66bf1640e50cc850ba97b7818de6e1a983b0/docs/public/images/ipad.png
--------------------------------------------------------------------------------
/docs/public/images/iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/craigrileyuk/vue3-mq/da1a66bf1640e50cc850ba97b7818de6e1a983b0/docs/public/images/iphone.png
--------------------------------------------------------------------------------
/docs/public/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/craigrileyuk/vue3-mq/da1a66bf1640e50cc850ba97b7818de6e1a983b0/docs/public/images/logo.png
--------------------------------------------------------------------------------
/docs/public/images/macbook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/craigrileyuk/vue3-mq/da1a66bf1640e50cc850ba97b7818de6e1a983b0/docs/public/images/macbook.png
--------------------------------------------------------------------------------
/docs/usage.md:
--------------------------------------------------------------------------------
1 |
5 |
6 | # The MQ Object
7 |
8 | Vue3-Mq provides your app with a fully reactive object detailing the environment that it's operating within. This includes the screen size, orientation and OS/browser theme preference (i.e. dark mode).
9 |
10 |
11 |