Skip to content

Commit

Permalink
Update Tailwind example to v2.0 (#19278)
Browse files Browse the repository at this point in the history
- Bump the Tailwind version to v2.0
- Add necessary latest `postcss` and `autoprefixer` deps
- Clean the tw config a bit
- Add dark mode styles
  • Loading branch information
Yuri Yakovlev authored Nov 20, 2020
1 parent 7782ba6 commit 0c38922
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 31 deletions.
10 changes: 6 additions & 4 deletions examples/with-tailwindcss/components/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ const links = [
export default function Nav() {
return (
<nav>
<ul className="flex justify-between items-center p-8">
<ul className="flex items-center justify-between p-8">
<li>
<Link href="/">
<a className="text-blue-500 no-underline">Home</a>
<a className="text-blue-500 no-underline text-accent-1 dark:text-blue-300">
Home
</a>
</Link>
</li>
<ul className="flex justify-between items-center space-x-4">
<ul className="flex items-center justify-between space-x-4">
{links.map(({ href, label }) => (
<li key={`${href}${label}`}>
<a href={href} className="btn-blue no-underline">
<a href={href} className="no-underline btn-blue">
{label}
</a>
</li>
Expand Down
6 changes: 3 additions & 3 deletions examples/with-tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"react-dom": "^16.13.1"
},
"devDependencies": {
"postcss-flexbugs-fixes": "4.2.1",
"postcss-preset-env": "^6.7.0",
"tailwindcss": "^1.7.4"
"autoprefixer": "10.0.2",
"postcss": "8.1.7",
"tailwindcss": "^2.0.1"
},
"license": "MIT"
}
4 changes: 2 additions & 2 deletions examples/with-tailwindcss/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default function IndexPage() {
<div>
<Nav />
<div className="py-20">
<h1 className="text-5xl text-center text-accent-1">
Next.js + Tailwind CSS
<h1 className="text-5xl text-center text-gray-700 dark:text-gray-100">
Next.js + Tailwind CSS 2.0
</h1>
</div>
</div>
Expand Down
17 changes: 1 addition & 16 deletions examples/with-tailwindcss/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
module.exports = {
plugins: [
'tailwindcss',
'postcss-flexbugs-fixes',
[
'postcss-preset-env',
{
autoprefixer: {
flexbox: 'no-2009',
},
stage: 3,
features: {
'custom-properties': false,
},
},
],
],
plugins: ['tailwindcss', 'autoprefixer'],
}
7 changes: 6 additions & 1 deletion examples/with-tailwindcss/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
@tailwind components;
/* Stop purging. */

html,
body {
@apply bg-gray-50 dark:bg-gray-900;
}

/* Write your own custom component styles here */
.btn-blue {
@apply bg-blue-500 text-white font-bold py-2 px-4 rounded;
@apply px-4 py-2 font-bold text-white bg-blue-500 rounded;
}

/* Start purging... */
Expand Down
9 changes: 4 additions & 5 deletions examples/with-tailwindcss/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
module.exports = {
future: {
removeDeprecatedGapUtilities: true,
purgeLayersByDefault: true,
},
purge: ['./components/**/*.{js,ts,jsx,tsx}', './pages/**/*.{js,ts,jsx,tsx}'],
darkMode: 'media', // 'media' or 'class'
theme: {
extend: {
colors: {
'accent-1': '#333',
},
},
},
variants: {},
variants: {
extend: {},
},
plugins: [],
}

0 comments on commit 0c38922

Please sign in to comment.