Skip to content

Commit

Permalink
docs: update Nuxt docs and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rkunev committed Oct 14, 2021
1 parent 4cd76de commit 16b639d
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docs/guide/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

The good news: yes, via Vite's server-side rendering.

The bad news: Nuxt v2.x doesn't support Vue 3 and until it does the `ColorPicker` isn't compatible with Nuxt's server-side rendering/static site generation.
The bad news: As of this writing Nuxt v3 has been released, but it is still in Beta. Use at your own risk.

## What's the browser support?

Expand Down
12 changes: 9 additions & 3 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ Depending on your build tool of choice you may have to setup the appropriate loa
If you don't want to register the component everywhere it's used you can instead register it globally:

```js
// in your App.vue or main.js file
// in your main.js file
import { createApp } from 'vue';
import App from './App.vue';

import ColorPicker from '@radial-color-picker/vue-color-picker';
import '@radial-color-picker/vue-color-picker/dist/vue-color-picker.min.css';

Vue.use(ColorPicker);
const app = createApp(App);

app.use(ColorPicker);
app.mount('#app');
```

## Using CDN
Expand All @@ -63,7 +69,7 @@ You can also use the minified sources directly:

```html
<head>
<script src="https://unpkg.com/vue@3.1.5/dist/vue.global.prod.js"></script>
<script src="https://unpkg.com/vue@3.2.20/dist/vue.global.prod.js"></script>
<script src="https://unpkg.com/@radial-color-picker/vue-color-picker/dist/vue-color-picker.umd.min.js"></script>
<link href="https://unpkg.com/@radial-color-picker/vue-color-picker/dist/vue-color-picker.min.css" rel="stylesheet">
</head>
Expand Down
5 changes: 5 additions & 0 deletions examples/with-nuxt/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ package-lock.json
*.njsproj
*.sln
*.sw*

# Nuxt files
.nuxt
nuxt.d.ts
.output
6 changes: 2 additions & 4 deletions examples/with-nuxt/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Example - With Nuxt.js

**Note:** Current version of Nuxt (v2.x) doesn't support Vue 3. The example will be updated with the upcoming Nuxt major release.

---

Example shows how to setup `vue-color-picker` with [Nuxt.js](https://nuxtjs.org). Setup process is the same as an app built with Vue CLI, but the CSS is configured globally for all pages in `next.config.js`.
Example shows how to setup `vue-color-picker` with [Nuxt.js](https://v3.nuxtjs.org/). Setup process is the same as an app built with Vue CLI or Vite, but the CSS is configured globally for all pages in `next.config.ts`.

## How to use
Download the example [or clone the whole project](https://github.com/radial-color-picker/vue-color-picker.git):
Expand All @@ -30,4 +28,4 @@ npm run build
npm start
```

For detailed explanation on how things work, checkout [Nuxt.js docs](https://nuxtjs.org).
For detailed explanation on how things work, checkout [Nuxt.js docs](https://v3.nuxtjs.org/).
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<template>
<div id="app">
<div>
<color-picker v-bind="color" @input="onInput" />
<h1>{{ msg }}</h1>
<pre>{{ color }}</pre>
</div>
</template>

<script>
// Note: you don't have to import and declare the color-picker component
// This is done automatically in `nuxt.config.js`
import ColorPicker from '@radial-color-picker/vue-color-picker';
export default {
components: { ColorPicker },
data() {
return {
msg: 'Welcome to Your Vue.js App',
Expand Down
15 changes: 0 additions & 15 deletions examples/with-nuxt/nuxt.config.js

This file was deleted.

6 changes: 6 additions & 0 deletions examples/with-nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineNuxtConfig } from 'nuxt3';

export default defineNuxtConfig({
// Add the Color Picker component's CSS globally
css: ['@radial-color-picker/vue-color-picker/dist/vue-color-picker.min.css'],
});
11 changes: 6 additions & 5 deletions examples/with-nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
"author": "Rosen Kanev",
"private": true,
"scripts": {
"dev": "nuxt",
"dev": "nuxt dev",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
"start": "node .output/server/index.mjs"
},
"dependencies": {
"@radial-color-picker/vue-color-picker": "latest",
"nuxt": "^2.0.0"
"@radial-color-picker/vue-color-picker": "latest"
},
"devDependencies": {
"nuxt3": "latest"
}
}
Binary file removed examples/with-nuxt/static/favicon.ico
Binary file not shown.
13 changes: 13 additions & 0 deletions examples/with-nuxt/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Node",
"strict": false,
"allowJs": true,
"resolveJsonModule": true,
"types": [
"node"
]
}
}

0 comments on commit 16b639d

Please sign in to comment.