-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,6 @@ | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Generated by CRA (eslint internally) | ||
.eslintcache |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import {useCharacters} from '../shared/firebase' | ||
import {CharacterCard} from './CharacterCard' | ||
import {Link as RouterLink} from 'react-router-dom' | ||
import {Text} from '@fluentui/react' | ||
import {colors} from '../shared/theme' | ||
import {useState} from 'react' | ||
import {ShareDialog} from './ShareDialog' | ||
|
||
function CharacterCardWrapper({character, mode}) { | ||
const [status, setStatus] = useState('idle') | ||
|
||
return ( | ||
<> | ||
<CharacterCard key={character.id} character={character} mode={mode}> | ||
{mode === 'view-characters' && ( | ||
<RouterLink to={`/character/${character.id}`} className="CharacterCard__action-button"> | ||
View Character | ||
</RouterLink> | ||
)} | ||
{mode === 'share-characters' && ( | ||
<button className="CharacterCard__action-button" onClick={() => setStatus('sharing')}> | ||
Share Character | ||
</button> | ||
)} | ||
</CharacterCard> | ||
<ShareDialog isOpen={status === 'sharing'} onDismiss={() => setStatus('idle')} character={character} /> | ||
</> | ||
) | ||
} | ||
|
||
/** | ||
* Renders a list of `<CharacterCard>`'s from a document and a resource. | ||
* @param {{mode: 'view-characters' | 'share-characters'}} props | ||
* @returns {JSX.Element|[JSX.Element]} | ||
* @constructor | ||
*/ | ||
export function CharacterCardList({mode}) { | ||
const characters = useCharacters() | ||
|
||
// Render all the Character Cards if there are any. | ||
if (characters.length > 0) { | ||
return characters.map(character => <CharacterCardWrapper character={character} mode={mode} />) | ||
} | ||
|
||
// Otherwise, inform the user of how to create a character. | ||
// TODO: Add alt for pride-drawing.svg | ||
return ( | ||
<div | ||
style={{ | ||
width: '100%', | ||
height: 'calc(100% - 100px)', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<img src="/pride-drawing.svg" alt="" style={{width: 270, height: 196, marginBottom: 35}} /> | ||
<Text variant="mediumTitle" as="h2" style={{textAlign: 'center', maxWidth: 232, color: colors.dark}}> | ||
To get started, add some characters with the "New" button. | ||
</Text> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {createContext, useContext} from 'react' | ||
|
||
import {Text} from '@fluentui/react' | ||
import {DialogContent, DialogOverlay} from '@reach/dialog' | ||
import {useId} from '@reach/auto-id' | ||
|
||
import '../styles/Dialog.css' | ||
|
||
const DialogContext = createContext({titleId: ''}) | ||
|
||
export function DialogTitle(props) { | ||
const {titleId} = useContext(DialogContext) | ||
return <Text id={titleId} variant="title" as="h1" className="Dialog__title" {...props} /> | ||
} | ||
|
||
export function DialogParagraph(props) { | ||
return <Text variant="medium" {...props} /> | ||
} | ||
|
||
export function Dialog({isOpen, onDismiss, children, ...props}) { | ||
const titleId = useId('title') | ||
return ( | ||
<DialogOverlay isOpen={isOpen} onDismiss={onDismiss} className="Dialog__overlay" {...props}> | ||
<DialogContent className="Dialog" aria-labelledby={titleId}> | ||
<DialogContext.Provider value={{titleId}}>{children}</DialogContext.Provider> | ||
</DialogContent> | ||
</DialogOverlay> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {Spinner} from '@fluentui/react' | ||
import {Center} from './Center' | ||
import {emptyObject} from '../shared/empty' | ||
|
||
export function Loading({centerStyle = emptyObject, ...props}) { | ||
return ( | ||
<Center style={centerStyle}> | ||
<Spinner {...props} /> | ||
</Center> | ||
) | ||
} |