Compare commits

..

No commits in common. "306ecea262b881b8b2a2624e8b19d781c34306c0" and "f25fd51572fe44ac87513029d20384ca6e968845" have entirely different histories.

10 changed files with 97 additions and 100 deletions

View File

@ -2,7 +2,6 @@ import React from 'react';
import { AppContext } from '../../../context/app' import { AppContext } from '../../../context/app'
import { AppData } from '../../../context/data' import { AppData } from '../../../context/data'
import { WHITE, BLACK } from '../Stone' import { WHITE, BLACK } from '../Stone'
import Wobler from '../../Wobler'
export default function Create() { export default function Create() {
const ctx = Definitions() const ctx = Definitions()
@ -16,13 +15,10 @@ export default function Create() {
const request = ctx.get_GameProposalRequest() const request = ctx.get_GameProposalRequest()
ctx.setFetching(true)
postData("/api/gameproposal", request) postData("/api/gameproposal", request)
.then((responce) => { .then((responce) => {
console.log("responce", responce) // JSON data parsed by `data.json()` call console.log("responce", responce) // JSON data parsed by `data.json()` call
ctx.clear_Message2Opponent() ctx.clear_Message2Opponent()
ctx.setFetching(false)
}); });
} }
@ -31,7 +27,7 @@ export default function Create() {
className={'game-action create' + (ctx.isEnabled ? ' enabled' : ' disabled')} className={'game-action create' + (ctx.isEnabled ? ' enabled' : ' disabled')}
onClick={onClick} onClick={onClick}
> >
<Wobler text="Leaderboard" dance={ctx.fetching} /> Create
</button> </button>
) )
} }
@ -68,11 +64,8 @@ function Definitions() {
hasCurrentUser, hasCurrentUser,
isEnabled, isEnabled,
fetching: ctx.newGame.fetching,
setFetching: (status) => { dispatchCtx({ update: "newGame", fetching: status }) },
get_GameProposalRequest, get_GameProposalRequest,
clear_Message2Opponent: () => { dispatchCtx({ update: "newGame", message: '' }) }, clear_Message2Opponent: () => { dispatchCtx({ update: "newGame", message: '' }) }
} }
} }

View File

