From 04e6b01c2a562b2894e5f458937ed300926eb1f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Wed, 25 Jan 2023 12:47:39 +0100 Subject: [PATCH] Integrate TailwindCSS --- Makefile | 10 +---- common/input.css | 22 ---------- frontend/index.html | 10 +++-- frontend/package.json | 7 +++- frontend/postcss.config.cjs | 6 +++ frontend/src/App.css | 41 ------------------ frontend/src/App.jsx | 54 +++++++++++++----------- frontend/src/assets/react.svg | 1 - frontend/src/index.css | 78 +++++++---------------------------- frontend/tailwind.config.cjs | 12 ++++++ frontend/vite.config.js | 2 +- tailwind.config.js | 14 ------- 12 files changed, 79 insertions(+), 178 deletions(-) delete mode 100644 common/input.css create mode 100644 frontend/postcss.config.cjs delete mode 100644 frontend/src/assets/react.svg create mode 100644 frontend/tailwind.config.cjs delete mode 100644 tailwind.config.js diff --git a/Makefile b/Makefile index 8296fc1..3e3c57e 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,12 @@ -all: css migrate +all: migrate -initialize: npm css migrate sethookdir loadplatforms +initialize: npm migrate sethookdir loadplatforms HTMLFILES := $(shell find games/templates -type f) npm: npm install -css: input.css - npx tailwindcss -i ./input.css -o ./games/static/base.css - -css-dev: css - npx tailwindcss -i ./input.css -o ./games/static/base.css --watch - makemigrations: poetry run python manage.py makemigrations diff --git a/common/input.css b/common/input.css deleted file mode 100644 index a37820a..0000000 --- a/common/input.css +++ /dev/null @@ -1,22 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -form label { - @apply dark:text-slate-400; -} - -form input, -select, -textarea { - @apply dark:border dark:border-slate-900 dark:bg-slate-500 dark:text-slate-100; -} - -#session-table { - display: grid; - grid-template-columns: 3fr 1fr repeat(2, 2fr) 0.5fr 1fr; -} - -#button-container button { - @apply mx-1; -} diff --git a/frontend/index.html b/frontend/index.html index 79c4701..b52f64c 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -2,11 +2,15 @@ - + + - Vite + React + + + + Timetracker - +
diff --git a/frontend/package.json b/frontend/package.json index 2371d17..af93702 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -9,8 +9,11 @@ "preview": "vite preview" }, "dependencies": { + "autoprefixer": "^10.4.13", + "postcss": "^8.4.21", "react": "^18.2.0", - "react-dom": "^18.2.0" + "react-dom": "^18.2.0", + "tailwindcss": "^3.2.4" }, "devDependencies": { "@types/react": "^18.0.26", @@ -18,4 +21,4 @@ "@vitejs/plugin-react": "^3.0.0", "vite": "^4.0.0" } -} \ No newline at end of file +} diff --git a/frontend/postcss.config.cjs b/frontend/postcss.config.cjs new file mode 100644 index 0000000..33ad091 --- /dev/null +++ b/frontend/postcss.config.cjs @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/frontend/src/App.css b/frontend/src/App.css index 2c5e2ef..e69de29 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -1,41 +0,0 @@ -#root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -@media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index ef0adc0..0831da0 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1,33 +1,41 @@ import { useState } from 'react' -import reactLogo from './assets/react.svg' import './App.css' function App() { const [count, setCount] = useState(0) return ( -
-
- - Vite logo - - - React logo - -
-

Vite + React

-
- -

- Edit src/App.jsx and save to test HMR -

-
-

- Click on the Vite and React logos to learn more -

-
+ <> +
+ + {/* {% block content %}No content here.{% endblock content %} */} +
+ {/* {% load version %} */} + {/* {% version %} ({% version_date %}) */} + ) } diff --git a/frontend/src/assets/react.svg b/frontend/src/assets/react.svg deleted file mode 100644 index 6c87de9..0000000 --- a/frontend/src/assets/react.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/frontend/src/index.css b/frontend/src/index.css index 917888c..539a4ec 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -1,70 +1,22 @@ -:root { - font-family: Inter, Avenir, Helvetica, Arial, sans-serif; - font-size: 16px; - line-height: 24px; - font-weight: 400; +@tailwind base; +@tailwind components; +@tailwind utilities; - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - -webkit-text-size-adjust: 100%; +form label { + @apply dark:text-slate-400; } -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; +form input, +select, +textarea { + @apply dark:border dark:border-slate-900 dark:bg-slate-500 dark:text-slate-100; } -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; +#session-table { + display: grid; + grid-template-columns: 3fr 1fr repeat(2, 2fr) 0.5fr 1fr; } -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} +#button-container button { + @apply mx-1; +} \ No newline at end of file diff --git a/frontend/tailwind.config.cjs b/frontend/tailwind.config.cjs new file mode 100644 index 0000000..e8ecc87 --- /dev/null +++ b/frontend/tailwind.config.cjs @@ -0,0 +1,12 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + darkMode: "class", + content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"], + theme: { + fontFamily: { + sans: ["Inter", "sans-serif"], + }, + extend: {}, + }, + plugins: [require("@tailwindcss/typography"), require("@tailwindcss/forms")], +}; diff --git a/frontend/vite.config.js b/frontend/vite.config.js index d54c977..3c471a7 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -6,7 +6,7 @@ export default defineConfig({ plugins: [react()], server: { proxy: { - "/": "http://localhost:8001", + "/api": "http://127.0.0.1:8001", }, }, }); diff --git a/tailwind.config.js b/tailwind.config.js deleted file mode 100644 index 62d044f..0000000 --- a/tailwind.config.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - darkMode: 'class', - content: ["./**/*.{html,js}"], - theme: { - fontFamily: { - sans: ['Inter', 'sans-serif'], - }, - extend: {}, - }, - plugins: [ - require('@tailwindcss/typography'), - require('@tailwindcss/forms') - ], -} \ No newline at end of file