From 2b548760358182825893fb03b4b108ec0854cb96 Mon Sep 17 00:00:00 2001 From: Oleksandr Rad Date: Sat, 7 Dec 2024 17:37:10 +0200 Subject: [PATCH] add solution --- README.md | 3 ++- src/App.jsx | 19 +++++++++++++------ src/components/Person/Person.jsx | 16 +++++++++++++++- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 009a2977c..d989b4a8b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ and use it 3 times inside the `App` instead of static markup. - keep the same classNames in `Person.jsx` as in `App.jsx` (`Person`, `Person__name`, `Person__age`, `Person__partner`). ## Instructions + - Install Prettier Extention and use this [VSCode settings](https://mate-academy.github.io/fe-program/tools/vscode/settings.json) to enable format on save. - Implement a solution following the [React task guideline](https://github.com/mate-academy/react_task-guideline#react-tasks-guideline). - Open one more terminal and run tests with `npm test` to ensure your solution is correct. -- Replace `` with your Github username in the [DEMO LINK](https://.github.io/react_person/) and add it to the PR description. +- Replace `` with your Github username in the [DEMO LINK](https://clavigo.github.io/react_person/) and add it to the PR description. diff --git a/src/App.jsx b/src/App.jsx index dcf8509c8..ac252f83f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,5 +1,6 @@ import React from 'react'; import './App.scss'; +import { Person } from './components/Person/Person'; export const misha = { name: 'Misha', @@ -25,21 +26,27 @@ export const alex = { export const App = () => (
-
+ {/*

My name is Misha

I am 37

Natasha is my wife

-
+
*/} -
+ + + {/*

My name is Olya

Maksym is my husband

-
+
*/} + + -
+ {/*

My name is Alex

I am 25

I am not married

-
+
*/} + +
); diff --git a/src/components/Person/Person.jsx b/src/components/Person/Person.jsx index eccf156a3..a746be065 100644 --- a/src/components/Person/Person.jsx +++ b/src/components/Person/Person.jsx @@ -1 +1,15 @@ -// export const Person = ({ person }) => (); +export const Person = ({ person }) => { + const { name, age, isMarried, sex, partnerName } = person; + + return ( +
+

My name is {name}

+ {age !== undefined &&

I am {age}

} +

+ {isMarried + ? `${partnerName} is my ${sex === 'f' ? 'husband' : 'wife'}` + : 'I am not married'} +

+
+ ); +};