install prettier

This commit is contained in:
Chuck Dries 2021-07-24 14:45:38 -07:00
parent 78a76f6516
commit d0073ac492
10 changed files with 46 additions and 83 deletions

4
.prettierignore Normal file
View File

@ -0,0 +1,4 @@
node_modules
dist
dist-ssr
*.local

1
.prettierrc.json Normal file
View File

@ -0,0 +1 @@
{}

View File

@ -4,7 +4,8 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc && vite build", "build": "tsc && vite build",
"serve": "vite preview" "serve": "vite preview",
"format": "prettier --write ."
}, },
"dependencies": { "dependencies": {
"react": "^17.0.0", "react": "^17.0.0",
@ -16,6 +17,7 @@
"@vitejs/plugin-react-refresh": "^1.3.1", "@vitejs/plugin-react-refresh": "^1.3.1",
"autoprefixer": "^10.3.1", "autoprefixer": "^10.3.1",
"postcss": "^8.3.6", "postcss": "^8.3.6",
"prettier": "2.3.2",
"tailwindcss": "^2.2.7", "tailwindcss": "^2.2.7",
"typescript": "^4.3.2", "typescript": "^4.3.2",
"vite": "^2.4.3" "vite": "^2.4.3"

View File

@ -3,4 +3,4 @@ module.exports = {
tailwindcss: {}, tailwindcss: {},
autoprefixer: {}, autoprefixer: {},
}, },
} };

View File

@ -1,53 +0,0 @@
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
.App-logo.spin-reverse {
animation: App-logo-spin-reverse infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes App-logo-spin-reverse {
from {
transform: rotate(0deg);
}
to {
transform: rotate(-360deg);
}
}
button {
font-size: calc(10px + 2vmin);
}

View File

@ -17,7 +17,7 @@ const Greeter: React.FC<GreeterProps> = ({ name, setName }) => {
autoFocus autoFocus
type="text" type="text"
style={{ style={{
width: Math.max(100, 14 * name.length) + "px", width: Math.max(100, 10 * name.length) + "px",
}} }}
value={name} value={name}
onChange={(e) => setName(e.target.value)} onChange={(e) => setName(e.target.value)}
@ -30,20 +30,20 @@ function App() {
const [count, setCount] = useState(0); const [count, setCount] = useState(0);
const [name, setName] = useState(""); const [name, setName] = useState("");
return ( return (
<div className="App"> <div className="bg-regal-blue text-white bg-opacity-90 flex flex-col items-center justify-center h-screen">
<header className="App-header">
<img <img
src={logo} src={logo}
className="App-logo" className="w-1/2"
alt="logo" alt="logo"
style={{ style={{
animationDuration: `${20 / (name.length || 1)}s`, animationDuration: `${20 / (name.length || 1)}s`,
}} }}
/> />
<p>Hello Vite + React!</p> <div className="text-center">
<p className="text-3xl">Hello Vite + React!</p>
<p> <p>
<button <button
className="bg-blue-400 bg-opacity-60 hover:bg-blue-600 p-2 rounded m-2" className="text-xl shadow bg-blue-400 bg-opacity-60 hover:bg-blue-600 p-2 rounded m-2"
type="button" type="button"
onClick={() => setCount((count) => count + 1)} onClick={() => setCount((count) => count + 1)}
> >
@ -51,7 +51,7 @@ function App() {
</button> </button>
</p> </p>
<Greeter name={name} setName={setName} /> <Greeter name={name} setName={setName} />
</header> </div>
</div> </div>
); );
} }

View File

@ -1,11 +1,11 @@
import React from 'react' import React from "react";
import ReactDOM from 'react-dom' import ReactDOM from "react-dom";
import './index.css' import "./index.css";
import App from './App' import App from "./App";
ReactDOM.render( ReactDOM.render(
<React.StrictMode> <React.StrictMode>
<App /> <App />
</React.StrictMode>, </React.StrictMode>,
document.getElementById('root') document.getElementById("root")
) );

View File

@ -1,12 +1,16 @@
module.exports = { module.exports = {
mode: 'jit', mode: "jit",
purge: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'], purge: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
darkMode: false, // or 'media' or 'class' darkMode: false, // or 'media' or 'class'
theme: { theme: {
extend: {}, extend: {
colors: {
"regal-blue": "#243c5a",
},
},
}, },
variants: { variants: {
extend: {}, extend: {},
}, },
plugins: [], plugins: [],
} };

View File

@ -1,7 +1,7 @@
import { defineConfig } from 'vite' import { defineConfig } from "vite";
import reactRefresh from '@vitejs/plugin-react-refresh' import reactRefresh from "@vitejs/plugin-react-refresh";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [reactRefresh()] plugins: [reactRefresh()],
}) });

View File

@ -1011,6 +1011,11 @@ postcss@^8.1.6, postcss@^8.2.1, postcss@^8.3.5, postcss@^8.3.6:
nanoid "^3.1.23" nanoid "^3.1.23"
source-map-js "^0.6.2" source-map-js "^0.6.2"
prettier@2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d"
integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==
pretty-hrtime@^1.0.3: pretty-hrtime@^1.0.3:
version "1.0.3" version "1.0.3"
resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1"