Skip to content

Commit

Permalink
chore: restructured frontend component structure
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinjosethomas committed Nov 27, 2024
1 parent 7459e9a commit fd8fc81
Show file tree
Hide file tree
Showing 115 changed files with 133 additions and 198 deletions.
File renamed without changes
7 changes: 2 additions & 5 deletions src/components/Analysis/AnalysisGameList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import {
} from 'react'
import { motion } from 'framer-motion'

import Tournament from './Tournament'
import { Tournament, UserGameList } from 'src/components'
import { AnalysisListContext, GameControllerContext } from 'src/contexts'
import UserGameList from './UserGameList'

interface AnalysisGameListProps {
currentId: string[] | null
Expand All @@ -34,7 +33,7 @@ interface AnalysisGameListProps {
) => Promise<void>
}

const AnalysisGameList: React.FC<AnalysisGameListProps> = ({
export const AnalysisGameList: React.FC<AnalysisGameListProps> = ({
currentId,
currentMaiaModel,
loadNewTournamentGame,
Expand Down Expand Up @@ -181,5 +180,3 @@ const AnalysisGameList: React.FC<AnalysisGameListProps> = ({
</div>
) : null
}

export default AnalysisGameList
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable import/named */
import {
ResponsiveScatterPlot,
ScatterPlotRawSerie,
ResponsiveScatterPlot,
ScatterPlotTooltipProps,
} from '@nivo/scatterplot'
import { useCallback, useContext } from 'react'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'

import { PositionEvaluation } from 'src/types'

interface Props {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Analysis/Tournament.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from 'src/components/Icons/icons'
import { AnalysisTournamentGame } from 'src/types'

export default function Tournament({
export const Tournament = ({
id,
index,
currentId,
Expand Down Expand Up @@ -37,7 +37,7 @@ export default function Tournament({
setCurrentMove: Dispatch<SetStateAction<number>>,
) => Promise<void>
setCurrentMove: Dispatch<SetStateAction<number>>
}) {
}) => {
const games = analysisTournamentList.get(id)
const [sectionId, title] = id.split('---')
const opened = openIndex == index
Expand Down
4 changes: 2 additions & 2 deletions src/components/Analysis/UserGameList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface Props {
currentMaiaModel: string
}

export default function UserGameList({
export const UserGameList = ({
currentId,
selected,
setSelected,
Expand All @@ -41,7 +41,7 @@ export default function UserGameList({
loadNewLichessGames,
loadNewUserGames,
currentMaiaModel,
}: Props) {
}: Props) => {
return (
<div className="flex w-full flex-col">
<div className="grid select-none grid-cols-4 border-b-2 border-white border-opacity-10">
Expand Down
9 changes: 8 additions & 1 deletion src/components/Analysis/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
export {}
export * from './MovePlot'
export * from './Tournament'
export * from './BlunderMeter'
export * from './UserGameList'
export * from './AnalysisGameList'
export * from './HorizontalEvaluationBar'
export * from './PositionEvaluationContainer'
export * from './VerticalEvaluationBar'
1 change: 0 additions & 1 deletion src/components/AuthenticatedWrapper/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/BlunderMeter/index.ts

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import Chessground from '@react-chess/chessground'
import type { DrawShape } from 'chessground/draw'
import { useCallback, useContext } from 'react'
import { GameControllerContext } from 'src/contexts'
import type { DrawShape } from 'chessground/draw'
import Chessground from '@react-chess/chessground'

import { BaseGame, Check } from 'src/types'
import { GameControllerContext } from 'src/contexts'

interface Props {
game: BaseGame
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Color } from 'src/types'
import { useState, useEffect, useContext } from 'react'

import { Color } from 'src/types'
import { AuthContext, ThemeContext } from 'src/contexts'
import { PlayControllerContext } from 'src/contexts/PlayControllerContext'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ import { useCallback, useContext, useEffect, useMemo, useState } from 'react'

import {
AuthContext,
GameControllerContext,
ThemeContext,
WindowSizeContext,
GameControllerContext,
} from 'src/contexts'
import { GameBoard, MovesContainer, BoardController } from 'src/components'
import { GameInfo, ExportGame } from '../Core'
import { GameClock } from '../GameClock'
import {
GameInfo,
GameClock,
GameBoard,
ExportGame,
StatsDisplay,
MovesContainer,
BoardController,
PromotionOverlay,
} from 'src/components'
import { useGameController } from 'src/hooks'
import { StatsDisplay } from '../StatsDisplay'
import { useUnload } from 'src/hooks/useUnload'
import { PromotionOverlay } from 'src/components/PromotionOverlay'
import { PlayControllerContext } from 'src/contexts/PlayControllerContext/PlayControllerContext'

interface Props {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useContext } from 'react'

import { Color } from 'src/types'
import { GameControllerContext } from 'src/contexts'
import Chessground from '@react-chess/chessground'

interface Props {
player: Color
Expand Down
6 changes: 6 additions & 0 deletions src/components/Board/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './GameClock'
export * from './GameBoard'
export * from './MovesContainer'
export * from './BoardController'
export * from './PromotionOverlay'
export * from './GameplayInterface'
1 change: 0 additions & 1 deletion src/components/BoardController/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Compose/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ReactNode, useContext } from 'react'

import { AuthContext } from 'src/contexts'

interface Props {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ReactNode } from 'react'
import { ErrorBoundary } from '../ErrorBoundary'

import { ErrorBoundary } from './ErrorBoundary'

interface Props {
components: (React.FC<{ children: ReactNode }> | typeof ErrorBoundary)[]
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import Link from 'next/link'
import Image from 'next/image'
import { useRouter } from 'next/router'
import { MenuIcon, UserIcon, DiscordIcon } from 'src/components/Icons/icons'
import { useCallback, useContext, useEffect, useState } from 'react'

import { ThemeButton } from '../ThemeButton'
import { ThemeButton } from 'src/components'
import { AuthContext, ModalContext, WindowSizeContext } from 'src/contexts'
import { MenuIcon, UserIcon, DiscordIcon } from 'src/components/Icons/icons'

export const Header: React.FC = () => {
const [showMenu, setShowMenu] = useState(false)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 8 additions & 3 deletions src/components/Core/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export * from './GameInfo'
export * from './ExportGame'
export * from './ContinueAgainstMaia'
export * from './Header'
export * from './Footer'
export * from './Compose'
export * from './Loading'
export * from './Markdown'
export * from './ThemeButton'
export * from './ErrorBoundary'
export * from './AuthenticatedWrapper'
1 change: 0 additions & 1 deletion src/components/ErrorBoundary/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Feedback/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Footer/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/GameBoard/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/GameClock/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/GameplayInterface/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Header/index.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes
2 changes: 2 additions & 0 deletions src/components/Home/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './HomeHero'
export * from './AboutMaia'
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
1 change: 0 additions & 1 deletion src/components/HorizontalEvaluationBar/index.tsx

This file was deleted.

1 change: 1 addition & 0 deletions src/components/Leaderboard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './LeaderboardColumn'
1 change: 0 additions & 1 deletion src/components/Loading/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Markdown/index.ts

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react'
import { Chess } from 'chess.ts'
import { useEffect, useState } from 'react'

import { Move } from 'src/types'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext } from 'react'

import { ModalContext } from 'src/contexts'
import { InstructionsType } from 'src/components/modals/InstructionsModal'
import { InstructionsType } from 'src/components'

interface Props {
icon: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { useContext } from 'react'
import { AnimatePresence } from 'framer-motion'

import { ModalContext } from 'src/contexts'
import { Markdown } from '../../Markdown'
import { ModalContainer } from '../ModalContainer'
import { CloseIcon } from 'src/components/Icons/icons'
import { Markdown, ModalContainer } from 'src/components'

export type InstructionsType =
| 'againstMaia'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ import {
TimeControlOptionNames,
TimeControlOptions,
} from 'src/types'
import bK from './bK.svg'
import wK from './wK.svg'
import wbK from './wbK.svg'
import { ModalContext } from 'src/contexts'
import { ModalContainer } from '../ModalContainer'
import { ModalContainer } from './ModalContainer'
import { CloseIcon } from 'src/components/Icons/icons'

const maiaOptions = [
Expand Down Expand Up @@ -255,7 +252,11 @@ export const PlaySetupModal: React.FC<Props> = (props: Props) => {
className="flex cursor-pointer select-none items-center justify-center rounded-sm border-none bg-background-2 p-2 text-center text-xl outline-none transition duration-200 hover:bg-human-4"
>
<div className="relative h-16 w-16">
<Image src={bK} fill={true} alt="" />
<Image
src="/assets/pieces/black king.svg"
fill={true}
alt=""
/>
</div>
</button>
<button
Expand All @@ -264,7 +265,11 @@ export const PlaySetupModal: React.FC<Props> = (props: Props) => {
className="flex cursor-pointer select-none items-center justify-center rounded-sm border-none bg-background-2 p-4 text-center text-xl outline-none transition duration-200 hover:bg-human-4"
>
<div className="relative h-20 w-20">
<Image src={wbK} fill={true} alt="" />
<Image
alt=""
fill={true}
src="/assets/pieces/white black king.svg"
/>
</div>
</button>
<button
Expand All @@ -273,7 +278,11 @@ export const PlaySetupModal: React.FC<Props> = (props: Props) => {
className="flex cursor-pointer select-none items-center justify-center rounded-sm border-none bg-background-2 p-2 text-center text-xl outline-none transition duration-200 hover:bg-human-4"
>
<div className="relative h-16 w-16">
<Image src={wK} fill={true} alt="" />
<Image
src="/assets/pieces/white king.svg"
fill={true}
alt=""
/>
</div>
</button>
</div>
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions src/components/Misc/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from './GameInfo'
export * from './ExportGame'
export * from './StatsDisplay'
export * from './PlaySetupModal'
export * from './ModalContainer'
export * from './InstructionsModal'
export * from './ContinueAgainstMaia'
1 change: 0 additions & 1 deletion src/components/MovePlot/index.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/MovesContainer/index.ts

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './PlayControls'
export * from './HandBrainPlayControls'
1 change: 0 additions & 1 deletion src/components/PlayControls/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/PositionEvaluationContainer/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { motion } from 'framer-motion'
import { AuthContext } from 'src/contexts'
import React, { useState, useEffect, useContext } from 'react'

import { AuthContext } from 'src/contexts'
import { AnalysisWebGame } from 'src/types'
import { getLichessGames, getAnalysisGameList } from 'src/api'

export default function GameList() {
export const GameList = () => {
const { user } = useContext(AuthContext)
const [selected, setSelected] = useState<'play' | 'hand' | 'brain' | 'pgn'>(
'play',
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable prettier/prettier */
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable import/named */
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable jsx-a11y/no-static-element-interactions */
import { useRouter } from 'next/router'
import React, { useState, useEffect, useContext } from 'react'

Expand All @@ -13,12 +13,11 @@ import {
TuringIcon,
RegularPlayIcon,
} from '../Icons/icons'
import GameList from './GameList'
import { getPlayerStats } from 'src/api'
import { GameList, ProfileColumn } from 'src/components'
import { AuthContext, WindowSizeContext } from 'src/contexts'
import { ProfileColumn } from '../ProfileColumn/ProfileColumn'

const UserProfile: React.FC = () => {
export const UserProfile: React.FC = () => {
const router = useRouter()
const { user } = useContext(AuthContext)
const { isMobile } = useContext(WindowSizeContext)
Expand Down Expand Up @@ -222,5 +221,3 @@ const UserProfile: React.FC = () => {

return <>{isMobile ? mobileLayout() : desktopLayout()}</>
}

export default UserProfile
3 changes: 3 additions & 0 deletions src/components/Profile/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './GameList'
export * from './UserProfile'
export * from './ProfileColumn'
1 change: 0 additions & 1 deletion src/components/PromotionOverlay/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/StatsDisplay/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/ThemeButton/index.tsx

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './Feedback'
export * from './PuzzleLog'
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable jsx-a11y/no-static-element-interactions */
import classNames from 'classnames'
import { useContext } from 'react'
import { TuringControllerContext } from 'src/contexts'

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './TuringGames'
export * from './TuringSubmission'
1 change: 0 additions & 1 deletion src/components/TuringGames/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/components/UserProfile/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/VerticalBar/VerticalBar.tsx

This file was deleted.

Loading

0 comments on commit fd8fc81

Please sign in to comment.