-
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
Showing
10 changed files
with
132 additions
and
6 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
File renamed without changes.
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,12 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import TownLocation from './TownLocation'; | ||
|
||
describe('<TownLocation />', () => { | ||
it('renders location name', () => { | ||
const name = 'Marketplace'; | ||
render(<TownLocation name={name} />); | ||
|
||
expect(screen.getByRole('button')).toHaveTextContent(name); | ||
}); | ||
}); |
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,28 @@ | ||
import React from 'react'; | ||
import styled from '@emotion/styled'; | ||
|
||
type TownLocationProps = { | ||
name: string; | ||
} | ||
|
||
export default function TownLocation({ name }: TownLocationProps): JSX.Element { | ||
return <Container>{name}</Container>; | ||
} | ||
|
||
const Container = styled.button` | ||
background-color: lightblue; | ||
border: 1px solid #c0c0c0; | ||
border-radius: 50%; | ||
height: 7em; | ||
outline: 0; | ||
padding: 1em; | ||
width: 7em; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
`; |
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,10 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import TownScene from '.'; | ||
|
||
describe('<TownScene />', () => { | ||
it('renders all shops', () => { | ||
render(<TownScene />); | ||
expect(screen.getAllByRole('button')).toHaveLength(4); | ||
}); | ||
}); |
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,38 @@ | ||
import React from 'react'; | ||
import styled from '@emotion/styled'; | ||
import TownLocation from './TownLocation'; | ||
|
||
const locations = ["Blacksmith's", 'Guild', 'Marketplace', "Alchemist's"]; | ||
|
||
export default function TownScene(): JSX.Element { | ||
return ( | ||
<Container> | ||
<MainContent> | ||
<LocationContainer> | ||
{locations.map((name) => <TownLocation key={name} name={name} />)} | ||
</LocationContainer> | ||
</MainContent> | ||
</Container> | ||
); | ||
} | ||
|
||
const Container = styled.div` | ||
width: 100%; | ||
display: flex; | ||
min-height: 70vh; | ||
align-items: stretch; | ||
`; | ||
|
||
const MainContent = styled.div` | ||
flex: 1 1 100%; | ||
display: flex; | ||
position: relative; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-content: center; | ||
`; | ||
|
||
const LocationContainer = styled.div` | ||
display: flex; | ||
justify-content: space-around; | ||
`; |
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,23 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
import { AppThunk } from '../../7-app/types'; | ||
|
||
export enum Scenes { | ||
Combat = 'combat', | ||
Town = 'town', | ||
} | ||
|
||
const initialState = { | ||
currentScene: Scenes.Town, | ||
}; | ||
|
||
const sceneMetaSlice = createSlice({ | ||
name: 'sceneMeta', | ||
initialState, | ||
reducers: { | ||
changedScene(state, action) { | ||
state.currentScene = action.payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export default sceneMetaSlice.reducer; |
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