-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea62c45
commit 626ccbb
Showing
26 changed files
with
1,307 additions
and
1,065 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,39 @@ | ||
import FaceIcon from '@mui/icons-material/Face'; | ||
import { Box, Button, Chip, CircularProgress } from '@mui/material'; | ||
import React from 'react'; | ||
|
||
import { useSteamUser } from '../../hooks/useSteamUser'; | ||
import { signInSteam, signOutFromSteam } from '../../services/auth'; | ||
|
||
const SteamAuthentication = () => { | ||
const { data: steamUser, isLoading, refetch } = useSteamUser(); | ||
|
||
return ( | ||
<> | ||
{steamUser && ( | ||
<Box mb={3}> | ||
<Chip | ||
icon={<FaceIcon />} | ||
label={`Angemeldet als ${steamUser.displayName}`} | ||
variant="filled" | ||
/> | ||
</Box> | ||
)} | ||
<Button | ||
onClick={() => | ||
steamUser ? signOutFromSteam().then(() => refetch()) : signInSteam() | ||
} | ||
disabled={isLoading} | ||
startIcon={ | ||
isLoading ? ( | ||
<CircularProgress color="inherit" size={18} thickness={3} /> | ||
) : null | ||
} | ||
> | ||
{steamUser ? 'Abmelden' : 'Bei Steam anmelden'} | ||
</Button> | ||
</> | ||
); | ||
}; | ||
|
||
export default SteamAuthentication; |
This file contains 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 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 |
---|---|---|
@@ -1,37 +1,30 @@ | ||
import { Box } from '@mui/material'; | ||
import React, { FunctionComponent } from 'react'; | ||
|
||
import { UNKNOWN_GAME_ID } from '../../constants'; | ||
import { Game } from '../../types'; | ||
|
||
const FallbackBanner: FunctionComponent<{ game: Game }> = ({ game }) => { | ||
const isUnknownGame = game.id === UNKNOWN_GAME_ID; | ||
|
||
return ( | ||
const FallbackBanner: FunctionComponent<{ game: Game }> = ({ game }) => ( | ||
<Box | ||
display="flex" | ||
alignItems="center" | ||
justifyContent="center" | ||
width="100%" | ||
height="100%" | ||
position="absolute" | ||
> | ||
<Box | ||
display="flex" | ||
alignItems="center" | ||
justifyContent="center" | ||
width="100%" | ||
height="100%" | ||
position="absolute" | ||
sx={{ | ||
margin: '-28px 1em 0 1em', | ||
textAlign: 'center', | ||
fontWeight: 'bold', | ||
fontSize: 'clamp(1.25rem, 2vw, 1.5rem)', | ||
lineHeight: 1.4, | ||
userSelect: 'none', | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
margin: '-28px 1em 0 1em', | ||
textAlign: 'center', | ||
fontWeight: 'bold', | ||
fontSize: isUnknownGame | ||
? 'clamp(1rem, 20vw, 120px)' | ||
: 'clamp(1.25rem, 2vw, 1.5rem)', | ||
lineHeight: 1.4, | ||
userSelect: 'none', | ||
}} | ||
> | ||
{isUnknownGame ? <span title="Unbekanntes Spiel">?</span> : game.name} | ||
</Box> | ||
{game.name} | ||
</Box> | ||
); | ||
}; | ||
</Box> | ||
); | ||
|
||
export default FallbackBanner; |
This file contains 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 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,52 @@ | ||
import { Autocomplete as MuiAutocomplete, TextField } from '@mui/material'; | ||
import React, { useState } from 'react'; | ||
|
||
import { SteamGame, useSteamGames } from '../../hooks/useSteamGames'; | ||
|
||
interface Props { | ||
defaultValue?: GameOption; | ||
onChange: (game: GameOption | null) => void; | ||
} | ||
|
||
export type GameOption = SteamGame | { name: string }; | ||
|
||
const GameSelect = (props: Props) => { | ||
const { data: games, isLoading: gamesLoading } = useSteamGames(); | ||
const [value, setValue] = useState<GameOption | null>( | ||
props.defaultValue ?? null, | ||
); | ||
|
||
return ( | ||
<MuiAutocomplete<GameOption, false, false, true> | ||
freeSolo | ||
options={games ?? []} | ||
value={value} | ||
onChange={(event, option) => { | ||
const value = typeof option === 'string' ? { name: option } : option; | ||
setValue(value); | ||
props.onChange(value); | ||
}} | ||
onInputChange={(event, newValue) => { | ||
setValue({ name: newValue }); | ||
props.onChange({ name: newValue }); | ||
}} | ||
getOptionLabel={option => { | ||
if (typeof option === 'string') { | ||
return option; | ||
} | ||
|
||
return option.name; | ||
}} | ||
selectOnFocus | ||
handleHomeEndKeys | ||
renderInput={props => ( | ||
<TextField {...props} label="Spiel" disabled={gamesLoading} required /> | ||
)} | ||
renderOption={(props, option) => <li {...props}>{option.name}</li>} | ||
disabled={gamesLoading} | ||
loading={gamesLoading} | ||
/> | ||
); | ||
}; | ||
|
||
export default GameSelect; |
This file contains 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
Oops, something went wrong.