Skip to content

Commit

Permalink
Merge pull request #40 from nickovchinnikov/nick/refactoringAndUpdates
Browse files Browse the repository at this point in the history
Nick/refactoring and updates
  • Loading branch information
nickovchinnikov committed Sep 23, 2021
2 parents f956d6d + d89a5d7 commit b0893db
Show file tree
Hide file tree
Showing 10 changed files with 3,441 additions and 4,916 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,7 @@
### Bombs counter

[Pull request](https://github.com/nickovchinnikov/minesweeper/pull/35/files)

#### Refactoring and update dependencies

[Pull request](https://github.com/nickovchinnikov/minesweeper/pull/40)
9 changes: 8 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
module.exports = {
presets: [
'@babel/preset-env',
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
'@babel/preset-typescript',
'@babel/preset-react',
],
Expand Down
8,181 changes: 3,359 additions & 4,822 deletions package-lock.json

Large diffs are not rendered by default.

59 changes: 30 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,51 +34,52 @@
},
"homepage": "https://github.com/nickovchinnikov/minesweeper#readme",
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.6",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@emotion/jest": "^11.3.0",
"@storybook/addon-actions": "^6.3.6",
"@storybook/addon-essentials": "^6.3.6",
"@storybook/addon-links": "^6.3.6",
"@storybook/builder-webpack5": "^6.3.6",
"@storybook/manager-webpack5": "^6.3.6",
"@storybook/react": "^6.3.6",
"@stryker-mutator/core": "^5.2.3",
"@stryker-mutator/jest-runner": "^5.2.3",
"@storybook/addon-actions": "^6.3.8",
"@storybook/addon-essentials": "^6.3.8",
"@storybook/addon-links": "^6.3.8",
"@storybook/builder-webpack5": "^6.3.8",
"@storybook/manager-webpack5": "^6.3.8",
"@storybook/react": "^6.3.8",
"@stryker-mutator/core": "^5.4.0",
"@stryker-mutator/jest-runner": "^5.4.0",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/react-hooks": "^7.0.1",
"@testing-library/react": "^12.1.0",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.2.1",
"@types/jest": "^26.0.24",
"@types/react": "^17.0.15",
"@types/jest": "^27.0.2",
"@types/react": "^17.0.24",
"@types/react-dom": "^17.0.9",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0",
"@typescript-eslint/eslint-plugin": "^4.31.2",
"@typescript-eslint/parser": "^4.31.2",
"babel-loader": "^8.2.2",
"chromatic": "^5.9.2",
"css-loader": "^6.2.0",
"chromatic": "^5.10.1",
"css-loader": "^6.3.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.26.0",
"eslint-plugin-react-hooks": "^4.2.0",
"html-webpack-plugin": "^5.3.2",
"husky": "^7.0.1",
"jest": "^27.0.6",
"prettier": "^2.3.2",
"husky": "^7.0.2",
"jest": "^27.2.1",
"prettier": "^2.4.1",
"stryker": "^0.35.1",
"stryker-cli": "^1.0.2",
"style-loader": "^3.2.1",
"typescript": "^4.3.5",
"style-loader": "^3.3.0",
"typescript": "^4.4.3",
"url-loader": "^4.1.1",
"webpack": "^5.48.0",
"webpack-cli": "^4.7.2",
"webpack-dev-server": "^3.11.2"
"webpack": "^5.53.0",
"webpack-bundle-analyzer": "^4.4.2",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "^4.2.1"
},
"dependencies": {
"@emotion/react": "^11.4.0",
"@emotion/react": "^11.4.1",
"@emotion/styled": "^11.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
Expand Down
19 changes: 5 additions & 14 deletions src/components/Game/Game.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
import React from 'react';
import { Story, Meta } from '@storybook/react';

import { CellState, Field } from '@/helpers/Field';
import { Field } from '@/helpers/Field';
import { fieldGenerator } from '@/helpers/__mocks__/Field';

import { Grid } from '@/components/Grid';
import { Top } from '@/components/Top';
import { Scoreboard } from '@/components/Scoreboard';

import { GameArea } from './GameArea';
import { Wrapper, WrapperProps } from './Wrapper';
import { Wrapper } from './Wrapper';
import { GameOver } from './GameOver';

export default {
title: 'Game/Example',
component: Wrapper,
} as Meta;

const Template: Story<WrapperProps> = (args) => <Wrapper {...args} />;
const Template: Story = (args) => <Wrapper {...args} />;

export const GameExample = Template.bind({});

const { empty: e, hidden: h, bomb: b, flag: f } = CellState;

const defautGameField: Field = [
[f, f, h, h, h],
[b, 3, 1, e, e],
[1, 1, h, 1, 1],
[1, e, e, 1, b],
[2, 1, e, 1, e],
];

GameExample.args = {
children: (
<>
Expand All @@ -46,7 +37,7 @@ GameExample.args = {
/>
<GameOver onClick={() => null} isWin={true} />
<Grid onClick={() => null} onContextMenu={() => null}>
{defautGameField}
{fieldGenerator(9) as Field}
</Grid>
</GameArea>
</>
Expand Down
13 changes: 2 additions & 11 deletions src/components/Game/GameArea.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import React, { FC, ReactNode } from 'react';
import React, { FC } from 'react';
import styled from '@emotion/styled';

export interface GameAreaProps {
/**
* Game items
*/
children: ReactNode;
}

export const GameArea: FC<GameAreaProps> = ({ children }) => (
<Frame>{children}</Frame>
);
export const GameArea: FC = ({ children }) => <Frame>{children}</Frame>;

const Frame = styled.div`
display: flex;
Expand Down
13 changes: 2 additions & 11 deletions src/components/Game/Wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import React, { FC, ReactNode } from 'react';
import React, { FC } from 'react';
import styled from '@emotion/styled';

export interface WrapperProps {
/**
* Game items
*/
children: ReactNode;
}

export const Wrapper: FC<WrapperProps> = ({ children }) => (
<Frame>{children}</Frame>
);
export const Wrapper: FC = ({ children }) => <Frame>{children}</Frame>;

const Frame = styled.div`
position: relative;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Grid/Cell.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Cell component check', () => {
const coords: Coords = [1, 1];

for (let cell = CellState.empty; cell <= CellState.weakFlag; cell++) {
it('Cell renders correctly', () => {
it('Cell renders correct', () => {
const props = {
coords,
onClick: jest.fn(),
Expand All @@ -20,7 +20,7 @@ describe('Cell component check', () => {

expect(asFragment()).toMatchSnapshot();
});
it('Closed Frame renders correctly', () => {
it('Closed Frame renders correct', () => {
const { asFragment } = render(<ClosedFrame mouseDown={true} />);
expect(asFragment()).toMatchSnapshot();
});
Expand Down
Loading

0 comments on commit b0893db

Please sign in to comment.