Skip to content

Commit

Permalink
state
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Jul 29, 2024
1 parent 7ee8e0d commit 69c24ab
Show file tree
Hide file tree
Showing 112 changed files with 23,036 additions and 3,397 deletions.
14 changes: 14 additions & 0 deletions clients/react-vite/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended', 'plugin:storybook/recommended'],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
26 changes: 26 additions & 0 deletions clients/react-vite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

*storybook.log
20 changes: 20 additions & 0 deletions clients/react-vite/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { StorybookConfig } from "@storybook/react-vite";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-onboarding",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
],
core: {
builder: "@storybook/builder-vite", // 👈 The builder enabled here.
},
framework: {
name: "@storybook/react-vite",
options: {},
},
};
export default config;
14 changes: 14 additions & 0 deletions clients/react-vite/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Preview } from "@storybook/react";

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
30 changes: 30 additions & 0 deletions clients/react-vite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: __dirname,
},
}
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
17 changes: 17 additions & 0 deletions clients/react-vite/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/index.css",
"baseColor": "slate",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
17 changes: 17 additions & 0 deletions clients/react-vite/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Azeret+Mono:ital,wght@0,100..900;1,100..900&family=Bodoni+Moda:ital,opsz,wght@0,6..96,400..900;1,6..96,400..900&display=swap" rel="stylesheet">

<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
57 changes: 57 additions & 0 deletions clients/react-vite/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "survivor",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"@radix-ui/react-slider": "^1.2.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"framer-motion": "^11.3.19",
"lucide-react": "^0.416.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tailwind-merge": "^2.4.0",
"tailwindcss-animate": "^1.0.7",
"@lootsurvivor/core": "workspace:^"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.6.1",
"@storybook/addon-essentials": "^8.2.6",
"@storybook/addon-interactions": "^8.2.6",
"@storybook/addon-links": "^8.2.6",
"@storybook/addon-onboarding": "^8.2.6",
"@storybook/blocks": "^8.2.6",
"@storybook/builder-vite": "^8.2.6",
"@storybook/react": "^8.2.6",
"@storybook/react-vite": "^8.2.6",
"@storybook/test": "^8.2.6",
"@types/node": "^20.14.12",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"eslint-plugin-storybook": "^0.8.0",
"postcss": "^8.4.40",
"storybook": "^8.2.6",
"tailwindcss": "^3.4.7",
"typescript": "^5.2.2",
"vite": "^5.3.4",
"vite-plugin-svgr": "^4.2.0"
}
}
6 changes: 6 additions & 0 deletions clients/react-vite/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
Binary file added clients/react-vite/public/images/avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added clients/react-vite/public/images/giant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions clients/react-vite/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions clients/react-vite/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.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;
}
15 changes: 15 additions & 0 deletions clients/react-vite/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { useState } from "react";

import "./App.css";

import { useGameStateStore } from "@lootsurvivor/core";

function App() {
const [count, setCount] = useState(0);

const { gameState } = useGameStateStore.getState();

return <></>;
}

export default App;
1 change: 1 addition & 0 deletions clients/react-vite/src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions clients/react-vite/src/components/game/BeastCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Button } from "../ui/button";
import { RoundedContainer } from "./RoundedContainer";
import { motion } from "framer-motion";

export interface Beast {
name: string;
level: number;
health: number;
maxHealth: number;
image: string;
}

export const BeastCard = ({ beast }: { beast: Beast }) => {
return (
<RoundedContainer inner className="text-primary bg-beast-red/50 relative">
<div className="text-5xl p-10 text-center uppercase">{beast.name}</div>
<RoundedContainer inner>
<div className="flex justify-between gap-8 p-6 py-4">
<div className="self-center">Tier 1</div>
<div className="flex-grow mx-2 relative">
<div className="w-full rounded-2xl h-6 border border-primary overflow-hidden">
<motion.div
className="bg-beast-red/50 h-full rounded-2xl border-r border-primary"
initial={{ width: "0%" }}
animate={{
width: `${(beast.health / beast.maxHealth) * 100}%`,
}}
transition={{ duration: 1, ease: "easeOut" }}
></motion.div>
</div>
<div className="text-xs text-center mt-1 flex justify-center absolute top-0 px-3 w-full">
<div>
{beast.health}/{beast.maxHealth} HP
</div>
</div>
</div>

<div className="self-center">lvl. {beast.level}</div>
</div>
<RoundedContainer inner>
<img
src={beast.image}
alt=""
className="w-full object-cover border border-primary rounded-2xl"
/>
</RoundedContainer>
</RoundedContainer>
<RoundedContainer className="absolute bottom-36 left-0 right-0 p-4 bg-black/90 mx-8">
{/* Add your content here */}
<div>
Giant: argghhh, who do you think you are!!! I will crush your skull
and eat your flesh! Time to die human.
</div>
</RoundedContainer>
<RoundedContainer
inner
className="absolute bottom-0 left-0 right-0 p-4 bg-black/90 flex justify-between"
>
<div className="flex flex-col gap-4">
<Button variant="destructive">Attack</Button>
<Button variant="default">Attack Till Death</Button>
</div>
<div className="flex flex-col gap-4">
<Button variant="default">Flee</Button>
<Button variant="default">Flee Till Death</Button>
</div>
</RoundedContainer>
</RoundedContainer>
);
};
38 changes: 38 additions & 0 deletions clients/react-vite/src/components/game/Confirming.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { RoundedContainer } from "./RoundedContainer";

const items = [
{
title: "+2 Strength",
},
{
title: "Equip Sword",
},
];

export const Confirmation = () => {
return (
<RoundedContainer className="bg-primary/40">
<div className="text-4xl p-4 text-center ">Upgrading...</div>

<RoundedContainer className="p-4 grid grid-cols-3 gap-4" inner>
{items.map((item) => (
<ConfirmationCard>
<div>{item.title}</div>
</ConfirmationCard>
))}
</RoundedContainer>
</RoundedContainer>
);
};

export const ConfirmationCard = ({
children,
}: {
children: React.ReactNode;
}) => {
return (
<div className="border border-primary bg-primary/40 text-center rounded-2xl p-4 animate-pulse">
{children}
</div>
);
};
Loading

0 comments on commit 69c24ab

Please sign in to comment.