NavigationMini.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. Copyright (C) 2017 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. import React from 'react'
  15. import { observer } from 'mobx-react'
  16. import styled, { css } from 'styled-components'
  17. import Navigation from '@src/components/modules/NavigationModule/Navigation'
  18. import { ThemeProps } from '@src/components/Theme'
  19. import menuImage from './images/menu'
  20. const Wrapper = styled.div<any>`
  21. margin-right: 38px;
  22. margin-left: 32px;
  23. `
  24. const Close = css`
  25. transform: rotate(0deg) translateX(0) translateY(0);
  26. `
  27. const Stub = styled.div<any>`
  28. width: 20px;
  29. `
  30. const MenuImage = styled.div<any>`
  31. cursor: pointer;
  32. width: 20px;
  33. height: 20px;
  34. ${props => (props.open ? css`position: fixed;` : '')}
  35. top: 23px;
  36. z-index: 99;
  37. #top {
  38. ${props => (props.open ? css`transform: rotate(45deg) translateX(0.5px) translateY(-4.5px);` : Close)}
  39. transition: all ${ThemeProps.animations.swift};
  40. }
  41. #bottom {
  42. ${props => (props.open ? css`transform: rotate(-45deg) translateX(-6.5px) translateY(1.5px);` : Close)}
  43. transition: all ${ThemeProps.animations.swift};
  44. }
  45. `
  46. const NavigationStyled = styled(Navigation)<any>`
  47. position: fixed;
  48. left: ${props => (props.open ? 0 : -80)}px;
  49. top: 0;
  50. padding-top: 24px;
  51. transition: left ${ThemeProps.animations.swift};
  52. z-index: 9;
  53. `
  54. export const TEST_ID = 'navigationMini'
  55. type State = {
  56. open: boolean,
  57. }
  58. @observer
  59. class NavigationMini extends React.Component<{}, State> {
  60. state = {
  61. open: false,
  62. }
  63. handleMenuToggleClick() {
  64. this.setState(prevState => ({ open: !prevState.open }))
  65. }
  66. render() {
  67. return (
  68. <Wrapper>
  69. <MenuImage
  70. open={this.state.open}
  71. onClick={() => { this.handleMenuToggleClick() }}
  72. dangerouslySetInnerHTML={{ __html: menuImage() }}
  73. />
  74. {this.state.open ? <Stub /> : null}
  75. <NavigationStyled
  76. open={this.state.open}
  77. collapsed
  78. hideLogos
  79. />
  80. </Wrapper>
  81. )
  82. }
  83. }
  84. export default NavigationMini