Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Add Tailwind to React app
Browse files Browse the repository at this point in the history
As described at https://tailwindcss.com/docs/guides/create-react-app;
using existing Tailwind config from Rails app (with `purge` paths
modified).
  • Loading branch information
bobwhitelock committed May 20, 2021
1 parent 42c7504 commit 1ebf46f
Show file tree
Hide file tree
Showing 5 changed files with 350 additions and 31 deletions.
7 changes: 7 additions & 0 deletions client/craco.config.js
@@ -0,0 +1,7 @@
module.exports = {
style: {
postcss: {
plugins: [require("tailwindcss"), require("autoprefixer")],
},
},
};
13 changes: 10 additions & 3 deletions client/package.json
Expand Up @@ -4,6 +4,7 @@
"private": true,
"proxy": "http://127.0.0.1:3000",
"dependencies": {
"@craco/craco": "^6.1.1",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
Expand All @@ -18,9 +19,9 @@
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "PORT=3001 react-scripts start",
"build": "react-scripts build && cp -r build/* ../public/",
"test": "react-scripts test",
"start": "PORT=3001 craco start",
"build": "craco build && cp -r build/* ../public/",
"test": "craco test",
"eject": "react-scripts eject"
},
"eslintConfig": {
Expand All @@ -40,5 +41,11 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@tailwindcss/postcss7-compat": "^2.1.0",
"autoprefixer": "^9",
"postcss": "^7",
"tailwindcss": "npm:@tailwindcss/postcss7-compat"
}
}
40 changes: 28 additions & 12 deletions client/src/index.css
@@ -1,13 +1,29 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
@tailwind base;
@tailwind components;
@tailwind utilities;

.card {
@apply flex flex-col w-full px-2 pb-2 overflow-hidden border-4 shadow-lg;
}

@screen md {
.card {
@apply w-1/3 border-2;
}
}

@screen lg {
.card {
@apply w-1/4;
}
}

@screen xl {
.card {
@apply w-1/5;
}
}

.tag-pill {
@apply inline-block px-2 my-1 mr-2 font-semibold rounded-full;
}
26 changes: 26 additions & 0 deletions client/tailwind.config.js
@@ -0,0 +1,26 @@
const defaultTheme = require("tailwindcss/defaultTheme");

module.exports = {
theme: {
extend: {
fontFamily: {
sans: ["Inter", ...defaultTheme.fontFamily.sans],
},
},
},
variants: {
backgroundColor: ["responsive", "hover", "focus", "disabled"],
cursor: ["responsive", "disabled"],
opacity: ["responsive", "hover", "focus", "disabled"],
},
plugins: [],
purge: [
"./src/**/*.{js,jsx,ts,tsx,css}",
"./public/index.html",
"../**/*.rb",
],
future: {
removeDeprecatedGapUtilities: true,
purgeLayersByDefault: true,
},
};

0 comments on commit 1ebf46f

Please sign in to comment.