Skip to content

Commit

Permalink
Create bomb component
Browse files Browse the repository at this point in the history
  • Loading branch information
zourdyzou committed Jul 29, 2022
1 parent 19dbcc7 commit bce613b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/components/grid/cell/cell.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,14 @@
filter: brightness(1);
}
}

.bombFrame {
background-color: #ec433c;
}

.bombEntity {
border-radius: 50%;
width: 1vw;
height: 1vw;
background-color: #333;
}
2 changes: 2 additions & 0 deletions src/components/grid/cell/cell.module.scss.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Please do not change this file!
declare namespace CellModuleScssNamespace {
export interface ICellModuleScss {
bombEntity: string;
bombFrame: string;
changedBorderColor: string;
closedFrame: string;
emptyFrame: string;
Expand Down
12 changes: 11 additions & 1 deletion src/components/grid/cell/cell.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CellState, Cell as CellType } from "@helpers/field";
import classNames from "classnames";
import React, { FunctionComponent } from "react";
import React, { FunctionComponent, PropsWithChildren, ReactNode } from "react";

import styles from "./cell.module.scss";

Expand All @@ -13,6 +13,12 @@ export const CellComponent: FunctionComponent<CellComponentType> = ({ mouseDown,
switch (children) {
case CellState.empty:
return <EmptyFrame />;
case CellState.bomb:
return (
<BombFrame>
<span className={styles.bombEntity} />
</BombFrame>
);
case CellState.hidden:
return <ClosedFrame mouseDown={mouseDown} />;
default:
Expand All @@ -34,3 +40,7 @@ const ClosedFrame: FunctionComponent<{ mouseDown: boolean }> = ({ mouseDown }) =
const EmptyFrame: FunctionComponent = () => {
return <div className={classNames(styles.closedFrame, styles.emptyFrame)} />;
};

const BombFrame: FunctionComponent<{ children: ReactNode }> = ({ children }) => {
return <div className={classNames(styles.closedFrame, styles.emptyFrame, styles.bombFrame)}>{children}</div>;
};
2 changes: 1 addition & 1 deletion src/components/scoreboard/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { ScoreBoard, ScoreboardProps } from "./scoreboard";
export * from "./scoreboard";
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"@styles/*": ["src/styles/*"],
"@components/*": ["src/components/*"],
"@assets/*": ["src/assets/*"],
"@helpers/*": ["src/helpers/*"]
"@helpers/*": ["src/helpers/*"],
"~types/*": ["src/@types/*"]
},
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
Expand Down
1 change: 1 addition & 0 deletions webpack/config/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export const aliasItems = {
"@components": join(rootDir, "/src/components"),
"@assets": join(rootDir, "/src/assets"),
"@helpers": join(rootDir, "/src/helpers"),
"~types": join(rootDir, "/src/@types"),
};

0 comments on commit bce613b

Please sign in to comment.