Skip to content

Commit

Permalink
support tailwind config
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Mar 19, 2020
1 parent f530657 commit b984b34
Show file tree
Hide file tree
Showing 11 changed files with 439 additions and 8 deletions.
374 changes: 374 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
"@testing-library/react": "^10.0.1",
"autoprefixer": "^9.7.4",
"bootstrap": "^4.4.1",
"codegen.macro": "^3.0.0",
"debounce-fn": "^4.0.0",
"faker": "^4.1.0",
"history": "^5.0.0-beta.5",
"match-sorter": "^4.0.2",
"postcss": "^7.0.27",
"postcss-cli": "^7.1.0",
"postcss-import": "^12.0.1",
"prop-types": "^15.7.2",
"querystringify": "^2.1.1",
"react": "16.13.0",
Expand Down
9 changes: 9 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const isProd = process.env.NODE_ENV === 'production'

module.exports = {
plugins: [
require('postcss-import'),
require('tailwindcss'),
isProd ? require('autoprefixer') : null,
].filter(Boolean),
}
4 changes: 2 additions & 2 deletions src/authenticated-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ function AuthenticatedApp() {
}

const navLinkClassName =
'block w-full h-full px-3 py-2 mx-0 my-2 text-gray-900 border-l-4 border-transparent rounded-sm hover:text-blue-700 hover:decoration-none hover:bg-gray-300'
const activeNavLinkClassName = 'bg-gray-300 border-l-4 border-blue-700'
'block w-full h-full px-3 py-2 mx-0 my-2 text-gray-900 border-l-4 border-transparent rounded-sm hover:text-primary hover:decoration-none hover:bg-gray-300'
const activeNavLinkClassName = 'bg-gray-300 border-l-4 border-primary'

function Nav(params) {
return (
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './hacks'
import './styles/tailwind'
import '@reach/dialog/styles.css'
import '@reach/menu-button/styles.css'
import '@reach/tabs/styles.css'
Expand Down
6 changes: 3 additions & 3 deletions src/components/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export const Button = withClassNames(
)

const buttonVariants = {
primary: 'bg-blue-700 text-white',
secondary: 'bg-gray-400 text-gray-800',
primary: 'bg-primary text-white',
secondary: 'bg-gray-100 text-gray-800',
}

export const FormGroup = withClassNames('div', 'flex flex-col')
Expand All @@ -75,5 +75,5 @@ export function FullPageSpinner() {

export const Link = withClassNames(
RouterLink,
'text-blue-600 hover:text-blue-800 hover:underline',
'text-primary hover:text-primary-800 hover:underline',
)
2 changes: 0 additions & 2 deletions src/styles/global.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '~tailwindcss/dist/tailwind.css';

#root {
color: #434449;
margin: 0 auto;
Expand Down
3 changes: 3 additions & 0 deletions src/styles/tailwind/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import codegen from 'codegen.macro'

codegen`module.exports = require('./tailwind-codegen')`
16 changes: 16 additions & 0 deletions src/styles/tailwind/tailwind-codegen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const {spawnSync} = require('child_process')

function generateTailwindCode() {
const result = spawnSync(
'./node_modules/.bin/postcss --output node_modules/.cache/app-postcss/styles.css src/styles/tailwind/tailwind.css',
{stdio: 'ignore', shell: true},
)
if (result.status !== 0) {
console.error(result.stdout)
console.error(result.stderr)
throw new Error(`postcss failure. Exit status: ${result.status}`)
}
return `require('.cache/app-postcss/styles.css')`
}

module.exports = generateTailwindCode
5 changes: 5 additions & 0 deletions src/styles/tailwind/tailwind.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import 'tailwindcss/base';

@import 'tailwindcss/components';

@import 'tailwindcss/utilities';
23 changes: 22 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
module.exports = {}
module.exports = {
theme: {
extend: {
colors: {
primary: '#3f51b5',
'primary-100': '#b7c1f8',
'primary-800': '#364495',
secondary: '#6f7077',
warning: '#ffc107',
success: '#4caf50',
danger: '#ef5350',
gray: {
'100': '#f1f2f7',
'200': '#f1f1f4',
'300': '#e4e5e9',
'400': '#6f7077',
'800': '#434449',
},
},
},
},
}

0 comments on commit b984b34

Please sign in to comment.