diff --git a/.prettierrc b/.prettierrc index 4a95970..a7716ac 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,5 @@ { + "plugins": ["prettier-plugin-tailwindcss"], "trailingComma": "all", "singleQuote": true, "endOfLine": "lf", diff --git a/bun.lockb b/bun.lockb index 82a62a3..5187839 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index db26a49..86947a1 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@tanstack/react-form": "^0.33.0", "@tanstack/react-router": "^1.62.0", "appwrite": "^16.0.2", + "classnames": "^2.5.1", "react": "^18.3.1", "react-dom": "^18.3.1" }, @@ -21,11 +22,16 @@ "@types/react": "^18.3.10", "@types/react-dom": "^18.3.0", "@vitejs/plugin-react-swc": "^3.5.0", + "autoprefixer": "^10.4.20", "eslint": "^9.11.1", "eslint-plugin-react": "^7.37.1", "eslint-plugin-react-hooks": "^5.1.0-rc.0", "eslint-plugin-react-refresh": "^0.4.12", "globals": "^15.9.0", + "postcss": "^8.4.47", + "prettier": "^3.3.3", + "prettier-plugin-tailwindcss": "^0.6.8", + "tailwindcss": "^3.4.13", "typescript": "^5.5.3", "typescript-eslint": "^8.7.0", "vite": "^5.4.8" diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/src/components/Button.tsx b/src/components/Button.tsx new file mode 100644 index 0000000..fa2e82e --- /dev/null +++ b/src/components/Button.tsx @@ -0,0 +1,41 @@ +import classNames from 'classnames'; + +enum ButtonColor { + Primary = 'primary', + Secondary = 'secondary', + Error = 'error', + Success = 'success', +} + +interface ButtonProps extends React.ButtonHTMLAttributes { + color?: ButtonColor; +} + +const Button: React.FC = ({ + children, + color = ButtonColor.Primary, + ...props +}) => { + const buttonClass = classNames( + 'flex w-full justify-center rounded-md px-3 py-1.5 text-sm font-semibold leading-6 text-white shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2', + { + 'bg-indigo-600 hover:bg-indigo-500 focus-visible:outline-indigo-600': + color === ButtonColor.Primary, + 'bg-gray-600 hover:bg-gray-500 focus-visible:outline-gray-600': + color === ButtonColor.Secondary, + 'bg-red-600 hover:bg-red-500 focus-visible:outline-red-600': + color === ButtonColor.Error, + 'bg-green-600 hover:bg-green-500 focus-visible:outline-green-600': + color === ButtonColor.Success, + }, + ); + + return ( + + ); +}; + +export { ButtonColor }; +export default Button; diff --git a/src/components/Input.tsx b/src/components/Input.tsx new file mode 100644 index 0000000..3e58e38 --- /dev/null +++ b/src/components/Input.tsx @@ -0,0 +1,25 @@ +const Input = ({ + label, + ...props +}: React.DetailedHTMLProps< + React.InputHTMLAttributes, + HTMLInputElement +> & { + label?: string; +}) => { + return ( + <> + {label && ( + + )} +
+ +
+ + ); +}; + +export default Input; diff --git a/src/components/index.ts b/src/components/index.ts new file mode 100644 index 0000000..6289584 --- /dev/null +++ b/src/components/index.ts @@ -0,0 +1,4 @@ +import Input from './Input'; +import Button, { ButtonColor } from './Button'; + +export { Input, Button, ButtonColor }; diff --git a/src/index.css b/src/index.css index 6119ad9..e7d4bb2 100644 --- a/src/index.css +++ b/src/index.css @@ -1,3 +1,7 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + :root { font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; line-height: 1.5; diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 38bf87b..015efda 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -19,7 +19,7 @@ function Home() { React logo -

Scrummie-Poker

+

Scrummie-Poker

  • diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index 2ca76c5..aa0e116 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -1,5 +1,6 @@ import { useForm } from '@tanstack/react-form'; import { useUser } from '../lib/context/user'; +import { Button, ButtonColor, Input } from '../components'; const Login = () => { const user = useUser(); @@ -15,56 +16,95 @@ const Login = () => { return ( <> -

    Login or register

    -
    - ( - field.handleChange(e.target.value)} - /> - )} - /> - ( - field.handleChange(e.target.value)} - /> - )} - /> -
    - - +
    +
    +

    + Sign in to your account +

    - - + +
    +
    +
    + ( + field.handleChange(e.target.value)} + /> + )} + /> +
    + +
    + ( + field.handleChange(e.target.value)} + /> + )} + /> +
    + +
    +
    + + + +
    +
    +
    + +

    + Don't want to create an account?{' '} + user.loginAsGuest()} + > + Sign in as a guest + +

    +
    +
    ); }; diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..d21f1cd --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,8 @@ +/** @type {import('tailwindcss').Config} */ +export default { + content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'], + theme: { + extend: {}, + }, + plugins: [], +};