Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import { css } from '@emotion/react'; import { EndScreen as EndScreenModel } from '@uniquegood/realworld-web-interface/lib/models/game/Screen/End'; import React from 'react'; import EndScreenPageA from '@lib/components/Game/Screen/End/pageTypes/A'; import EndScreenPageB from '@lib/components/Game/Screen/End/pageTypes/B'; import { MAX_HEIGHT_DP, MAX_WIDTH_DP } from '@uniquegood/realworld-web-interface/lib/constants/game'; const screenDisplayTypeToComponentMap: Record< EndScreenModel['displayType'], React.FC<{ screen: EndScreenModel }> > = { A: EndScreenPageA, B: EndScreenPageB }; export default function EndScreen(props: EndScreenModel) { const { displayType, style } = props; const ScreenComponent = screenDisplayTypeToComponentMap[displayType]; if (!ScreenComponent) throw new Error('Invalid screen display type'); const pageWrapStyle = React.useMemo(() => { const cssText = ` background-color: ${style.backgroundColor}; `; return css(cssText); }, [style]); return ( <div css={pageContainer}> <div css={[pageWrap, pageWrapStyle]}> <ScreenComponent screen={props} /> </div> </div> ); } const pageContainer = css` width: 100%; height: 100%; `; const pageWrap = css` width: ${MAX_WIDTH_DP}px; height: ${MAX_HEIGHT_DP}px; background-size: contain; background-repeat: no-repeat; background-position: center; `; |