Skip to content

Commit

Permalink
[REFACTOR] Make everything beautiful (maaaaagic...)
Browse files Browse the repository at this point in the history
  • Loading branch information
jannydiamond authored and on3iro committed Oct 19, 2019
1 parent b5465e5 commit 15a5c8d
Show file tree
Hide file tree
Showing 48 changed files with 709 additions and 220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ const getUpgradedBasicNemesisCards = (state: RootState) =>

const getExpansionId = (_: any, id: string) => id

const getIdList = (_: any, props: { upgradedBasicNemesisIds: string[] }) =>
props.upgradedBasicNemesisIds

const getUpgradedBasicNemesisCardIds = (state: RootState) =>
state.Settings.Expansions.UpgradedBasicNemesisCards
.upgradedBasicNemesisCardIds
Expand Down
20 changes: 20 additions & 0 deletions src/components/atoms/ModalBodyWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import styled from 'styled-components/macro'

type Props = {
hasFooter?: boolean
}

const ModalBodyWrapper = styled('div')<Props>`
margin: auto;
height: ${props => (props.hasFooter ? 'calc(100% - 64px)' : '100%')};
width: 100%;
padding: 24px;
position: relative;
overflow-y: auto;
> *:first-child {
margin-top: 0;
}
`

export default ModalBodyWrapper
24 changes: 24 additions & 0 deletions src/components/atoms/ModalFooterWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import styled from 'styled-components/macro'

const ModalFooterWrapper = styled('div')`
margin: auto;
height: 64px;
width: 100%;
padding: 0 24px;
position: relative;
display: flex;
justify-content: flex-end;
align-items: center;
border-top: 1px solid rgba(0, 0, 0, 0.1);
margin-top: -1px;
button {
width: 100%;
}
button + button {
margin-left: 16px;
}
`

