diff --git a/package-lock.json b/package-lock.json index e99a306fb..cbac0f588 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ }, "devDependencies": { "@cypress/react18": "^2.0.1", - "@mate-academy/scripts": "^1.8.5", + "@mate-academy/scripts": "^2.1.3", "@mate-academy/students-ts-config": "*", "@mate-academy/stylelint-config": "*", "@types/node": "^20.14.10", @@ -1170,10 +1170,11 @@ } }, "node_modules/@mate-academy/scripts": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/@mate-academy/scripts/-/scripts-1.8.5.tgz", - "integrity": "sha512-mHRY2FkuoYCf5U0ahIukkaRo5LSZsxrTSgMJheFoyf3VXsTvfM9OfWcZIDIDB521kdPrScHHnRp+JRNjCfUO5A==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@mate-academy/scripts/-/scripts-2.1.3.tgz", + "integrity": "sha512-a07wHTj/1QUK2Aac5zHad+sGw4rIvcNl5lJmJpAD7OxeSbnCdyI6RXUHwXhjF5MaVo9YHrJ0xVahyERS2IIyBQ==", "dev": true, + "license": "MIT", "dependencies": { "@octokit/rest": "^17.11.2", "@types/get-port": "^4.2.0", diff --git a/package.json b/package.json index db76807cc..aba201d75 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ }, "devDependencies": { "@cypress/react18": "^2.0.1", - "@mate-academy/scripts": "^1.8.5", + "@mate-academy/scripts": "^2.1.3", "@mate-academy/students-ts-config": "*", "@mate-academy/stylelint-config": "*", "@types/node": "^20.14.10", diff --git a/src/App.tsx b/src/App.tsx index 168716b91..abd084b19 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,6 +2,12 @@ import React from 'react'; import 'bulma/css/bulma.css'; import './App.scss'; +type State = { + selectedGood: string; +}; + +type Props = {}; + export const goods = [ 'Dumplings', 'Carrot', @@ -15,58 +21,87 @@ export const goods = [ 'Garlic', ]; -export const App: React.FC = () => ( -
-

No goods selected

- -

- Jam is selected - {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */} -

+export class App extends React.Component { + state: State = { + selectedGood: 'Jam', + }; - - - - + handelClick = (good: string) => { + if (good === this.state.selectedGood) { + this.clearSelection(); + } else { + this.selectGood(good); + } + } - - + clearSelection = () => { + this.setState({ selectedGood: '' }); + }; - - + selectGood = (good: string) => { + this.setState({ selectedGood: good }); + }; - - + render() { + return ( +
+

+ {this.state.selectedGood !== '' ? ( + <> + {this.state.selectedGood} is selected +

-
- +
- - - Dumplings -
- - - Jam -
- -
+ + {goods.map(good => { + return ( + + - - - -
+ + - Garlic -
-
-); + + {good} + + + ); + })} + + + + ); + } +}