-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): added
EntityPreview
component, updated EpisodeListItem
…
…and `LevelListItem`
- Loading branch information
Showing
7 changed files
with
188 additions
and
63 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
src/features/ui/components/entity-preview/entity-preview.module.css
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,88 @@ | ||
.container { | ||
display: flex; | ||
width: 1.25rem; | ||
height: 1.25rem; | ||
flex-shrink: 0; | ||
border-radius: 0.25rem; | ||
justify-content: center; | ||
align-items: center; | ||
text-align: start; | ||
appearance: none; | ||
color: white; | ||
} | ||
|
||
.dice0 { | ||
background-color: var(--color-orange); | ||
} | ||
|
||
.dice1 { | ||
background-color: var(--color-yellow); | ||
} | ||
|
||
.dice2 { | ||
background-color: var(--color-green); | ||
} | ||
|
||
.dice3 { | ||
background-color: var(--color-teal); | ||
} | ||
|
||
.dice4 { | ||
background-color: var(--color-blue); | ||
} | ||
|
||
.dice5 { | ||
background-color: var(--color-purple); | ||
} | ||
|
||
.dice6 { | ||
background-color: var(--color-red); | ||
} | ||
|
||
.movable { | ||
background-color: var(--color-white); | ||
} | ||
|
||
.floor { | ||
background-color: rgba(255, 255, 255, 0.15); | ||
} | ||
|
||
.director, | ||
.target { | ||
border: 1px solid rgba(255, 255, 255, 0.25); | ||
} | ||
|
||
.target0 { | ||
border: 1px solid var(--color-orange); | ||
color: var(--color-orange); | ||
} | ||
|
||
.target1 { | ||
border: 1px solid var(--color-yellow); | ||
color: var(--color-yellow); | ||
} | ||
|
||
.target2 { | ||
border: 1px solid var(--color-green); | ||
color: var(--color-green); | ||
} | ||
|
||
.target3 { | ||
border: 1px solid var(--color-teal); | ||
color: var(--color-teal); | ||
} | ||
|
||
.target4 { | ||
border: 1px solid var(--color-blue); | ||
color: var(--color-blue); | ||
} | ||
|
||
.target5 { | ||
border: 1px solid var(--color-purple); | ||
color: var(--color-purple); | ||
} | ||
|
||
.target6 { | ||
border: 1px solid var(--color-red); | ||
color: var(--color-red); | ||
} |
55 changes: 55 additions & 0 deletions
55
src/features/ui/components/entity-preview/entity-preview.tsx
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,55 @@ | ||
import clsx from 'clsx'; | ||
|
||
import { | ||
Entity, | ||
isDice, | ||
isFloor, | ||
isMovable, | ||
} from '../../../engine/types/entities'; | ||
import { getArrowSymbol } from '../../utils/get-arrow-symbol'; | ||
import $$ from './entity-preview.module.css'; | ||
|
||
export const EntityPreview = ({ entity }: { entity?: Entity }) => { | ||
if (!entity) { | ||
return <div className={clsx($$.container)} />; | ||
} | ||
|
||
if (isDice(entity)) { | ||
const { value } = entity; | ||
|
||
return ( | ||
<div className={clsx($$.container, $$[`dice${value}`])}>{2 ** value}</div> | ||
); | ||
} | ||
|
||
if (isMovable(entity)) { | ||
return <div className={clsx($$.container, $$.movable)} />; | ||
} | ||
|
||
if (isFloor(entity)) { | ||
if (entity.target !== undefined) { | ||
return ( | ||
<div | ||
className={clsx( | ||
$$.container, | ||
$$.floor, | ||
$$.target, | ||
$$[`target${entity.target}`], | ||
)} | ||
> | ||
{2 ** entity.target} | ||
</div> | ||
); | ||
} else if (entity.direction !== undefined) { | ||
return ( | ||
<div className={clsx($$.container, $$.floor, $$.director)}> | ||
{getArrowSymbol(entity.direction)} | ||
</div> | ||
); | ||
} | ||
|
||
return <div className={clsx($$.container, $$.floor)} />; | ||
} | ||
|
||
return <div className={clsx($$.container)}>X</div>; | ||
}; |
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