Skip to content

Commit

Permalink
chore: add example for usage with tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Apr 24, 2024
1 parent 7e05768 commit 5011f93
Show file tree
Hide file tree
Showing 17 changed files with 783 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
buildScript: example:starter:build
storybookBuildScript: example:starter:storybook:publish
projectToken: chpt_dc04103f8a32bfa
- package: Tailwind
buildScript: example:tailwind:build
storybookBuildScript: example:tailwind:storybook:publish
projectToken: chpt_fbfe47dc27d4064
steps:
- uses: actions/checkout@v4
with:
Expand Down
26 changes: 26 additions & 0 deletions examples/tailwind/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example

*storybook.log
20 changes: 20 additions & 0 deletions examples/tailwind/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** @type { import('storybook-vue').StorybookConfig } */
const config = {
stories: [
'../components/**/*.mdx',
'../components/**/*.stories.@(js|jsx|ts|tsx|mdx)',
],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@chromatic-com/storybook',
],
framework: {
name: '@storybook-vue/nuxt',
options: {},
},
docs: {
autodocs: 'tag',
},
}
export default config
12 changes: 12 additions & 0 deletions examples/tailwind/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
}

export default preview
79 changes: 79 additions & 0 deletions examples/tailwind/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Nuxt 3 Minimal Starter

This example shows how to use the [Tailwind CSS module for Nuxt](https://tailwindcss.nuxtjs.org/) in combination with the Nuxt Storybook module.

---

Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.

## Setup

Make sure to install the dependencies:

```bash
# npm
npm install

# pnpm
pnpm install

# yarn
yarn install

# bun
bun install
```

## Development Server

Start the development server on `http://localhost:3000`:

```bash
# npm
npm run dev

# pnpm
pnpm run dev

# yarn
yarn dev

# bun
bun run dev
```

## Production

Build the application for production:

```bash
# npm
npm run build

# pnpm
pnpm run build

# yarn
yarn build

# bun
bun run build
```

Locally preview production build:

```bash
# npm
npm run preview

# pnpm
pnpm run preview

# yarn
yarn preview

# bun
bun run preview
```

Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
5 changes: 5 additions & 0 deletions examples/tailwind/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
<NuxtWelcome />
</div>
</template>
13 changes: 13 additions & 0 deletions examples/tailwind/components/CSSStyling.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import CSSStyling from './CSSStyling.vue'

const meta = {
title: 'Example/CSS Styling',
component: CSSStyling,
tags: ['autodocs'],
}

export default meta

export const CSSStylingStory = {
args: {},
}
18 changes: 18 additions & 0 deletions examples/tailwind/components/CSSStyling.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<div class="p-4">
<div class="px-6 py-4">
<span class="badge mr-2">#photography</span>
<span class="badge mr-2">#travel</span>
<span class="badge">#winter</span>
</div>
</div>
</template>

<style lang="postcss" scoped>
.badge {
@apply inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700;
&:hover {
@apply bg-gray-300;
}
}
</style>
13 changes: 13 additions & 0 deletions examples/tailwind/components/SimpleDiv.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import SimpleDiv from './SimpleDiv.vue'

const meta = {
title: 'Example/Simple Div',
component: SimpleDiv,
tags: ['autodocs'],
}

export default meta

export const SimpleDivStory = {
args: {},
}
10 changes: 10 additions & 0 deletions examples/tailwind/components/SimpleDiv.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<template>
<div class="px-6 py-4 pb-2">
<div class="font-bold text-xl mb-2">The Coldest Sunset</div>
<p class="text-gray-700 text-base">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatibus
quia, nulla! Maiores et perferendis eaque, exercitationem praesentium
nihil.
</p>
</div>
</template>
5 changes: 5 additions & 0 deletions examples/tailwind/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
modules: ['@nuxtjs/storybook', '@nuxtjs/tailwindcss'],
})
27 changes: 27 additions & 0 deletions examples/tailwind/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "tailwind",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"@nuxtjs/tailwindcss": "^6.12.0",
"nuxt": "^3.11.2",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.3.3",
"@nuxtjs/storybook": "workspace:*",
"@storybook/addon-essentials": "^8.0.8",
"@storybook/addon-links": "^8.0.8",
"@storybook/blocks": "^8.0.8",
"@storybook/test": "^8.0.8"
}
}
Binary file added examples/tailwind/public/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions examples/tailwind/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}
4 changes: 4 additions & 0 deletions examples/tailwind/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
"example:starter:build": "nuxi build examples/starter",
"example:starter:storybook:build": "cd examples/starter && pnpm run build-storybook",
"example:starter:storybook:publish": "chromatic --exit-zero-on-changes --build-script-name example:starter:storybook:build --project-token=chpt_dc04103f8a32bfa",
"example:tailwind:build": "nuxi build examples/tailwind",
"example:tailwind:storybook:build": "cd examples/tailwind && pnpm run build-storybook",
"example:tailwind:storybook:publish": "chromatic --exit-zero-on-changes --build-script-name example:tailwind:storybook:build --project-token=chpt_fbfe47dc27d4064",
"build": "nuxt-module-build build",
"lint": "pnpm lint:eslint && pnpm lint:prettier",
"lint:eslint": "eslint --report-unused-disable-directives .",
Expand Down
Loading

0 comments on commit 5011f93

Please sign in to comment.