Skip to content

Commit

Permalink
Use Tailwind 3.0 (#515)
Browse files Browse the repository at this point in the history
* upgrade to tailwind 3.0 alpha, make config changes

* rewrite svg: w/ new addVariant API tailwindlabs/tailwindcss#5809

* first first-of-type:before: order issue (tw fix in next alpha)

tailwindlabs/tailwindcss#6112
tailwindlabs/tailwindcss#6016
tailwindlabs/tailwindcss#6018

* replace tailwindcss-children plugin with new custom addVariant

* oh yeah... use stroke-green-500

* each variant doesn't need its own plugin

* update yarn.lock after merging main
  • Loading branch information
david-crespo committed Nov 17, 2021
1 parent 1cfbb66 commit 0b6db6a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 167 deletions.
2 changes: 1 addition & 1 deletion app/pages/ProjectsPage.tsx
Expand Up @@ -27,7 +27,7 @@ const Metric = ({ label, value, className }: MetricProps) => (
<div className="flex">
<div className="text-display-lg mr-4">{value}</div>
<div>
<SparklineSVG className="stroke-current text-green-500 w-full" />
<SparklineSVG className="stroke-green-500 w-full" />
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion libs/ui/lib/breadcrumbs/Breadcrumbs.tsx
Expand Up @@ -11,7 +11,7 @@ export const Breadcrumbs = ({ data }: BreadcrumbsProps) => (
<ol className="text-xs font-mono uppercase mb-6">
{data.map(({ href, label }) => (
<li
className="inline-block first-of-type:before:content-none
className="inline-block before:first-of-type:content-none
before:content-['/'] before:mx-2 before:text-gray-400"
key={`${href}-${label}`}
>
Expand Down
2 changes: 1 addition & 1 deletion libs/ui/lib/radio/Radio.tsx
Expand Up @@ -44,7 +44,7 @@ const cardLabelStyles = `
peer-disabled:hover:bg-gray-500
children:py-2 children:px-4 children:-mx-4 children:border-gray-400
children:first:-mt-2 children:last:-mb-2
first:children:-mt-2 last:children:-mb-2
peer-checked:children:border-green-500
cursor-pointer peer-disabled:cursor-default
`
Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -108,8 +108,7 @@
"postcss-nesting": "^8.0.1",
"prettier": "2.4.0",
"rollup": "^2.52.7",
"tailwindcss": "^2.2.0",
"tailwindcss-children": "^2.1.0",
"tailwindcss": "^3.0.0-alpha.2",
"ts-node": "^9.1.1",
"tsconfig-paths-webpack-plugin": "^3.5.1",
"typescript": "~4.4.2",
Expand Down
26 changes: 6 additions & 20 deletions tailwind.config.js
Expand Up @@ -3,15 +3,10 @@
/** @type {import('tailwindcss/lib/util/createPlugin').default} */
// @ts-ignore
const plugin = require('tailwindcss/plugin')
const defaultConfig = require('tailwindcss/defaultConfig')

const childrenPlugin = require('tailwindcss-children')

/** @type {import('tailwindcss/tailwind-config').TailwindConfig} */
module.exports = {
mode: 'jit',
purge: ['./libs/ui/**/*.{ts,tsx,mdx}', './app/**/*.{ts,tsx}'],
darkMode: false,
content: ['./libs/ui/**/*.{ts,tsx,mdx}', './app/**/*.{ts,tsx}'],
theme: {
extend: {
borderRadius: {
Expand Down Expand Up @@ -74,20 +69,11 @@ module.exports = {
},
},
plugins: [
// imitation of the twin.macro svg: variant. svg:text-green-500 puts green
// on an SVG that's an immediate child of the element
plugin(function ({ addVariant, e }) {
addVariant('svg', ({ modifySelectors, separator }) => {
modifySelectors(
({ className }) => `.${e(`svg${separator}${className}`)} > svg`
)
})
plugin(({ addVariant }) => {
// imitation of the twin.macro svg: variant. svg:text-green-500 puts green
// on an SVG that's an immediate child of the element
addVariant('svg', '& > svg')
addVariant('children', '& > *')
}),
childrenPlugin,
],
/**
* TODO: This isn't respected, need an upstream fix.
* @see https://github.com/tailwindlabs/tailwindcss/issues/3949
*/
variantOrder: ['children', ...defaultConfig.variantOrder, 'svg'],
}

1 comment on commit 0b6db6a

@vercel
Copy link

@vercel vercel bot commented on 0b6db6a Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.