Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Clutch
Commits
5279eb32
Commit
5279eb32
authored
3 years ago
by
Derek Schaller
Browse files
Options
Download
Email Patches
Plain Diff
frontend: make dash project selector responsive
parent
16b37a1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/workflows/projectSelector/src/dash.tsx
+35
-5
frontend/workflows/projectSelector/src/dash.tsx
with
35 additions
and
5 deletions
+35
-5
frontend/workflows/projectSelector/src/dash.tsx
+
35
-
5
View file @
5279eb32
import
*
as
React
from
"
react
"
;
import
{
Box
}
from
"
@material-ui/core
"
;
import
styled
from
"
@emotion/styled
"
;
import
{
Box
,
Fab
,
useMediaQuery
}
from
"
@material-ui/core
"
;
import
KeyboardArrowDownIcon
from
"
@material-ui/icons/KeyboardArrowDown
"
;
import
KeyboardArrowUpIcon
from
"
@material-ui/icons/KeyboardArrowUp
"
;
import
_
from
"
lodash
"
;
import
{
DashDispatchContext
,
DashStateContext
}
from
"
./dash-hooks
"
;
...
...
@@ -11,6 +14,13 @@ const initialState = {
projectData
:
{},
};
const
StyledFab
=
styled
(
Fab
)({
position
:
"
fixed
"
,
left
:
"
85px
"
,
bottom
:
"
50vh
"
,
transform
:
"
rotate(270deg)
"
,
});
const
dashReducer
=
(
state
:
DashState
,
action
:
DashAction
):
DashState
=>
{
switch
(
action
.
type
)
{
case
"
UPDATE_SELECTED
"
:
{
...
...
@@ -26,15 +36,35 @@ const dashReducer = (state: DashState, action: DashAction): DashState => {
const
Dash
=
({
children
})
=>
{
const
[
state
,
dispatch
]
=
React
.
useReducer
(
dashReducer
,
initialState
);
const
compress
=
useMediaQuery
((
theme
:
any
)
=>
theme
.
breakpoints
.
down
(
"
md
"
));
const
[
showSelector
,
setShowSelector
]
=
React
.
useState
<
boolean
>
(
false
);
const
Icon
=
showSelector
?
KeyboardArrowUpIcon
:
KeyboardArrowDownIcon
;
return
(
<
Box
display
=
"flex"
flex
=
{
1
}
>
<
DashDispatchContext
.
Provider
value
=
{
dispatch
}
>
<
DashStateContext
.
Provider
value
=
{
state
}
>
<
ProjectSelector
/>
<
Box
display
=
"flex"
flex
=
{
1
}
>
{
children
}
</
Box
>
{
compress
?
(
<>
<
StyledFab
onClick
=
{
()
=>
setShowSelector
(
s
=>
!
s
)
}
size
=
"small"
>
<
Icon
/>
</
StyledFab
>
{
showSelector
?
(
<
ProjectSelector
/>
)
:
(
<
Box
display
=
"flex"
flex
=
{
1
}
>
{
children
}
</
Box
>
)
}
</>
)
:
(
<>
<
ProjectSelector
/>
<
Box
display
=
"flex"
flex
=
{
1
}
>
{
children
}
</
Box
>
</>
)
}
</
DashStateContext
.
Provider
>
</
DashDispatchContext
.
Provider
>
</
Box
>
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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