Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kszkepzes-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KSZK
DevTeam
kszkepzes
old
kszkepzes-frontend
Commits
95c26eae
Commit
95c26eae
authored
6 years ago
by
Chif Gergő
Browse files
Options
Downloads
Patches
Plain Diff
Create responsive menu for mobile devices
parent
e0021455
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/App.js
+5
-6
5 additions, 6 deletions
src/components/App.js
src/components/Header.js
+71
-8
71 additions, 8 deletions
src/components/Header.js
src/components/Main.js
+18
-15
18 additions, 15 deletions
src/components/Main.js
with
94 additions
and
29 deletions
src/components/App.js
+
5
−
6
View file @
95c26eae
...
@@ -5,12 +5,11 @@ import Footer from './Footer';
...
@@ -5,12 +5,11 @@ import Footer from './Footer';
const
App
=
()
=>
(
const
App
=
()
=>
(
<
div
style
=
{{
minHeight
:
'
100%
'
,
position
:
'
relative
'
}}
>
<
div
style
=
{{
minHeight
:
'
100%
'
,
position
:
'
relative
'
}}
>
<
header
id
=
'
header
'
>
<
Header
>
<
Header
/>
<
main
id
=
'
main
'
style
=
{{
minHeight
:
'
100%
'
,
position
:
'
relative
'
}}
>
<
/header
>
<
Main
/>
<
main
id
=
'
main
'
style
=
{{
minHeight
:
'
100%
'
,
position
:
'
relative
'
}}
>
<
/main
>
<
Main
/>
<
/Header
>
<
/main
>
<
footer
id
=
'
footer
'
style
=
{{
position
:
'
absolute
'
,
width
:
'
100%
'
,
bottom
:
'
0
'
}}
>
<
footer
id
=
'
footer
'
style
=
{{
position
:
'
absolute
'
,
width
:
'
100%
'
,
bottom
:
'
0
'
}}
>
<
Footer
/>
<
Footer
/>
<
/footer
>
<
/footer
>
...
...
This diff is collapsed.
Click to expand it.
src/components/Header.js
+
71
−
8
View file @
95c26eae
...
@@ -7,6 +7,9 @@ import {
...
@@ -7,6 +7,9 @@ import {
Segment
,
Segment
,
Visibility
,
Visibility
,
Image
,
Image
,
Responsive
,
Sidebar
,
Icon
}
from
'
semantic-ui-react
'
;
}
from
'
semantic-ui-react
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
getUserData
}
from
'
../actions
'
;
import
{
getUserData
}
from
'
../actions
'
;
...
@@ -35,7 +38,7 @@ const menuItems = [
...
@@ -35,7 +38,7 @@ const menuItems = [
text
:
'
Ütemterv
'
,
text
:
'
Ütemterv
'
,
to
:
'
/schedule
'
,
to
:
'
/schedule
'
,
prefix
:
''
,
prefix
:
''
,
permissionLevel
:
1
,
permissionLevel
:
2
,
},
},
{
{
text
:
'
Statisztika
'
,
text
:
'
Statisztika
'
,
...
@@ -85,7 +88,60 @@ const FixedMenu = ({ user }) => (
...
@@ -85,7 +88,60 @@ const FixedMenu = ({ user }) => (
<
/Menu
>
<
/Menu
>
);
);
class
Header
extends
Component
{
class
MobileContainer
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
sidebarVisible
:
false
,
};
}
componentWillMount
()
{
this
.
props
.
getUserData
();
}
render
()
{
const
visible
=
this
.
state
.
sidebarVisible
;
const
{
children
,
user
}
=
this
.
props
;
return
(
<
Responsive
{...
Responsive
.
onlyMobile
}
>
<
Segment
inverted
textAlign
=
'
center
'
vertical
>
<
Container
>
<
Menu
inverted
secondary
>
<
Menu
.
Item
onClick
=
{
visible
?
this
.
handleHideClick
:
this
.
handleShowClick
}
><
Icon
name
=
'
sidebar
'
/><
/Menu.Item
>
<
/Menu
>
<
/Container
>
<
/Segment
>
<
Sidebar
.
Pushable
>
<
Sidebar
as
=
{
Menu
}
animation
=
'
overlay
'
icon
=
'
labeled
'
inverted
vertical
visible
=
{
visible
}
width
=
'
thin
'
>
{
menuItems
.
map
((
item
,
i
)
=>
(
this
.
props
.
user
.
permission
>=
item
.
permissionLevel
||
(
item
.
permissionLevel
===
0
)
?
<
Menu
.
Item
key
=
{
i
}
as
=
{
Link
}
to
=
{
item
.
to
}
onClick
=
{
this
.
handleSidebarHide
}
>
{
item
.
prefix
}{
item
.
text
}
<
/Menu.Item
>
:
null
))}
<
/Sidebar
>
<
Sidebar
.
Pusher
onClick
=
{
this
.
handleSidebarHide
}
>
{
children
}
<
/Sidebar.Pusher
>
<
/Sidebar.Pushable
>
<
/Responsive>
)
;
}
handleShowClick
=
()
=>
this
.
setState
({
sidebarVisible
:
true
})
handleHideClick
=
()
=>
this
.
setState
({
sidebarVisible
:
false
})
handleSidebarHide
=
()
=>
this
.
setState
({
sidebarVisible
:
false
})
}
class
DesktopContainer
extends
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
this
.
state
=
{
this
.
state
=
{
...
@@ -104,12 +160,11 @@ class Header extends Component {
...
@@ -104,12 +160,11 @@ class Header extends Component {
this
.
setState
({
visible
:
true
});
this
.
setState
({
visible
:
true
});
}
}
render
()
{
render
()
{
const
{
visible
}
=
this
.
state
;
const
{
visible
}
=
this
.
state
.
visible
;
const
{
children
,
user
}
=
this
.
props
;
return
(
return
(
<
div
>
<
Responsive
{...
Responsive
.
onlyComputer
}
>
{
visible
?
<
FixedMenu
user
=
{
this
.
props
.
user
}
/> : null
}
{
visible
?
<
FixedMenu
user
=
{
this
.
props
.
user
}
/> : null
}
<
Visibility
<
Visibility
onBottomPassed
=
{()
=>
this
.
showFixedMenu
()}
onBottomPassed
=
{()
=>
this
.
showFixedMenu
()}
...
@@ -118,7 +173,7 @@ class Header extends Component {
...
@@ -118,7 +173,7 @@ class Header extends Component {
>
>
<
Segment
inverted
textAlign
=
'
center
'
vertical
>
<
Segment
inverted
textAlign
=
'
center
'
vertical
>
<
Container
>
<
Container
>
<
Menu
inverted
secondary
size
=
'
large
'
>
<
Menu
inverted
secondary
stackable
size
=
'
large
'
>
{
menuItems
.
map
((
item
,
i
)
=>
{
menuItems
.
map
((
item
,
i
)
=>
(
this
.
props
.
user
.
permission
>=
item
.
permissionLevel
||
(
this
.
props
.
user
.
permission
>=
item
.
permissionLevel
||
...
@@ -143,11 +198,19 @@ class Header extends Component {
...
@@ -143,11 +198,19 @@ class Header extends Component {
<
/Container
>
<
/Container
>
<
/Segment
>
<
/Segment
>
<
/Visibility
>
<
/Visibility
>
<
/div
>
{
children
}
<
/Responsive
>
);
);
}
}
}
}
const
Header
=
({
children
,
user
,
getUserData
})
=>
(
<
div
>
<
DesktopContainer
user
=
{
user
}
getUserData
=
{
getUserData
}
>
{
children
}
<
/DesktopContainer
>
<
MobileContainer
user
=
{
user
}
getUserData
=
{
getUserData
}
>
{
children
}
<
/MobileContainer
>
<
/div
>
)
const
mapStateToProps
=
({
user
})
=>
({
const
mapStateToProps
=
({
user
})
=>
({
user
,
user
,
});
});
...
...
This diff is collapsed.
Click to expand it.
src/components/Main.js
+
18
−
15
View file @
95c26eae
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
Switch
,
Route
,
Redirect
,
withRouter
}
from
'
react-router-dom
'
;
import
{
Switch
,
Route
,
Redirect
,
withRouter
}
from
'
react-router-dom
'
;
import
{
Sidebar
}
from
'
semantic-ui-react
'
;
import
Home
from
'
./pages/Home
'
;
import
Home
from
'
./pages/Home
'
;
import
Trainers
from
'
./pages/Trainers
'
;
import
Trainers
from
'
./pages/Trainers
'
;
...
@@ -15,21 +16,23 @@ import EventDetail from './pages/EventDetail';
...
@@ -15,21 +16,23 @@ import EventDetail from './pages/EventDetail';
import
ApplicantProfile
from
'
./pages/ApplicantProfile
'
;
import
ApplicantProfile
from
'
./pages/ApplicantProfile
'
;
const
Main
=
()
=>
(
const
Main
=
()
=>
(
<
Switch
>
<
Sidebar
.
Pusher
>
<
Redirect
exact
from
=
'
/
'
to
=
'
/home
'
/>
<
Switch
>
<
Route
exact
path
=
'
/home
'
component
=
{
Home
}
/
>
<
Redirect
exact
from
=
'
/
'
to
=
'
/home
'
/>
<
Route
path
=
'
/news
'
component
=
{
News
}
/
>
<
Route
exact
path
=
'
/home
'
component
=
{
Home
}
/
>
<
Route
path
=
'
/trainers
'
component
=
{
Trainers
}
/
>
<
Route
path
=
'
/news
'
component
=
{
News
}
/
>
<
Route
path
=
'
/schedule
'
component
=
{
Schedule
}
/
>
<
Route
path
=
'
/trainers
'
component
=
{
Trainers
}
/
>
<
Route
path
=
'
/profile
'
component
=
{
withRouter
(
Profile
)}
/
>
<
Route
path
=
'
/schedule
'
component
=
{
Schedule
}
/
>
<
Route
path
=
'
/statistics
'
component
=
{
Statistics
}
/
>
<
Route
path
=
'
/profile
'
component
=
{
withRouter
(
Profile
)}
/
>
<
Route
path
=
'
/groups
'
component
=
{
Groups
}
/
>
<
Route
path
=
'
/statistics
'
component
=
{
Statistics
}
/
>
<
Route
path
=
'
/homework
'
component
=
{
Homework
}
/
>
<
Route
path
=
'
/groups
'
component
=
{
Groups
}
/
>
<
Route
path
=
'
/events/:id
'
component
=
{
EventDetail
}
/
>
<
Route
path
=
'
/homework
'
component
=
{
Homework
}
/
>
<
Route
path
=
'
/applications
'
component
=
{
Applications
}
/
>
<
Route
path
=
'
/events/:id
'
component
=
{
EventDetail
}
/
>
<
Route
path
=
'
/applicant/:id
'
component
=
{
ApplicantProfile
}
/
>
<
Route
path
=
'
/applications
'
component
=
{
Applications
}
/
>
<
Route
component
=
{
NotFound
}
/
>
<
Route
path
=
'
/applicant/:id
'
component
=
{
ApplicantProfile
}
/
>
<
/Switch
>
<
Route
component
=
{
NotFound
}
/
>
<
/Switch
>
<
/Sidebar.Pusher
>
);
);
export
default
Main
;
export
default
Main
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment