Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ export default tseslint.config(
],
},
},
stylistic.configs.recommended,
{
plugins: {
'@stylistic': stylistic,
},
rules: {
...stylistic.configs.recommended.rules,
'@stylistic/jsx-one-expression-per-line': ['error', { allow: 'non-jsx' }],
},
},
{
files: ['**/*.test.ts?(x)'],
languageOptions: {
globals: {
...vitest.environments.env.globals,
},
},
plugins: {
vitest,
'testing-library': testingLibrary,
},
rules: {
...vitest.configs.recommended.rules,
...testingLibrary.configs['flat/react'].rules,
},
},
{ ignores: ['dist'] },
)
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"preview": "vite preview"
},
"dependencies": {
"@mui/material": "^6.4.8",
"devicon": "^2.16.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router": "^7.4.0"
Expand Down
502 changes: 502 additions & 0 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { BrowserRouter, Routes, Route } from 'react-router'
import { Game } from '@/components/Game'
import Home from '@/components/Home'
import Home from '@/pages/Home'
import { Navbar } from '@/components/layout/Navbar'
import GitClicker from '@/pages/GitClicker'

export default function App() {
return (
<BrowserRouter>
<Routes>
<Route index element={<Home />} />
<Route path="gitclicker" element={<Game />} />
<Route path="/" element={<Navbar />}>
<Route index element={<Home />} />
<Route path="gitclicker" element={<GitClicker />} />
</Route>
</Routes>
</BrowserRouter>
)
Expand Down
12 changes: 0 additions & 12 deletions src/components/Game.css

This file was deleted.

75 changes: 0 additions & 75 deletions src/components/Game.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions src/components/Home.tsx

This file was deleted.

24 changes: 0 additions & 24 deletions src/components/Office.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/Store.css

This file was deleted.

42 changes: 0 additions & 42 deletions src/components/Store.tsx

This file was deleted.

80 changes: 80 additions & 0 deletions src/components/game/Game.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { useEffect, useState } from 'react'
import '@/styles/game/index.css'
import type { Item, OwnedItems } from '@/types'
import { Grid2 as Grid, Card, CardContent, CardHeader } from '@mui/material'
import { items } from '@/constants/items'
import { Score, Gitcoin } from '@/components/game/core'
import { Skills } from '@/components/game/skills'
import { Store } from '@/components/game/store'

export function Game() {
const [lines, setLines] = useState(0)
const [linesPerMillisecond, setLinesPerMillisecond] = useState(0)

const [ownedItems, setOwnedItems] = useState<OwnedItems>({})

useEffect(() => {
const interval = setInterval(() => {
setLines(prev => prev + linesPerMillisecond)
}, 100)
return () => clearInterval(interval)
}, [linesPerMillisecond])

useEffect(() => {
let count = 0

Object.keys(ownedItems).forEach((name) => {
const item = items.find(element => element.name === name)

if (item != null) {
count += item.linesPerMillisecond * ownedItems[name]
}
})

setLinesPerMillisecond(count)
}, [ownedItems])

const handleClick = () => {
setLines(lines + 1)
}

const handleBuy = (item: Item) => {
setLines(lines - item.price)
setOwnedItems({
...ownedItems,
[item.name]: (ownedItems[item.name] || 0) + 1,
})
}

return (
<>
<Grid size={3}>
<Card component="section" className="card">
<CardContent className="content">
<Score
lines={Math.ceil(lines)}
linesPerSecond={Math.ceil(linesPerMillisecond * 10)}
/>
<Gitcoin onClick={handleClick} />
</CardContent>
</Card>
</Grid>
<Grid size="grow">
<Card component="section" className="card">
<CardHeader title="Skills" />
<CardContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
<Skills skills={ownedItems} />
</CardContent>
</Card>
</Grid>
<Grid size="grow">
<Card component="section" className="card">
<CardHeader title="Store" />
<CardContent>
<Store lines={lines} onBuy={handleBuy} />
</CardContent>
</Card>
</Grid>
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import './Gitcoin.css'
import '@/styles/game/core/gitcoin.css'
import githubIcon from '@/assets/github.svg'

type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ export function Score({ lines, linesPerSecond }: Props) {
return (
<>
<h3 style={{ fontFamily: 'Orbitron' }}>
{lines}
{' '}
lines
{Math.ceil(lines)} lines
</h3>
<small>
per second:
{linesPerSecond}
per second: {Math.ceil(linesPerSecond * 10)}
</small>
</>
)
Expand Down
2 changes: 2 additions & 0 deletions src/components/game/core/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Gitcoin } from './Gitcoin'
export { Score } from './Score'
1 change: 1 addition & 0 deletions src/components/game/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Game } from './Game'
36 changes: 36 additions & 0 deletions src/components/game/skills/Section.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { items } from '@/constants/items'
import { Box, Grid2 as Grid, Typography } from '@mui/material'

type Props = {
itemName: string
number: number
}

export const Section = ({ itemName, number }: Props) => {
const item = items.find(element => element.name === itemName)

if (item == null) {
return null
}

return (
<Box component="section">
<Typography variant="subtitle2" marginBottom={1}>{item.name}</Typography>
<Grid container component="ul" gap={1}>
{Array.from({ length: number }).map((_, index) => (
<li
key={index}
>
<img
src={item.icon}
alt={item.name}
style={{
width: '2rem',
}}
/>
</li>
))}
</Grid>
</Box>
)
}
Loading