未验证 提交 0c389225 编写于 作者: Y Yuri Yakovlev 提交者: GitHub

Update Tailwind example to v2.0 (#19278)

- Bump the Tailwind version to v2.0
- Add necessary latest `postcss` and `autoprefixer` deps
- Clean the tw config a bit
- Add dark mode styles
上级 7782ba6f
...@@ -8,16 +8,18 @@ const links = [ ...@@ -8,16 +8,18 @@ const links = [
export default function Nav() { export default function Nav() {
return ( return (
<nav> <nav>
<ul className="flex justify-between items-center p-8"> <ul className="flex items-center justify-between p-8">
<li> <li>
<Link href="/"> <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> </Link>
</li> </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 }) => ( {links.map(({ href, label }) => (
<li key={`${href}${label}`}> <li key={`${href}${label}`}>
<a href={href} className="btn-blue no-underline"> <a href={href} className="no-underline btn-blue">
{label} {label}
</a> </a>
</li> </li>
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
"react-dom": "^16.13.1" "react-dom": "^16.13.1"
}, },
"devDependencies": { "devDependencies": {
"postcss-flexbugs-fixes": "4.2.1", "autoprefixer": "10.0.2",
"postcss-preset-env": "^6.7.0", "postcss": "8.1.7",
"tailwindcss": "^1.7.4" "tailwindcss": "^2.0.1"
}, },
"license": "MIT" "license": "MIT"
} }
...@@ -5,8 +5,8 @@ export default function IndexPage() { ...@@ -5,8 +5,8 @@ export default function IndexPage() {
<div> <div>
<Nav /> <Nav />
<div className="py-20"> <div className="py-20">
<h1 className="text-5xl text-center text-accent-1"> <h1 className="text-5xl text-center text-gray-700 dark:text-gray-100">
Next.js + Tailwind CSS Next.js + Tailwind CSS 2.0
</h1> </h1>
</div> </div>
</div> </div>
......
module.exports = { module.exports = {
plugins: [ plugins: ['tailwindcss', 'autoprefixer'],
'tailwindcss',
'postcss-flexbugs-fixes',
[
'postcss-preset-env',
{
autoprefixer: {
flexbox: 'no-2009',
},
stage: 3,
features: {
'custom-properties': false,
},
},
],
],
} }
...@@ -6,9 +6,14 @@ ...@@ -6,9 +6,14 @@
@tailwind components; @tailwind components;
/* Stop purging. */ /* Stop purging. */
html,
body {
@apply bg-gray-50 dark:bg-gray-900;
}
/* Write your own custom component styles here */ /* Write your own custom component styles here */
.btn-blue { .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... */ /* Start purging... */
......
module.exports = { module.exports = {
future: {
removeDeprecatedGapUtilities: true,
purgeLayersByDefault: true,
},
purge: ['./components/**/*.{js,ts,jsx,tsx}', './pages/**/*.{js,ts,jsx,tsx}'], purge: ['./components/**/*.{js,ts,jsx,tsx}', './pages/**/*.{js,ts,jsx,tsx}'],
darkMode: 'media', // 'media' or 'class'
theme: { theme: {
extend: { extend: {
colors: { colors: {
...@@ -11,6 +8,8 @@ module.exports = { ...@@ -11,6 +8,8 @@ module.exports = {
}, },
}, },
}, },
variants: {}, variants: {
extend: {},
},
plugins: [], plugins: [],
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册