Skip to content
This repository was archived by the owner on May 8, 2021. It is now read-only.

[WIP] - nuxt example with @nuxtjs/tailwindcss module #99

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added examples/guides/.DS_Store
Binary file not shown.
13 changes: 13 additions & 0 deletions examples/guides/nuxt/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
90 changes: 90 additions & 0 deletions examples/guides/nuxt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
/logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# Nuxt generate
dist

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# IDE / Editor
.idea

# Service worker
sw.*

# macOS
.DS_Store

# Vim swap files
*.swp
73 changes: 73 additions & 0 deletions examples/guides/nuxt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
## Option 1: Using `create-nuxt-app` and the integrated `@nuxtjs/tailwindcss` module

You can use `create-nuxt-app` to create a new Nuxt project that includes Tailwind CSS out of the box.

### 1. Create a new project with `npx create-nuxt-app`

Let's create a `tailwindcss-nuxt` project with the following command:

```sh
npx create-nuxt-app tailwindcss-nuxt
```

### 2. Choose "Tailwind CSS" in the "Which UI Framework" prompt

You'll be asked a series of questions, which the answers will be based on you specific use case. When asked about what **UI Framework** you want to use, you'll want to choose **Tailwind CSS**.

After that, keep answering questions based on your needs. You'll eventually end up with a brand new Nuxt project.

If you look at your `package.json` file, you'll notice that the `@nuxtjs/tailwindcss` dependency, Nuxt's official module for Tailwind CSS support, was added to your project.

### 3. Start your new Nuxt project

Let's go in our new project directory with `cd tailwindcss-nuxt` (or however you named this project). From there, you can start it with:

```sh
npm run dev
```

You'll be greeted with the Nuxt demo homepage.

### 4. Tailwind CSS works out of the box!

To show that Tailwind CSS works out of the box, let's open the `pages/index.vue` file, locate the following `h1` tag:

```html
<h1 class="title">
nuxt
</h1>
```

and replace it with some Tailwind flavoured styles:

```html
<h1
class="mt-2 text-4xl font-black bg-gradient-to-r from-teal-400 to-teal-800 bg-clip-text text-transparent"
>
nuxt with Tailwind CSS
</h1>
```

That's it! You're up and running with Nuxt and Tailwind CSS based on a default Tailwind config file.

### 5. Customizing the Taliwind config and writing custom CSS

If you want to customise the Tailwind config, simply create a `tailwind.config.js` in your project root.

The `@nuxtjs/tailwindcss` module will also look for a CSS file in `./assets/css/tailwind.css`, which is where you can write your custom CSS and use things like `@apply`, `@responsive` or `@screen` directives.

If no file is found at that location, the default three `@tailwind` layer directives will be used:

```css
@tailwind base;
@tailwind components;
@tailwind utilities;
```

### 6. Learn more about the `@nuxtjs/tailwindcss` module

You can find more information on more advanced features of the `@nuxtjs/tailwindcss` module here: https://tailwindcss.nuxtjs.org/

---

## Option 2: Should we show a "vanilla" implementation without the `@nuxtjs/tailwindcss` module?
7 changes: 7 additions & 0 deletions examples/guides/nuxt/assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ASSETS

**This directory is not required, you can delete it if you don't want to use it.**

This directory contains your un-compiled assets such as LESS, SASS, or JavaScript.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#webpacked).
29 changes: 29 additions & 0 deletions examples/guides/nuxt/components/Logo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<svg class="NuxtLogo" width="245" height="180" viewBox="0 0 452 342" xmlns="http://www.w3.org/2000/svg">
<path
d="M139 330l-1-2c-2-4-2-8-1-13H29L189 31l67 121 22-16-67-121c-1-2-9-14-22-14-6 0-15 2-22 15L5 303c-1 3-8 16-2 27 4 6 10 12 24 12h136c-14 0-21-6-24-12z"
fill="#00C58E"
/>
<path
d="M447 304L317 70c-2-2-9-15-22-15-6 0-15 3-22 15l-17 28v54l39-67 129 230h-49a23 23 0 0 1-2 14l-1 1c-6 11-21 12-23 12h76c3 0 17-1 24-12 3-5 5-14-2-26z"
fill="#108775"
/>
<path
d="M376 330v-1l1-2c1-4 2-8 1-12l-4-12-102-178-15-27h-1l-15 27-102 178-4 12a24 24 0 0 0 2 15c4 6 10 12 24 12h190c3 0 18-1 25-12zM256 152l93 163H163l93-163z"
fill="#2F495E"
/>
</svg>
</template>

<style>
.NuxtLogo {
animation: 1s appear;
margin: auto;
}

@keyframes appear {
0% {
opacity: 0;
}
}
</style>
7 changes: 7 additions & 0 deletions examples/guides/nuxt/components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# COMPONENTS

**This directory is not required, you can delete it if you don't want to use it.**

The components directory contains your Vue.js Components.

_Nuxt.js doesn't supercharge these components._
12 changes: 12 additions & 0 deletions examples/guides/nuxt/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["./*"],
"@/*": ["./*"],
"~~/*": ["./*"],
"@@/*": ["./*"]
}
},
"exclude": ["node_modules", ".nuxt", "dist"]
}
7 changes: 7 additions & 0 deletions examples/guides/nuxt/layouts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# LAYOUTS

**This directory is not required, you can delete it if you don't want to use it.**

This directory contains your Application Layouts.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/views#layouts).
62 changes: 62 additions & 0 deletions examples/guides/nuxt/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<template>
<div>
<Nuxt />
</div>
</template>

<style>
html {
font-family:
'Source Sans Pro',
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
'Helvetica Neue',
Arial,
sans-serif;
font-size: 16px;
word-spacing: 1px;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
box-sizing: border-box;
}

*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
}

.button--green {
display: inline-block;
border-radius: 4px;
border: 1px solid #3b8070;
color: #3b8070;
text-decoration: none;
padding: 10px 30px;
}

.button--green:hover {
color: #fff;
background-color: #3b8070;
}

.button--grey {
display: inline-block;
border-radius: 4px;
border: 1px solid #35495e;
color: #35495e;
text-decoration: none;
padding: 10px 30px;
margin-left: 15px;
}

.button--grey:hover {
color: #fff;
background-color: #35495e;
}
</style>
8 changes: 8 additions & 0 deletions examples/guides/nuxt/middleware/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# MIDDLEWARE

**This directory is not required, you can delete it if you don't want to use it.**

This directory contains your application middleware.
Middleware let you define custom functions that can be run before rendering either a page or a group of pages.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing#middleware).
42 changes: 42 additions & 0 deletions examples/guides/nuxt/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export default {
// Target (https://go.nuxtjs.dev/config-target)
target: 'static',

// Global page headers (https://go.nuxtjs.dev/config-head)
head: {
title: 'nuxt',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},

// Global CSS (https://go.nuxtjs.dev/config-css)
css: [
],

// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
plugins: [
],

// Auto import components (https://go.nuxtjs.dev/config-components)
components: true,

// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
buildModules: [
// https://go.nuxtjs.dev/tailwindcss
'@nuxtjs/tailwindcss',
],

// Modules (https://go.nuxtjs.dev/config-modules)
modules: [
],

// Build Configuration (https://go.nuxtjs.dev/config-build)
build: {
}
}
Loading