Skip to content

Commit b33a2f9

Browse files
committed
docs(README): update readme for vue 3 support
1 parent 1936cb2 commit b33a2f9

File tree

1 file changed

+41
-55
lines changed

1 file changed

+41
-55
lines changed

README.md

+41-55
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
`vue-imgix` is a client library for generating URLs with [imgix](https://www.imgix.com/).
66

7+
> ### Vue 2.x
8+
> ⚠️ You are viewing the Vue 3.0 `@next` development branch. This branch is for preview purposes. There will be bugs and undocumented behavior differences from v2. For Vue 2, please look at the [`main`](https://github.com/imgix/vue-imgix/tree/main) branch. We will be supporting Vue 2 for the official support timeline (18 months) after we release Vue 3 support.
9+
<!-- TODO(luis): update/remove badges for @next -->
710
[![npm version](https://img.shields.io/npm/v/vue-imgix.svg)](https://www.npmjs.com/package/vue-imgix)
811
[![Build Status](https://travis-ci.com/imgix/vue-imgix.svg?branch=main)](https://travis-ci.com/imgix/vue-imgix)
912
[![Downloads](https://img.shields.io/npm/dm/vue-imgix.svg)](https://www.npmjs.com/package/vue-imgix)
@@ -29,26 +32,29 @@
2932
- [Overview / Resources](#overview--resources)
3033
- [Get Started](#get-started)
3134
- [Configure](#configure)
32-
* [Polyfills required](#polyfills-required)
33-
* [Standard Vue 2.x App](#standard-vue-2x-app)
34-
* [Vue 3.x](#vue-3x)
35-
* [Nuxt.js](#nuxtjs)
35+
- [Polyfills required](#polyfills-required)
36+
- [Standard Vue 3.x App](#standard-vue-3x-app)
37+
- [Nuxt.js](#nuxtjs)
3638
- [Usage](#usage)
37-
* [Examples](#examples)
38-
+ [Basic Use Case](#basic-use-case)
39-
+ [Flexible Image Rendering](#flexible-image-rendering)
40-
+ [Fixed Image Rendering (i.e. non-flexible)](#fixed-image-rendering-ie-non-flexible)
41-
+ [Picture Support](#picture-support)
42-
+ [Lazy-Loading](#lazy-loading)
43-
* [Advanced Examples](#advanced-examples)
44-
+ [buildUrlObject](#buildurlobject)
45-
+ [buildUrl](#buildurl)
46-
+ [buildSrcSet](#buildsrcset)
47-
+ [Custom Attribute Mapping](#custom-attribute-mapping)
48-
+ [Custom Srcset Width](#custom-srcset-width)
49-
+ [Width Tolerance](#width-tolerance)
50-
+ [Minimum and Maximum Width Ranges](#minimum-and-maximum-width-ranges)
51-
+ [Base64 Encoding](#base64-encoding)
39+
- [Examples](#examples)
40+
- [Basic Use Case](#basic-use-case)
41+
- [Flexible Image Rendering](#flexible-image-rendering)
42+
- [Fixed Image Rendering (i.e. non-flexible)](#fixed-image-rendering-ie-non-flexible)
43+
- [Picture Support](#picture-support)
44+
- [Lazy-Loading](#lazy-loading)
45+
- [Lazy-loading (Native + Interaction Observer) **Recommended**](#lazy-loading-native--interaction-observer-recommended)
46+
- [Lazy-loading (Native)](#lazy-loading-native)
47+
- [Lazy-loading (Interaction Observer)](#lazy-loading-interaction-observer)
48+
- [Lazy-loading (Event Listener)](#lazy-loading-event-listener)
49+
- [Advanced Examples](#advanced-examples)
50+
- [buildUrlObject](#buildurlobject)
51+
- [buildUrl](#buildurl)
52+
- [buildSrcSet](#buildsrcset)
53+
- [Custom Attribute Mapping](#custom-attribute-mapping)
54+
- [Custom Srcset Width](#custom-srcset-width)
55+
- [Width Tolerance](#width-tolerance)
56+
- [Minimum and Maximum Width Ranges](#minimum-and-maximum-width-ranges)
57+
- [Base64 Encoding](#base64-encoding)
5258
- [What Is the `ixlib` Param on Every Request?](#what-is-the-ixlib-param-on-every-request)
5359
- [Code of Conduct](#code-of-conduct)
5460
- [Contributors](#contributors)
@@ -71,8 +77,8 @@ Firstly, follow this [quick start guide](https://docs.imgix.com/setup/quick-star
7177

7278
Then, install vue-imgix with the following commands, depending on your package manager.
7379

74-
- **NPM**: `npm install vue-imgix`
75-
- **Yarn**: `yarn add vue-imgix`
80+
- **NPM**: `npm install imgix/vue-imgix/@next`
81+
- **Yarn**: `yarn add imgix/vue-imgix/@next`
7682

7783
This module exports two transpiled versions. If a ES6-module-aware bundler is being used to consume this module, it will pick up an ES6 module version and can perform tree-shaking. **If you are not using ES6 modules, you don't have to do anything.**
7884

@@ -82,55 +88,34 @@ This module exports two transpiled versions. If a ES6-module-aware bundler is be
8288

8389
A polyfill for `Object.assign` must be supplied for browsers that need it. You probably have this already set up, so you likely don't need to do anything.
8490

85-
### Standard Vue 2.x App
91+
### Standard Vue 3.x App
8692

8793
Vue-imgix needs to be initialized with a minimal configuration before it can be used in components. Modify your startup/init file (usually `main.js` or similar) to include the following:
8894

8995
```js
90-
import Vue from 'vue';
96+
import { createApp } from 'vue';
9197
import VueImgix from 'vue-imgix';
98+
import App from './App.vue';
9299

93-
Vue.use(VueImgix, {
100+
// Create and mount the root instance.
101+
const app = createApp(App);
102+
// Make sure to _use_ the VueImgix instance to make the
103+
// whole app VueImgix-aware.
104+
app.use(VueImgix, {
94105
domain: "<your company's imgix domain>",
95106
defaultIxParams: {
96107
// This enables the auto format imgix parameter by default for all images, which we recommend to reduce image size, but you might choose to turn this off.
97108
auto: 'format',
98109
},
99110
});
111+
112+
app.mount('#app');
100113
```
101114

102115
And that's all you need to get started! Have fun!
103116

104-
### Vue 3.x
105-
106-
⚠️ Currently this library does not explicitly support Vue 3, although we are planning to roll out official support for it soon. We will also be supporting Vue 2 for the official support timeline (18 months) after we release Vue 3 support.
107-
108117
### Nuxt.js
109-
110-
To configure vue-imgix for a Nuxt app:
111-
112-
1. Add a `vue-imgix.js` file in `/plugins` with the following contents:
113-
114-
```js
115-
import Vue from 'vue';
116-
import VueImgix from 'vue-imgix';
117-
118-
Vue.use(VueImgix, {
119-
domain: "<your company's imgix domain>",
120-
defaultIxParams: {
121-
// This enables the auto format imgix parameter by default for all images, which we recommend to reduce image size, but you might choose to turn this off.
122-
auto: 'format',
123-
},
124-
});
125-
```
126-
127-
2. Add the plugin to your Nuxt config (in `nuxt.config.js`) like so:
128-
129-
```js
130-
plugins: ['~/plugins/vue-imgix.js'],
131-
```
132-
133-
And that's all you need to get started! Have fun!
118+
Nuxt.js *[beta](https://www.npmjs.com/package/nuxt3)* still isn't public. As such, we don't explicitly support Nuxt.js with Version 3.x as of right now.
134119

135120
## Usage
136121

@@ -293,6 +278,7 @@ For lazy loading, there are a few options to choose from. They're listed here, a
293278

294279
##### Lazy-loading (Native + Interaction Observer) **Recommended**
295280

281+
<!-- TODO(luis): change this to use Vue 3 directive API lifecycle methods -->
296282
This approach uses native lazy loading for browsers that support it, which is more and more every day, and uses [Lozad.js](https://apoorv.pro/lozad.js/) for those that don't. Lozad.js uses Interaction Observers to watch for changes to DOM elements, and is more performant than using event listeners.
297283

298284
<picture>
@@ -473,7 +459,7 @@ We also provide `buildSrcSet` from imgix-core-js to help developers to create an
473459

474460
```html
475461
<template>
476-
<img :src="advancedSrc" :srcset="advancedSrcSet" />
462+
<img :src="advancedUrl" :srcset="advancedSrcSet" />
477463
</template>
478464

479465
<script>
@@ -623,7 +609,7 @@ becomes:
623609
```
624610

625611
## What Is the `ixlib` Param on Every Request?
626-
612+
<!-- TODO(luis): update this to reflect Vue 3 Global API changes -->
627613
For security and diagnostic purposes, we tag all requests with the language and version of library used to generate the URL.
628614

629615
To disable this, set `includeLibraryParam` to false when initializing `VueImgix`.

0 commit comments

Comments
 (0)