diff --git a/client/src/Placard.css b/client/src/Placard.css new file mode 100644 index 0000000..7c4b4ae --- /dev/null +++ b/client/src/Placard.css @@ -0,0 +1,54 @@ +.Placard { + display: flex; + position: relative; + width: 9.4em; + height: 11.44em; + background-position: center left; + background-repeat: no-repeat; + background-size: cover; + margin: 0.25em 0; + display: inline-block; + display: flex; + flex-direction: column; + justify-items: space-between; + pointer-events: none; +} + +.Placard > div { + box-sizing: border-box; + margin: 0 0.9em; +} + +.Placard:not([disabled]) { + cursor: pointer; + pointer-events: all; +} + +.Placard.Selected { + filter: brightness(110%); + transform-origin: 100% 100%; + transform: scale(1.5); + z-index: 10000; +} + +.Placard > div:nth-child(1) { + height: 15.5%; +} + +.Placard > div:nth-child(2), +.Placard > div:nth-child(3), +.Placard > div:nth-child(4), +.Placard > div:nth-child(5) { + height: 15.25%; +} + +.Placard > div:nth-child(6) { + flex: 1; +} + +.Placard > div:hover:nth-child(2), +.Placard > div:hover:nth-child(3), +.Placard > div:hover:nth-child(4), +.Placard > div:hover:nth-child(5) { + background-color: #ffffff40; +} diff --git a/client/src/Placard.js b/client/src/Placard.js new file mode 100644 index 0000000..46fe033 --- /dev/null +++ b/client/src/Placard.js @@ -0,0 +1,70 @@ +import React from "react"; +import "./Placard.css"; +import { assetsPath } from './Common.js'; + +const Placard = ({table, type, active, disabled}) => { + const dismissClicked = (event) => { + table.setState({ buildActive: false }); + } + + const buildClicked = (event) => { + if (!type.match(/^l.*/)) { + if (!table.state.buildActive) { + table.setState({ buildActive: true }); + } + } + }; + + const roadClicked = (event) => { + table.buyRoad(); + table.setState({ buildActive: false }); + }; + + const settlementClicked = (event) => { + table.buySettlement(); + table.setState({ buildActive: false }); + }; + + const cityClicked = (event) => { + table.buyCity(); + table.setState({ buildActive: false }); + }; + + const developmentClicked = (event) => { + table.buyDevelopment(); + table.setState({ buildActive: false }); + }; + + let buttons; + switch (active ? type : undefined) { + case 'orange': + case 'red': + case 'white': + case 'blue': + buttons = <> +