Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
exam_7
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zarina
exam_7
Commits
3c713bec
Commit
3c713bec
authored
Mar 28, 2020
by
zarina
🌊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#6
, реализована возможность удаления элемента из корзины + выведены иконки (
#2
)
parent
e2db9d87
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
68 additions
and
25 deletions
+68
-25
drink_icon.jpg
public/img/drink_icon.jpg
+0
-0
food_icon.jpg
public/img/food_icon.jpg
+0
-0
Basket.css
src/components/Basket/Basket.css
+1
-1
Basket.js
src/components/Basket/Basket.js
+3
-2
BaskeItem.js
src/components/Basket/BasketItem/BaskeItem.js
+2
-0
BasketItem.css
src/components/Basket/BasketItem/BasketItem.css
+14
-0
TotalPrice.css
src/components/Basket/TotalPrice/TotalPrice.css
+3
-1
Menu.css
src/components/Menu/Menu.css
+2
-3
Menu.js
src/components/Menu/Menu.js
+5
-7
MenuItem.css
src/components/Menu/MenuItem/MenuItem.css
+12
-3
MenuItem.js
src/components/Menu/MenuItem/MenuItem.js
+4
-3
App.js
src/containers/App.js
+22
-5
No files found.
public/img/drink_icon.jpg
0 → 100644
View file @
3c713bec
6.73 KB
public/img/food_icon.jpg
0 → 100644
View file @
3c713bec
13.6 KB
src/components/Basket/Basket.css
View file @
3c713bec
.Basket
{
width
:
30%
;
border
:
3px
solid
silver
;
border
:
3px
solid
darkslategrey
;
;
min-height
:
400px
;
border-radius
:
10px
0
0
10px
;
padding-top
:
20px
;
...
...
src/components/Basket/Basket.js
View file @
3c713bec
...
...
@@ -10,10 +10,11 @@ const Basket = props => {
let
createBasket
=
()
=>
{
return
basketElements
.
map
((
elem
,
i
)
=>
{
return
<
BasketItem
key
=
{
'BasketItem-'
+
{
elem
}
+
i
}
key
=
{
'BasketItem-'
+
elem
+
i
}
qty
=
{
props
.
basket
[
elem
]}
price
=
{
props
.
menuList
[
elem
].
price
}
name
=
{
elem
}
/>
;
name
=
{
elem
}
removeElement
=
{()
=>
props
.
removeElement
(
elem
)}
/>
;
});
}
return
(
...
...
src/components/Basket/BasketItem/BaskeItem.js
View file @
3c713bec
...
...
@@ -8,7 +8,9 @@ const BasketItem = props => {
<
div
>
<
span
>
{
props
.
price
}
KZT
<
/span
>
<
span
>
<
b
>
x
{
props
.
qty
}
<
/b></
span
>
<
button
onClick
=
{
props
.
removeElement
}
>
x
<
/button
>
<
/div
>
<
/div
>
);
};
...
...
src/components/Basket/BasketItem/BasketItem.css
View file @
3c713bec
...
...
@@ -3,5 +3,19 @@
justify-content
:
space-between
;
padding
:
20px
;
align-items
:
center
;
}
.BasketItem
button
{
padding
:
6px
;
line-height
:
10px
;
font-size
:
20px
;
color
:
red
;
background
:
#eee
;
border
:
1px
solid
darkslategrey
;
;
border-radius
:
5px
;
margin-left
:
10px
;
}
.BasketItem
button
:focus
{
outline
:
none
;
}
\ No newline at end of file
src/components/Basket/TotalPrice/TotalPrice.css
View file @
3c713bec
.TotalPrice
{
border-top
:
1px
solid
black
;
padding-top
:
10px
;
margin-top
:
10px
;
margin
:
10px
0
;
font-weight
:
bold
;
text-transform
:
uppercase
;
}
\ No newline at end of file
src/components/Menu/Menu.css
View file @
3c713bec
.Menu
{
width
:
70%
;
border
:
3px
solid
silver
;
border
:
3px
solid
darkslategrey
;
border-radius
:
0
10px
10px
0
;
padding
:
10px
;
padding
:
10px
;
}
}
\ No newline at end of file
src/components/Menu/Menu.js
View file @
3c713bec
...
...
@@ -7,16 +7,14 @@ const Menu = props => {
let
createMenu
=
()
=>
{
let
menuKeys
=
Object
.
keys
(
props
.
menuList
);
return
menuKeys
.
map
(
key
=>
{
let
className
=
[
'MenuItem'
]
;
let
imgUrl
=
'./img/drink_icon.jpg'
;
if
(
props
.
menuList
[
key
].
type
===
'drink'
)
{
className
.
push
(
'MenuItem_drink'
)
}
else
{
className
.
push
(
'MenuItem_eat'
)
}
if
(
props
.
menuList
[
key
].
type
===
'food'
)
{
imgUrl
=
'./img/food_icon.jpg'
;
}
return
<
MenuItem
addElem
=
{()
=>
(
props
.
addElement
(
key
))}
name
=
{
key
}
price
=
{
props
.
menuList
[
key
].
price
}
key
=
{
'MenuItem-'
+
key
}
class
=
{
className
.
join
(
' '
)
}
/
>
key
=
{
'MenuItem-'
+
key
}
img
=
{
imgUrl
}
/
>
});
};
...
...
src/components/Menu/MenuItem/MenuItem.css
View file @
3c713bec
.MenuItem
{
margin
:
10px
;
background
:
#ccc
;
height
:
auto
;
width
:
35%
;
border
:
3px
solid
#eee
;
width
:
320px
;
border
:
5px
solid
darkslategrey
;
border-radius
:
10px
;
padding
:
20px
0
20px
70px
;
display
:
inline-block
;
cursor
:
pointer
;
position
:
relative
;
}
.MenuItem
img
{
position
:
absolute
;
top
:
50%
;
transform
:
translateY
(
-50%
);
left
:
50px
;
}
\ No newline at end of file
src/components/Menu/MenuItem/MenuItem.js
View file @
3c713bec
...
...
@@ -2,9 +2,10 @@ import React from "react";
import
'./MenuItem.css'
const
MenuItem
=
props
=>
{
return
(
<
div
onClick
=
{
props
.
addElem
}
className
=
{
props
.
class
}
>
<
h3
className
=
'MenuItem_name'
>
{
props
.
name
}
<
/h3
>
<
span
className
=
'MenuItem_price'
>
Price
:
{
props
.
price
}
<
/span
>
<
div
className
=
'MenuItem'
onClick
=
{
props
.
addElem
}
>
<
img
src
=
{
props
.
img
}
width
=
'50'
height
=
'50'
alt
=
'element_icon'
/>
<
h3
>
{
props
.
name
}
<
/h3
>
<
span
>
Price
:
{
props
.
price
}
<
/span
>
<
/div
>
);
};
...
...
src/containers/App.js
View file @
3c713bec
...
...
@@ -8,15 +8,15 @@ class App extends Component {
menu
:
{
Hamburger
:
{
price
:
200
,
type
:
'
eat
'
type
:
'
food
'
},
Cheeseburger
:
{
price
:
300
,
type
:
'
eat
'
type
:
'
food
'
},
Fries
:
{
price
:
150
,
type
:
'
eat
'
type
:
'
food
'
},
Coffee
:
{
price
:
70
,
...
...
@@ -38,7 +38,7 @@ class App extends Component {
addElement
=
(
name
)
=>
{
let
basket
=
{...
this
.
state
.
basket
};
if
(
!
basket
[
name
]){
if
(
!
basket
[
name
])
{
basket
[
name
]
=
1
}
else
{
basket
[
name
]
++
...
...
@@ -49,10 +49,27 @@ class App extends Component {
};
removeElement
=
(
name
)
=>
{
let
basket
=
{...
this
.
state
.
basket
};
if
(
basket
[
name
]
===
1
)
{
delete
basket
[
name
]
}
else
{
basket
[
name
]
--
}
let
totalPrice
=
this
.
state
.
totalPrice
-
this
.
state
.
menu
[
name
].
price
;
this
.
setState
({
totalPrice
,
basket
})
};
render
()
{
return
(
<
div
className
=
'App'
>
<
Basket
menuList
=
{
this
.
state
.
menu
}
totalPrice
=
{
this
.
state
.
totalPrice
}
basket
=
{
this
.
state
.
basket
}
/
>
<
Basket
menuList
=
{
this
.
state
.
menu
}
totalPrice
=
{
this
.
state
.
totalPrice
}
basket
=
{
this
.
state
.
basket
}
removeElement
=
{
this
.
removeElement
}
/
>
<
Menu
menuList
=
{
this
.
state
.
menu
}
addElement
=
{
this
.
addElement
}
/
>
<
/div
>
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment