Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint1/step1 #1

Merged
merged 8 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

todo.txt
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# Космическая бургерная

## Начальный коммит
Стартовый коммит проекта с помощью [CRA](https://create-react-app.dev/docs/getting-started) с добавленными UI компонентами от [Яндекс](https://github.com/Yandex-Practicum/react-developer-burger-ui-components).
Кода пока никакого не написано, это начальный коммит.

## Спринт1
### Шаг1
Создали папку [src/components](src/components/), поместили туда app.js и 3 компонента: AppHeader, BurgerContructor и BurgerIngredients.
Данные с бургерами поместили в файл [src/utils/data.js](src/utils/data.js).
Делаем начальную верстку главной страницы приложения.
```
git checkout sprint1/step1
```

Обсуждение [замечаний](https://github.com/miptleha/react-burger/pull/1) от ревьювера.
Замечания были исправлены, было предложено продолжить оставшуюся верстку в sprint1/step2
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10",
"@ya.praktikum/react-developer-burger-ui-components": "^1.14.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
Expand Down
Binary file modified public/favicon.ico
Binary file not shown.
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Космическая бургерная</title>
</head>
<body>
<body class="body">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
Expand Down
38 changes: 0 additions & 38 deletions src/App.css

This file was deleted.

9 changes: 0 additions & 9 deletions src/App.test.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions src/App.tsx

This file was deleted.

28 changes: 28 additions & 0 deletions src/components/app-header/app-header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import styles from './app-header.module.css';
import { Logo, BurgerIcon, ListIcon, ProfileIcon } from '@ya.praktikum/react-developer-burger-ui-components';
import IconLink from '../icon-link/icon-link';

function AppHeader() {
return (
<header className={`${styles.header} pt-4 pb-4`}>
<div className={styles.container}>
<nav className={styles.left}>
<ul className={styles.list}>
<li><IconLink href="/" icon={BurgerIcon} isActive>Конструктор</IconLink></li>
<li><IconLink href="/" icon={ListIcon}>Лента заказов</IconLink></li>
</ul>
</nav>

<div className={styles.center}>
<Logo />
</div>

<div className={styles.right}>
<IconLink href="/" icon={ProfileIcon}>Личный кабинет</IconLink>
</div>
</div>
</header>
);
}

export default AppHeader;
32 changes: 32 additions & 0 deletions src/components/app-header/app-header.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.header {
background: var(--background);
}

.container {
display: flex;
width: var(--width-outer);
margin: 0 auto;
}

.center {
flex: 0 0 content;
}

.left {
flex: 1 0 100px;
display: flex;
justify-content: flex-start;
}

.right {
flex: 1 0 100px;
display: flex;
justify-content: flex-end;
}

.list {
margin: 0;
padding: 0;
display: flex;
list-style: none;
}
21 changes: 21 additions & 0 deletions src/components/app/app.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import styles from './app.module.css';
import { data } from '../../utils/data';
import AppHeader from '../app-header/app-header';
import BurgerConstructor from '../burger-constructor/burger-constructor';
import BurgerIngredients from '../burger-ingredients/burger-ingredients';

function App() {
return (
<>
<AppHeader/>
<main className={styles.main}>
<div className={styles.inner}>
<BurgerIngredients data={data}/>
<BurgerConstructor data={data}/>
</div>
</main>
</>
);
}

export default App;
12 changes: 12 additions & 0 deletions src/components/app/app.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.main {
margin: 0 auto;
width: var(--width-outer);
}

.inner {
margin-right: 20px;
margin-left: 20px;
display: flex;
flex-direction: row;
justify-content: space-between;
}
61 changes: 61 additions & 0 deletions src/components/burger-constructor/burger-constructor.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react';
import PropTypes from 'prop-types';
import styles from './burger-constructor.module.css';
import { dataPropTypes } from '../../utils/dataPropTypes';
import { BUN } from '../../utils/dataNames';
import { Button, ConstructorElement, CurrencyIcon, DragIcon } from '@ya.praktikum/react-developer-burger-ui-components';


function BurgerConstructor({ data }) {
const list = React.useMemo(() => data.filter(item => item.type !== BUN), [data]);
const bun = React.useMemo(() => data.find(item => item.type === BUN), [data]);
const sum = React.useMemo(() => bun.price * 2 + list.reduce((sum, item) => sum += item.price, 0), [list, bun]);

return (
<section className={styles.section}>
<div className={`${styles.burger} mt-25 ml-4`}>
<ConstructorElement
type="top"
isLocked={true}
text={`${bun.name} (верх)`}
price={bun.price}
thumbnail={bun.image}
extraClass={`${styles.ingredient} ml-8`}
/>
<ul className={`${styles.scroll} mt-4 mb-4`}>
{list.map((item, index) => (
<li className={`${styles['list-item']} mt-4`} key={index}>
<span className={styles.draggable}><DragIcon type="primary" /></span>
<ConstructorElement
text={item.name}
price={item.price}
thumbnail={item.image}
extraClass={`${styles.ingredient} ml-2`}
/>
</li>
))}
</ul>
<ConstructorElement
type="bottom"
isLocked={true}
text={`${bun.name} (низ)`}
price={bun.price}
thumbnail={bun.image}
extraClass={`${styles.ingredient} ml-8`}
/>
</div>

<div className={`${styles.total} mr-4 mt-10`}>
<div className="text text_type_digits-medium mr-2 mb-1">{sum}</div>
<div className={`${styles['total-icon']} mr-10`}><CurrencyIcon type="primary" /></div>
<Button htmlType="button" type="primary">Оформить заказ</Button>
</div>
</section>
);
}

BurgerConstructor.propTypes = {
data: PropTypes.arrayOf(dataPropTypes.isRequired).isRequired
}

export default BurgerConstructor;
83 changes: 83 additions & 0 deletions src/components/burger-constructor/burger-constructor.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
.section {
flex: 0 0 600px;
}

.scroll {
overflow-y: auto;
max-height: 464px;
scrollbar-width: thin;
scrollbar-color: #8585AD #2F2F37;
padding: 0;
list-style: none;
}

.scroll::-webkit-scrollbar {
background-color: #2F2F37;
width: 8px;
}

.scroll::-webkit-scrollbar-thumb {
background-color: #8585AD;
}

.scroll > :first-child {
margin-top: 0;
}

@media (max-height: 950px) {
.scroll {
max-height: 370px;
}
}

@media (max-height: 850px) {
.scroll {
max-height: 270px;
}
}

@media (max-height: 750px) {
.scroll {
max-height: 175px;
}
}

.burger {
padding: 0;
}

@media (max-height: 650px) {
.burger {
margin-top: 30px;
}

.total {
margin-top: 16px;
}
}

.list-item {
display: flex;
align-items: center;
}

.ingredient {
background: var(--background);
}

.draggable {
cursor: grabbing;
}

.total {
display: flex;
align-items: center;
justify-content: flex-end;
}

.total-icon {
transform: scale(1.5);
transform-origin: top left;
width: 36px;
height: 32px;
}
24 changes: 24 additions & 0 deletions src/components/burger-ingredients-item/burger-ingredients-item.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import PropTypes from 'prop-types';
import styles from './burger-ingredients-item.module.css';
import { CurrencyIcon } from '@ya.praktikum/react-developer-burger-ui-components';

function BurgerIngredientItem({ img, title, price }) {
return (
<li className={`${styles.card} mt-6 mb-8 ml-3 mr-2`}>
<img className={`${styles['card-image']} ml-4 mr-4 mb-1`} src={img} alt={title} />
<div className={`${styles['card-price']} mb-1`}>
<span className="text text_type_digits-default mr-2">{price}</span>
<CurrencyIcon type="primary" />
</div>
<div className={`${styles['card-title']} text text_type_main-default`}>{title}</div>
</li>
);
}

BurgerIngredientItem.propTypes = {
img: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
price: PropTypes.number.isRequired
}

export default BurgerIngredientItem;
Loading