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
{
.Basket
{
width
:
30%
;
width
:
30%
;
border
:
3px
solid
silver
;
border
:
3px
solid
darkslategrey
;
;
min-height
:
400px
;
min-height
:
400px
;
border-radius
:
10px
0
0
10px
;
border-radius
:
10px
0
0
10px
;
padding-top
:
20px
;
padding-top
:
20px
;
...
...
src/components/Basket/Basket.js
View file @
3c713bec
...
@@ -10,10 +10,11 @@ const Basket = props => {
...
@@ -10,10 +10,11 @@ const Basket = props => {
let
createBasket
=
()
=>
{
let
createBasket
=
()
=>
{
return
basketElements
.
map
((
elem
,
i
)
=>
{
return
basketElements
.
map
((
elem
,
i
)
=>
{
return
<
BasketItem
return
<
BasketItem
key
=
{
'BasketItem-'
+
{
elem
}
+
i
}
key
=
{
'BasketItem-'
+
elem
+
i
}
qty
=
{
props
.
basket
[
elem
]}
qty
=
{
props
.
basket
[
elem
]}
price
=
{
props
.
menuList
[
elem
].
price
}
price
=
{
props
.
menuList
[
elem
].
price
}
name
=
{
elem
}
/>
;
name
=
{
elem
}
removeElement
=
{()
=>
props
.
removeElement
(
elem
)}
/>
;
});
});
}
}
return
(
return
(
...
...
src/components/Basket/BasketItem/BaskeItem.js
View file @
3c713bec
...
@@ -8,7 +8,9 @@ const BasketItem = props => {
...
@@ -8,7 +8,9 @@ const BasketItem = props => {
<
div
>
<
div
>
<
span
>
{
props
.
price
}
KZT
<
/span
>
<
span
>
{
props
.
price
}
KZT
<
/span
>
<
span
>
<
b
>
x
{
props
.
qty
}
<
/b></
span
>
<
span
>
<
b
>
x
{
props
.
qty
}
<
/b></
span
>
<
button
onClick
=
{
props
.
removeElement
}
>
x
<
/button
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
);
);
};
};
...
...
src/components/Basket/BasketItem/BasketItem.css
View file @
3c713bec
...
@@ -3,5 +3,19 @@
...
@@ -3,5 +3,19 @@
justify-content
:
space-between
;
justify-content
:
space-between
;
padding
:
20px
;
padding
:
20px
;
align-items
:
center
;
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
{
.TotalPrice
{
border-top
:
1px
solid
black
;
border-top
:
1px
solid
black
;
padding-top
:
10px
;
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
{
.Menu
{
width
:
70%
;
width
:
70%
;
border
:
3px
solid
silver
;
border
:
3px
solid
darkslategrey
;
border-radius
:
0
10px
10px
0
;
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 => {
...
@@ -7,16 +7,14 @@ const Menu = props => {
let
createMenu
=
()
=>
{
let
createMenu
=
()
=>
{
let
menuKeys
=
Object
.
keys
(
props
.
menuList
);
let
menuKeys
=
Object
.
keys
(
props
.
menuList
);
return
menuKeys
.
map
(
key
=>
{
return
menuKeys
.
map
(
key
=>
{
let
className
=
[
'MenuItem'
]
;
let
imgUrl
=
'./img/drink_icon.jpg'
;
if
(
props
.
menuList
[
key
].
type
===
'drink'
)
{
if
(
props
.
menuList
[
key
].
type
===
'food'
)
{
className
.
push
(
'MenuItem_drink'
)
imgUrl
=
'./img/food_icon.jpg'
;
}
else
{
}
className
.
push
(
'MenuItem_eat'
)
}
return
<
MenuItem
addElem
=
{()
=>
(
props
.
addElement
(
key
))}
name
=
{
key
}
price
=
{
props
.
menuList
[
key
].
price
}
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
{
.MenuItem
{
margin
:
10px
;
margin
:
10px
;
background
:
#ccc
;
height
:
auto
;
height
:
auto
;
width
:
35%
;
width
:
320px
;
border
:
3px
solid
#eee
;
border
:
5px
solid
darkslategrey
;
border-radius
:
10px
;
padding
:
20px
0
20px
70px
;
padding
:
20px
0
20px
70px
;
display
:
inline-block
;
display
:
inline-block
;
cursor
:
pointer
;
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";
...
@@ -2,9 +2,10 @@ import React from "react";
import
'./MenuItem.css'
import
'./MenuItem.css'
const
MenuItem
=
props
=>
{
const
MenuItem
=
props
=>
{
return
(
return
(
<
div
onClick
=
{
props
.
addElem
}
className
=
{
props
.
class
}
>
<
div
className
=
'MenuItem'
onClick
=
{
props
.
addElem
}
>
<
h3
className
=
'MenuItem_name'
>
{
props
.
name
}
<
/h3
>
<
img
src
=
{
props
.
img
}
width
=
'50'
height
=
'50'
alt
=
'element_icon'
/>
<
span
className
=
'MenuItem_price'
>
Price
:
{
props
.
price
}
<
/span
>
<
h3
>
{
props
.
name
}
<
/h3
>
<
span
>
Price
:
{
props
.
price
}
<
/span
>
<
/div
>
<
/div
>
);
);
};
};
...
...
src/containers/App.js
View file @
3c713bec
...
@@ -8,15 +8,15 @@ class App extends Component {
...
@@ -8,15 +8,15 @@ class App extends Component {
menu
:
{
menu
:
{
Hamburger
:
{
Hamburger
:
{
price
:
200
,
price
:
200
,
type
:
'
eat
'
type
:
'
food
'
},
},
Cheeseburger
:
{
Cheeseburger
:
{
price
:
300
,
price
:
300
,
type
:
'
eat
'
type
:
'
food
'
},
},
Fries
:
{
Fries
:
{
price
:
150
,
price
:
150
,
type
:
'
eat
'
type
:
'
food
'
},
},
Coffee
:
{
Coffee
:
{
price
:
70
,
price
:
70
,
...
@@ -38,7 +38,7 @@ class App extends Component {
...
@@ -38,7 +38,7 @@ class App extends Component {
addElement
=
(
name
)
=>
{
addElement
=
(
name
)
=>
{
let
basket
=
{...
this
.
state
.
basket
};
let
basket
=
{...
this
.
state
.
basket
};
if
(
!
basket
[
name
]){
if
(
!
basket
[
name
])
{
basket
[
name
]
=
1
basket
[
name
]
=
1
}
else
{
}
else
{
basket
[
name
]
++
basket
[
name
]
++
...
@@ -49,10 +49,27 @@ class App extends Component {
...
@@ -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
()
{
render
()
{
return
(
return
(
<
div
className
=
'App'
>
<
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
}
/
>
<
Menu
menuList
=
{
this
.
state
.
menu
}
addElement
=
{
this
.
addElement
}
/
>
<
/div
>
<
/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