-
Notifications
You must be signed in to change notification settings - Fork 4
Front tournament #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jmtth
wants to merge
8
commits into
codastream:main
Choose a base branch
from
jmtth:front-tournament
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Front tournament #72
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
48b247e
feat(FRONT): start react tournament
f62ba67
feat(front): add tournament pages
acc7ade
feat(front): Add tournament component
jmtth 01a2df3
feat(front): improve TournamentBracket by adding online status and start
8a373a6
feat(front): Add component FriendsList
jmtth 0f61257
chore: regenerate clean lockfile
20badb6
feat: transfert home too school
3358ca1
feat(front): Improved visual appearance of components and their adapt…
jmtth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import { RefObject, useEffect, useState } from 'react'; | ||
|
|
||
| export interface BracketConnection { | ||
| from: RefObject<HTMLElement | null>; | ||
| to: RefObject<HTMLElement | null>; | ||
| } | ||
|
|
||
| interface Point { | ||
| x: number; | ||
| y: number; | ||
| } | ||
|
|
||
| interface ComputedLine { | ||
| from: Point; | ||
| to: Point; | ||
| } | ||
|
|
||
| interface BracketLinesProps { | ||
| // coordinate reference | ||
| containerRef: RefObject<HTMLElement | null>; | ||
| connections: BracketConnection[]; | ||
| } | ||
|
|
||
| /* renvoi les coordonnées du centre de l'objet / div | ||
| * car getBoundingClientRect renvoie les coordonnées viewport du rectangle | ||
| * cette fontion utilitaire permet aux lignes de partir du centre des capsules | ||
| */ | ||
| function centerOf(rect: DOMRect): Point { | ||
| return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 }; | ||
| } | ||
|
|
||
| /* BracketLines est un composant de rendu SVG qui dessine dynamiquement des lignes | ||
| * entre des éléments du DOM, en restant synchronisé avec le layout réel | ||
| * (responsive, scroll, resize). | ||
| */ | ||
| export function BracketLines({ containerRef, connections }: BracketLinesProps) { | ||
| const [lines, setLines] = useState<ComputedLine[]>([]); | ||
|
|
||
| useEffect(() => { | ||
| const compute = () => { | ||
| const container = containerRef.current; | ||
| if (!container) return; | ||
| // on récupère les coordonnées du container | ||
| const cRect = container.getBoundingClientRect(); | ||
|
|
||
| const computed: ComputedLine[] = []; | ||
|
|
||
| for (const { from, to } of connections) { | ||
| const aEl = from.current; | ||
| const bEl = to.current; | ||
| if (!aEl || !bEl) continue; | ||
|
|
||
| const a = centerOf(aEl.getBoundingClientRect()); | ||
| const b = centerOf(bEl.getBoundingClientRect()); | ||
|
|
||
| //convert viewport -> container local coords | ||
| computed.push({ | ||
| from: { x: a.x - cRect.left, y: a.y - cRect.top }, | ||
| to: { x: b.x - cRect.left, y: b.y - cRect.top }, | ||
| }); | ||
| } | ||
|
|
||
| setLines(computed); | ||
| }; | ||
|
|
||
| /*recalcul : au montage, au resize, au scroll (y compris scrolls internes)*/ | ||
| compute(); | ||
|
|
||
| window.addEventListener('resize', compute); | ||
| window.addEventListener('scroll', compute, true); // capte scroll de conteneurs | ||
| // évite les fuite de mémoire | ||
| return () => { | ||
| window.removeEventListener('resize', compute); | ||
| window.removeEventListener('scroll', compute, true); | ||
| }; | ||
| }, [containerRef, connections]); | ||
|
|
||
| return ( | ||
| <svg className="absolute inset-0 w-full h-full pointer-events-none"> | ||
| {lines.map((line, i) => { | ||
| // courbe de bézier cubique | ||
| const cx = (line.from.x + line.to.x) / 2; | ||
|
|
||
| return ( | ||
| <path | ||
| key={i} | ||
| d={`M ${line.from.x} ${line.from.y} | ||
| C ${cx} ${line.from.y}, | ||
| ${cx} ${line.to.y}, | ||
| ${line.to.x} ${line.to.y}`} | ||
| stroke="rgba(125, 211, 252, 0.9)" | ||
| strokeWidth="2" | ||
| fill="none" | ||
| /> | ||
| ); | ||
| })} | ||
| </svg> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { motion } from 'framer-motion'; | ||
| import React from 'react'; | ||
|
|
||
| interface CircleButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { | ||
| children?: React.ReactNode; | ||
| } | ||
|
|
||
| const dropdownStyle = 'shadow-[0_10px_10px_1px_rgba(205,205,205,0.4)] '; | ||
|
|
||
| export const CircleButton = ({ children, className = '', ...props }: CircleButtonProps) => ( | ||
| <button | ||
| className={` | ||
| transition-all | ||
| hover:scale-110 hover:text-green-900 | ||
| active:scale-95 active:text-red-800 | ||
| h-56 p-6 | ||
| scale-75 | ||
| md:scale-100 md:m-10 | ||
| aspect-square | ||
| rounded-full | ||
| bg-slate-100/80 | ||
| flex items-center justify-center | ||
| font-quantico border border-cyan-300 | ||
| text-gray-700 | ||
| ${dropdownStyle} | ||
| `} | ||
| {...props} | ||
| > | ||
| <p className="text-2xl text-center whitespace-nowrap">{children}</p> | ||
| </button> | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { MatchStatus } from '../../types/types'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| interface MatchNodeProps { | ||
| label: string; | ||
| status: MatchStatus; | ||
| highlight?: boolean; | ||
| onStart?: () => void; | ||
| } | ||
|
|
||
| export function MatchNode({ label, status, highlight = false, onStart }: MatchNodeProps) { | ||
| const canStart = status === 'ready'; | ||
| const { t } = useTranslation(); | ||
|
|
||
| return ( | ||
| <div | ||
| className={` | ||
| flex items-center gap-4 px-6 py-3 rounded-full | ||
| text-sm font-medium font-quantico | ||
| backdrop-blur border border-cyan-200 | ||
| ${highlight ? 'bg-cyan-500 text-white shadow-lg' : 'bg-white/70 text-gray-600'} | ||
| `} | ||
| > | ||
| {/* Label */} | ||
| <span>{label}</span> | ||
|
|
||
| {/* Start button */} | ||
| <button | ||
| onClick={onStart} | ||
| disabled={!canStart} | ||
| className={` | ||
| px-4 py-1.5 rounded-full text-xs font-semibold | ||
| transition-all | ||
| ${ | ||
| canStart | ||
| ? 'bg-emerald-500 text-white hover:bg-emerald-600 hover:scale-105 active:scale-100' | ||
| : 'bg-gray-300 text-gray-500 cursor-not-allowed' | ||
| } | ||
| `} | ||
| aria-disabled={!canStart} | ||
| > | ||
| {t('game.start')} | ||
| </button> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { Player } from '../../types/types'; | ||
| import Avatar from './Avatar'; | ||
|
|
||
| export function PlayerCapsule({ player }: { player: Player }) { | ||
| const isOnline = player.online === true; | ||
| const isWaiting = player.status === 'waiting'; | ||
| return ( | ||
| <div | ||
| className={` | ||
| flex items-center gap-3 px-4 py-2 rounded-full | ||
| border backdrop-blur overflow-hidden | ||
| ${isWaiting ? 'border-gray-400 bg-white/10 opacity-95' : 'border-cyan-300 bg-white/80'} | ||
| `} | ||
| > | ||
| {/* Avatar + status */} | ||
| <div className="relative"> | ||
| <Avatar src={player.avatar} size="sm" /> | ||
|
|
||
| <span | ||
| className={[ | ||
| 'absolute bottom-0 right-0 w-3 h-3 rounded-full border-2 border-white', | ||
| isOnline ? 'bg-emerald-500' : 'bg-gray-400', | ||
| ].join(' ')} | ||
| aria-label={isOnline ? 'online' : 'offline'} | ||
| /> | ||
| </div> | ||
|
|
||
| {/* Name */} | ||
| <span className="text-sm font-medium text-gray-700 font-quantico whitespace-nowrap"> | ||
| {player.name} | ||
| </span> | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu penses qu’on peut supprimer ce commentaire ou il apporte quelque chose pour le mock ?