@ -1,11 +1,11 @@
import './GameMessage.css' import './GameMessage.css'
import React from 'react' import React from 'react'
// import { AppContext } from '../../context/app' import { AppContext } from '../../context/app'
export default function GameMessage() { export default function GameMessage() {
// const [ctx] = React.useContext(AppContext) const [ctx] = React.useContext(AppContext)
return ( return (
<div className='game-message'> <div className='game-message'>

View File

@ -8,14 +8,14 @@ import Proposal from './GameSelector/GameProposal';
export default function GameSelector() { export default function GameSelector() {
const [data] = React.useContext(AppData) const [data] = React.useContext(AppData)
const [/*ctx*/, dispatchCtx] = React.useContext(AppContext) const [ctx, dispatchCtx] = React.useContext(AppContext)
const { pathname } = useLocation(); const { pathname } = useLocation();
const isProposalPath = matchPath("/game/proposal/*", pathname); const isProposalPath = matchPath("/game/proposal/*", pathname);
const isActivelPath = matchPath("/game/active/*", pathname); const isActivelPath = matchPath("/game/active/*", pathname);
const isArchivePath = matchPath("/game/archive/*", pathname); const isArchivePath = matchPath("/game/archive/*", pathname);
// console.log("GameSelector appCtx", ctx) console.log("GameSelector appCtx", ctx)
const onClick_proposal = (selectedGame) => { const onClick_proposal = (selectedGame) => {
dispatchCtx({ component: "game-selector", selectedGameProposal: selectedGame }) dispatchCtx({ component: "game-selector", selectedGameProposal: selectedGame })

View File

@ -1,30 +0,0 @@
import './Header.css';
import React from "react"
import { NavLink } from "react-router-dom";
import OnlineToggle from './OnlineTgl';
import { AppData } from "../context/data"
import Wobler from './Wobler';
export default function Header() {
const [data] = React.useContext(AppData)
return (
<div className='app-header'>
<h1 >
CordaCheckers
</h1>
<OnlineToggle />
<nav>
<NavLink to="/about">
About
</NavLink>
<NavLink to="/game">
<Wobler text="Game" dance={data.gamesFetching} />
</NavLink>
<NavLink to="/leaderboard">
<Wobler text="Leaderboard" dance={data.leaderboardFetching} />
</NavLink>
</nav>
</div>
)
}

View File

@ -0,0 +1,43 @@
import './index.css';
import './wave.css'
import React from "react"
import { NavLink } from "react-router-dom";
import OnlineToggle from '../OnlineTgl';
import { AppData } from "../../context/data"
export default function Header() {
const [data] = React.useContext(AppData)
return (
<div className='app-header'>
<h1 >
CordaCheckers
</h1>
<OnlineToggle />
<nav>
<NavLink to="/about">
About
</NavLink>
<NavLink to="/game" className={data.gamesFetching && "woble"}>
<span>G</span>
<span>a</span>
<span>m</span>
<span>e</span>
</NavLink>
<NavLink to="/leaderboard" className={data.leaderboardFetching && "woble"}>
<span>L</span>
<span>e</span>
<span>a</span>
<span>d</span>
<span>e</span>
<span>r</span>
<span>b</span>
<span>o</span>
<span>a</span>
<span>r</span>
<span>d</span>
</NavLink>
</nav>
</div>
)
}

View File

@ -0,0 +1,48 @@
/* https://blog.karimould.dev/hover-letter-wave-effect-in-css */
.woble {
display: flex;
cursor: pointer;
justify-content: center;
align-items: center;
/* text-transform: uppercase; */
/* font-size: 1.5rem; */
/* padding: 1rem 2rem; */
/* background-color: black; */
/* color: white; */
/* border-radius: 100px; */
/* gap: 1rem; */
}
/* .wave > span {
transform: rotate(-90deg);
} */
@keyframes wave {
0% {
transform: scale(1) /*rotate(-90deg)*/;
}
50% {
transform: scale(1.1) /*rotate(-90deg)*/;
}
100% {
transform: scale(1) rotate(-5deg);
}
}
.woble span {
animation: wave 0.4s linear infinite;
}
.woble span:nth-child(2) {
animation-delay: 0.1s;
}
.woble span:nth-child(3) {
animation-delay: 0.2s;
}
.woble span:nth-child(4) {
animation-delay: 0.3s;
}

View File

@ -1,42 +0,0 @@
/* https://blog.karimould.dev/hover-letter-wave-effect-in-css */
/*
.wave > span {
transform: rotate(-90deg);
}
*/
@keyframes wave {
0% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1) rotate(-5deg);
}
}
.wobler.dance {
display: flex;
flex-direction: row;
}
.wobler.dance span {
animation: wave 0.4s linear infinite;
}
.wobler.dance span:nth-child(2) {
animation-delay: 0.1s;
}
.wobler.dance span:nth-child(3) {
animation-delay: 0.2s;
}
.wobler.dance span:nth-child(4) {
animation-delay: 0.3s;
}

View File

@ -1,14 +0,0 @@
import './Wobler.css'
import React from 'react';
export default function Wobler({ text, dance }) {
const spannedMessage = Array.from(text).map((letter, idx) => {
return <span key={idx}>{letter}</span>
})
return (
<div className={'wobler' + (dance === true ? ' dance' : '')}>
{spannedMessage}
</div>
)
}

View File

@ -25,7 +25,6 @@ export const initialState = {
whitePlayer: '', whitePlayer: '',
blackPlayer: '', blackPlayer: '',
message: '', message: '',
fetching: false,
}, },
} }