Skip to content

Commit

Permalink
feat: add tailwind preset for nuxt (#591)
Browse files Browse the repository at this point in the history
* feat: add tailwind preset for nuxt

* feat: add tailwind preset for next

* feat: add default css variables to preset

* chore: cleanup nuxt tailwind config

* fix: switch nuxt to use packaged example styles

* feat: update previews with tailwind preset

* chore: update tailwind preset package

* chore: update turbo.json for tailwind config

* chore: tailwind preview turbo + tests
  • Loading branch information
mattmaribojoc authored and FRSgit committed Mar 8, 2023
1 parent c9c5e01 commit c52858a
Show file tree
Hide file tree
Showing 31 changed files with 594 additions and 795 deletions.
4 changes: 2 additions & 2 deletions apps/preview/next/cypress/support/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

// Import commands.js using ES2015 syntax:
import './commands';
import '../../styles/global.scss';
import '../../styles/global.css';
import '@percy/cypress';
import "@cypress/code-coverage/support";
import '@cypress/code-coverage/support';

// Alternatively you can use CommonJS syntax:
// require('./commands')
Expand Down
2 changes: 1 addition & 1 deletion apps/preview/next/layouts/Examples.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from 'next/link';
import { useRouter } from 'next/router';
import { createElement, ReactElement, useState } from 'react';
import { ReactElement, useState, createElement } from 'react';
import useSWR from 'swr';
import { VsfButton, VsfButtonVariant, VsfButtonSize } from '@storefront-ui/react/components/VsfButton';
import { VsfListItemMenu } from '@storefront-ui/react/components/VsfListItemMenu';
Expand Down
2 changes: 1 addition & 1 deletion apps/preview/next/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppProps } from 'next/app';
import { ReactElement, ReactNode } from 'react';
import { NextPage } from 'next';
import '~/styles/global.scss';
import '~/styles/global.css';
import '@storefront-ui/example-style';

export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
Expand Down
5 changes: 5 additions & 0 deletions apps/preview/next/styles/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import url('https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@300;400;500;700&family=Red+Hat+Text:ital,wght@0,400;0,500;0,700;1,300&display=swap');

@tailwind base;
@tailwind components;
@tailwind utilities;
3 changes: 0 additions & 3 deletions apps/preview/next/styles/global.scss

This file was deleted.

19 changes: 12 additions & 7 deletions apps/preview/next/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
const vsfTypography = require('@storefront-ui/typography');
/** @type {import('tailwindcss').Config} */
const config = require('@storefront-ui/tailwind-config/index.json');
const { tailwindConfig } = require('@storefront-ui/tailwind-config');

module.exports = {
...config,
content: [
...config.content,
'../../../node_modules/@storefront-ui/react/**/*.{ts,tsx}',
],
plugins: [vsfTypography]
presets: [tailwindConfig],
content: ['./**/*.ts', './**/*.tsx', '../../../node_modules/@storefront-ui/react/**/*.tsx'],
theme: {
extend: {
fontFamily: {
sans: 'Red Hat Text, sans-serif',
},
},
},
plugins: [vsfTypography],
};
4 changes: 4 additions & 0 deletions apps/preview/nuxt/assets/css/tailwind.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import url('https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@300;400;500;700&family=Red+Hat+Text:ital,wght@0,400;0,500;0,700;1,300&display=swap');
@tailwind base;
@tailwind components;
@tailwind utilities;
2 changes: 0 additions & 2 deletions apps/preview/nuxt/assets/global.scss

This file was deleted.

2 changes: 1 addition & 1 deletion apps/preview/nuxt/components/utils/ComponentExample.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="e-page">
<div class="flex-1">
<div class="e-page-component" :class="componentContainerClassName">
<slot />
</div>
Expand Down
7 changes: 1 addition & 6 deletions apps/preview/nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { defineNuxtConfig } from 'nuxt/config';
import tailwindConfig from './tailwind.config';