export default ModalFooterWrapper
4 changes: 4 additions & 0 deletions src/components/atoms/SectionHeadline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const SectionHeadline = styled(({ themeColor, ...rest }) => <H2 {...rest} />)<
color: ${props => props.themeColor};
font-weight: 300;
margin: 16px 0 8px;
+ div {
margin-top: 0;
}
`

export default SectionHeadline
1 change: 1 addition & 0 deletions src/components/molecules/MageList/MageGridWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import styled from 'styled-components/macro'

const MageGridWrapper = styled('div')`
margin-top: 24px;
width: 100%;
`

MageGridWrapper.displayName = 'MageGridWrapper'
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/MageList/MageTile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const MageTile = React.memo(({ mage, playerNumber, theme }: Props) => {
}, [show])

return (
<Wrapper item xs={6} md={3}>
<Wrapper item xs={12} sm={6} md={3}>
<Tile
body={<Body mage={mage} />}
bgColor={bgColor}
Expand Down
4 changes: 3 additions & 1 deletion src/components/molecules/MageModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import * as types from '../../../types'

import { RenderModalType } from '../../../hooks/useModal'

import ModalBodyWrapper from '../../atoms/ModalBodyWrapper'

import MageInformation from '../MageInformation'

// FIXME refine type (withStyle is the issue here)
Expand Down Expand Up @@ -45,7 +47,7 @@ const MageModal = React.memo(

return (
<RenderModal titleColor={titleColor} titleLabel={titleLabel}>
{body}
<ModalBodyWrapper>{body}</ModalBodyWrapper>
</RenderModal>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/MarketTile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const MarketTile = React.memo(
const card = getCard(marketTile)

return (
<Wrapper item xs={6} md={4} {...rest}>
<Wrapper item xs={12} sm={6} md={4} {...rest}>
{marketTile && (
<Tile
clickHandler={handleSelection}
Expand Down
5 changes: 0 additions & 5 deletions src/components/molecules/Modal/Body.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import styled from 'styled-components'

const Body = styled('div')`
margin: auto;
height: calc(100% - 64px);
width: 100%;
padding: 24px;
position: relative;
overflow-y: auto;
`

export default Body
16 changes: 16 additions & 0 deletions src/components/molecules/Modal/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import styled from 'styled-components'

const Footer = styled('div')`
margin: auto;
height: 64px;
width: 100%;
padding: 0 24px;
position: relative;
display: flex;
justify-content: flex-end;
align-items: center;
border-top: 1px solid rgba(0, 0, 0, 0.1);
margin-top: -1px;
`

export default Footer
6 changes: 3 additions & 3 deletions src/components/molecules/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import CloseIcon from '@material-ui/icons/Close'
type Props = {
titleLabel: string
titleColor: string
body: React.ReactChild
children: React.ReactChild
closeModal: () => void
}

const Modal = React.memo(
({ titleColor, titleLabel, body, closeModal }: Props) => {
({ titleColor, titleLabel, children, closeModal }: Props) => {
const domEl = document.getElementById('modal-root')

if (!domEl) return null
Expand All @@ -37,7 +37,7 @@ const Modal = React.memo(
<CloseIcon />
</CloseButton>
</Header>
<Body>{body}</Body>
<Body>{children}</Body>
</Content>
</Wrapper>
</React.Fragment>,
Expand Down
6 changes: 5 additions & 1 deletion src/components/molecules/NemesisModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { RootState, selectors } from '../../../Redux/Store'

import { RenderModalType } from '../../../hooks/useModal'

import ModalBodyWrapper from '../../atoms/ModalBodyWrapper'

import NemesisInformation from '../NemesisInformation'

type OwnProps = {
Expand Down Expand Up @@ -34,7 +36,9 @@ const NemesisModal = React.memo(({ theme, RenderModal, nemesis }: Props) => {

return (
<RenderModal titleColor={titleColor} titleLabel={titleLabel}>
<NemesisInformation nemesis={nemesis} />
<ModalBodyWrapper>
<NemesisInformation nemesis={nemesis} />
</ModalBodyWrapper>
</RenderModal>
)
})
Expand Down
31 changes: 26 additions & 5 deletions src/components/molecules/Prompt.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import React from 'react'

import Button from '@material-ui/core/Button'

import ModalBodyWrapper from '../atoms/ModalBodyWrapper'
import ModalFooterWrapper from '../atoms/ModalFooterWrapper'

const Prompt = React.memo(
({
yesHandler,
Expand All @@ -11,11 +16,27 @@ const Prompt = React.memo(
children?: React.ReactChild
}) => {
return (
<div>
{children}
<button onClick={yesHandler}>Yes</button>
<button onClick={noHandler}>No</button>
</div>
<React.Fragment>
<ModalBodyWrapper hasFooter={true}>{children}</ModalBodyWrapper>
<ModalFooterWrapper>
<Button
onClick={noHandler}
size="small"
variant="contained"
color="secondary"
>
No
</Button>
<Button
size="small"
variant="contained"
color="primary"
onClick={yesHandler}
>
Yes
</Button>
</ModalFooterWrapper>
</React.Fragment>
)
}
)
Expand Down
1 change: 1 addition & 0 deletions src/components/molecules/SupplyList/ListWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import styled from 'styled-components/macro'

const ListWrapper = styled('div')`
margin-top: 24px;
width: 100%;
`

ListWrapper.displayName = 'ListWrapper'
Expand Down
4 changes: 3 additions & 1 deletion src/components/molecules/SupplyModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import * as types from '../../../types'

import { RenderModalType } from '../../../hooks/useModal'

import ModalBodyWrapper from '../../atoms/ModalBodyWrapper'

import Body from '../SupplyCardInformation'

export type CardProperties = {
Expand Down Expand Up @@ -49,7 +51,7 @@ const SupplyModal = React.memo(

return (
<RenderModal titleColor={titleColor} titleLabel={titleLabel}>
{body}
<ModalBodyWrapper>{body}</ModalBodyWrapper>
</RenderModal>
)
}
Expand Down
12 changes: 10 additions & 2 deletions src/components/molecules/SupplySelection/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ import styled from 'styled-components/macro'
import TileWrapper from '../Tile/Wrapper'

const Wrapper = styled('div')`
${TileWrapper}:hover {
background: #eee;
> p {
margin-top: 0;
}
${TileWrapper} {
border: 2px solid transparent;
&:hover {
border-color: ${props => props.theme.colors.primary.main};
}
}
`

Expand Down
17 changes: 12 additions & 5 deletions src/components/molecules/SupplySelection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import React from 'react'

import SupplyList, { Props as ListProps } from '../SupplyList'

import SectionHeadline from '../../atoms/SectionHeadline'

import InfoItem from '../InfoItem'

import Wrapper from './Wrapper'

type ContextProps = {
Expand Down Expand Up @@ -30,7 +34,7 @@ const renderLists = (lists: List[], selectionHandler: (val: any) => void) =>
return (
<div key={list.id}>
<SelectionHandlerContext.Provider value={selectionContextValue}>
{list.title && <h2>{list.title}</h2>}
{list.title && <SectionHeadline>{list.title}</SectionHeadline>}
<SupplyList {...list} />
</SelectionHandlerContext.Provider>
</div>
Expand All @@ -53,10 +57,13 @@ const SupplySelection = React.memo(
}: Props) => {
return (
<Wrapper>
<h2>Please select {amountOfCardsToSelect} cards to banish!</h2>
<p>
<b>Cards selected:</b> {selectedCardsCount}/{amountOfCardsToSelect}
</p>
<SectionHeadline>
Please select {amountOfCardsToSelect} cards to banish!
</SectionHeadline>
<InfoItem
label="Cards selected"
info={`${selectedCardsCount}/${amountOfCardsToSelect}`}
></InfoItem>
{renderLists(lists, handleSelection)}
</Wrapper>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/Tile/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import styled, { css } from 'styled-components/macro'
import MuiCard from '@material-ui/core/Card'

const selectedMixin = css`
border: 2px solid ${props => props.theme.colors.secondary.main};
border: 2px solid ${props => props.theme.colors.secondary.main} !important;
`

type Props = {
Expand Down
9 changes: 9 additions & 0 deletions src/components/molecules/TreasureList/TreasureGridWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import styled from 'styled-components/macro'

const TreasureGridWrapper = styled('div')`
margin-top: 24px;
`

TreasureGridWrapper.displayName = 'TreasureGridWrapper'

export default TreasureGridWrapper
28 changes: 28 additions & 0 deletions src/components/molecules/TreasureList/TreasureTile/Body.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react'
import List from '@material-ui/core/List'

import { Treasure } from '../../../../types'

import AbilityText from '../../../atoms/AbilityText'

import InfoItem from '../../InfoItem'

import Name from './Name'

type Props = {
treasure: Treasure
}

const Body = React.memo(({ treasure }: Props) => (
<React.Fragment>
<Name component="p">{treasure.name}</Name>
<List>
<InfoItem label="Set" info={treasure.expansion} />
<InfoItem label="Treasure Level" info={treasure.level.toString()} />
{treasure.subtype && <InfoItem label="Subtype" info={treasure.subtype} />}
</List>
<AbilityText dangerouslySetInnerHTML={{ __html: treasure.effect }} />
</React.Fragment>
))

export default Body
10 changes: 10 additions & 0 deletions src/components/molecules/TreasureList/TreasureTile/Name.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styled from 'styled-components/macro'
import Typography from '@material-ui/core/Typography'

const Name = styled(Typography)`
font-weight: bold;
`

Name.displayName = 'Name'

export default Name
16 changes: 16 additions & 0 deletions src/components/molecules/TreasureList/TreasureTile/Wrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import styled from 'styled-components/macro'
import Grid from '@material-ui/core/Grid'

import TileWrapper from '../../Tile/Wrapper'

const Wrapper = styled(Grid)`
${TileWrapper} {
min-height: 148px;
min-width: 30px;
height: 100%;
}
`

Wrapper.displayName = 'Wrapper'

export default Wrapper
Loading

0 comments on commit 15a5c8d

Please sign in to comment.