Skip to content

Commit

Permalink
Create component preview for game-section-area
Browse files Browse the repository at this point in the history
  • Loading branch information
zourdyzou committed Aug 5, 2022
1 parent 4a8e404 commit ab51271
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/components/game-area/game-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export interface Props {
children: React.ReactNode;
}

const WrapperContainer: FunctionComponent<PropsWithChildren> = ({ children }) => (
export const WrapperContainer: FunctionComponent<PropsWithChildren> = ({ children }) => (
<div className={styles.wrapperContainer}>{children}</div>
);

const GameArea: FunctionComponent<PropsWithChildren> = ({ children }) => (
export const GameArea: FunctionComponent<PropsWithChildren> = ({ children }) => (
<div className={styles.gameArea}>{children}</div>
);

Expand Down
12 changes: 12 additions & 0 deletions src/components/game-area/game-over.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React, { FunctionComponent, PropsWithChildren } from "react";

import styles from "./game-section.module.scss";

interface GameOverProps {
isWin: boolean;
onClick: () => void;
}

export const GameOver: FunctionComponent<GameOverProps> = ({ onClick, isWin }) => {
return <div className={styles.gameOverComponent}>{isWin ? "😎" : "🙁"}</div>;
};
28 changes: 28 additions & 0 deletions src/components/game-area/game-section-example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { GameArea, WrapperContainer } from "@components/game-area/game-layout";
import { GameOver } from "@components/game-area/game-over";
import { GridComponent } from "@components/grid";
import { ScoreBoard } from "@components/scoreboard";
import { Top } from "@components/top-section";
import { Field, fieldGenerator } from "@helpers/field";
import React, { FunctionComponent } from "react";

export const GameSectionExample: FunctionComponent = () => {
return (
<WrapperContainer>
<Top feature="Flag" firstAction="right click">
Minesweeper
</Top>
<GameArea>
<ScoreBoard
time="000"
mines="000"
levels={["beginner", "intermediate", "expert"]}
onReset={() => null}
onChange={() => null}
/>
<GameOver onClick={() => null} isWin={true} />
<GridComponent children={fieldGenerator(10, 0.5) as Field} onClick={() => null} onContextMenu={() => null} />
</GameArea>
</WrapperContainer>
);
};
19 changes: 19 additions & 0 deletions src/components/game-area/game-section.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,22 @@
border: 6px solid #e3e3e3;
background-color: #e3e3e3;
}

.gameOverComponent {
top: 60%;
left: 50%;
z-index: 11;
width: 8vw;
height: 8vw;
font-size: 4vw;
text-align: center;
user-select: none;
cursor: pointer;
line-height: 8vw;
position: absolute;
border-radius: 50%;
pointer-events: auto;
background-color: #d1d1d1;
transform: translate(-50%, -50%);
border: 1px solid rgba(51, 51, 51, 0.25);
}
16 changes: 16 additions & 0 deletions src/components/game-area/game-section.module.scss.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// autogenerated by typings-for-css-modules-loader.
// Please do not change this file!
declare namespace GameSectionModuleScssNamespace {
export interface IGameSectionModuleScss {
gameArea: string;
gameOverComponent: string;
wrapperContainer: string;
}
}

declare const GameSectionModuleScssModule: GameSectionModuleScssNamespace.IGameSectionModuleScss & {
/** WARNING: Only available when `css-loader` is used without `style-loader` or `mini-css-extract-plugin` */
locals: GameSectionModuleScssNamespace.IGameSectionModuleScss;
};

export = GameSectionModuleScssModule;
Empty file.
3 changes: 3 additions & 0 deletions src/components/game-area/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { WrapperContainer, GameArea, GameLayout } from "./game-layout";
export { GameOver } from "./game-over";
export { GameSectionExample } from "./game-section-example";
13 changes: 4 additions & 9 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import "@styles/styles.scss";
import "normalize.css/normalize.css";

import { GridComponent } from "@components/grid";
import { MockFieldData } from "@helpers/mockData";
import { GameSectionExample } from "@components/game-area";
// import { GridComponent } from "@components/grid";
// import { MockFieldData } from "@helpers/mockData";
import React from "react";
import { createRoot } from "react-dom/client";

Expand All @@ -15,13 +16,7 @@ const root = createRoot(container);
root.render(
<React.StrictMode>
{/*<Segment writeKey={process.env.SEGMENT_WRITE_KEY as string}>*/}
<>
{/*<Top feature="Flag" firstAction="ctrl" secondAction="click">*/}
{/* Minesweeper*/}
{/*</Top>*/}
{/*<ScoreBoard time="000" onReset={() => null} levels={["beginner", "intermediate", "expert"]} mines="010" />*/}
<GridComponent children={MockFieldData} onContextMenu={() => null} onClick={() => null} />
</>
<GameSectionExample />
{/*</Segment>*/}
</React.StrictMode>
);

0 comments on commit ab51271

Please sign in to comment.