export default defineNuxtConfig({
app: {
Expand All @@ -11,12 +10,8 @@ export default defineNuxtConfig({
title: 'Vue Storefront UI v2',
},
},
tailwindcss: {
config: tailwindConfig,
cssPath: '~/assets/global.scss',
},
modules: ['@nuxtjs/tailwindcss'],
css: ['@storefront-ui/example-style/index.scss'],
css: ['@storefront-ui/example-style/index.scss', '@storefront-ui/example-style/controls.scss'],
imports: {
transform: {
// you could also add the path of your built library to prevent this happening
Expand Down
12 changes: 3 additions & 9 deletions apps/preview/nuxt/pages/examples.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@
<VsfIconChevronRight v-else />
</template>
</VsfButton>
<ul class="sidebar-list">
<li>
<NuxtLink
v-for="component in components"
:key="component"
v-slot="{ navigate }"
:to="`/examples/${component}`"
custom
>
<ul class="sidebar-list flex flex-col">
<li v-for="component in components" :key="component">
<NuxtLink v-slot="{ navigate }" :to="`/examples/${component}`" custom>
<VsfListItemMenu
tag="span"
:active="currentRoute.path === `/examples/${component}`"
Expand Down
17 changes: 10 additions & 7 deletions apps/preview/nuxt/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import type { Config } from 'tailwindcss';
import vsfTypography from '@storefront-ui/typography';
import config from '@storefront-ui/tailwind-config/index.json';
import { tailwindConfig } from '@storefront-ui/tailwind-config';

export default <Config>{
...(config as unknown as Config),
content: [
...config.content,
'../../../node_modules/@storefront-ui/vue/shared/**/*.ts',
'../../../node_modules/@storefront-ui/vue/components/**/*.{ts,vue}',
],
presets: [tailwindConfig],
content: ['./**/*.vue', './**/*.ts', './**/*.tsx', '../../../node_modules/@storefront-ui/vue/**/*.vue'],
theme: {
extend: {
fontFamily: {
sans: 'Red Hat Text, sans-serif',
},
},
},
plugins: [vsfTypography],
};
2 changes: 1 addition & 1 deletion apps/preview/vue/cypress/support/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// Import commands.js using ES2015 syntax:
import "./commands";
import "../../src/assets/global.scss";
import "../../src/assets/main.css";
// Alternatively you can use CommonJS syntax:
// require('./commands')

Expand Down
4 changes: 4 additions & 0 deletions apps/preview/vue/src/assets/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import url("https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@300;400;500;700&family=Red+Hat+Text:ital,wght@0,400;0,500;0,700;1,300&display=swap");
@tailwind base;
@tailwind components;
@tailwind utilities;
2 changes: 0 additions & 2 deletions apps/preview/vue/src/assets/global.scss

This file was deleted.

19 changes: 10 additions & 9 deletions apps/preview/vue/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { createApp } from "vue";
import { createPinia } from "pinia";

import App from './App.vue'
import router from './router'
import App from "./App.vue";
import router from "./router";

import './assets/main.css'
import "./assets/main.css";
import "./assets/global.css";

const app = createApp(App)
const app = createApp(App);

app.use(createPinia())
app.use(router)
app.use(createPinia());
app.use(router);

app.mount('#app')
app.mount("#app");
5 changes: 2 additions & 3 deletions apps/preview/vue/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/** @type {import('tailwindcss').Config} */

const config = require("@storefront-ui/tailwind-config/index.json");
const { tailwindConfig } = require("@storefront-ui/tailwind-config");
module.exports = {
...config,
presets: [tailwindConfig],
content: [
...config.content,
"../../../node_modules/@storefront-ui/vue/shared/**/*.ts",
"../../../node_modules/@storefront-ui/vue/components/**/*.{ts,vue}",
],
Expand Down
Loading

0 comments on commit c52858a

Please sign in to comment.