From 8c827511bc15d4a1a5ca95aad0d9c86c97c7a31c Mon Sep 17 00:00:00 2001 From: Nayara Souza Date: Mon, 2 Apr 2018 00:11:11 -0300 Subject: [PATCH] Adiciona menu colapsado para telas menores que 1080 --- public/index.html | 1 + src/components/menu/Menu.js | 79 ++++++++++++++++--- .../menu/__snapshots__/Menu.test.js.snap | 38 +++------ src/components/menu/menu.css | 42 +++++++++- 4 files changed, 123 insertions(+), 37 deletions(-) diff --git a/public/index.html b/public/index.html index ec6e5635..36b14d72 100644 --- a/public/index.html +++ b/public/index.html @@ -8,6 +8,7 @@ manifest.json provides metadata used when your web app is added to the homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ --> + diff --git a/src/components/menu/Menu.js b/src/components/menu/Menu.js index 3f1e6e3f..2572097f 100644 --- a/src/components/menu/Menu.js +++ b/src/components/menu/Menu.js @@ -4,23 +4,80 @@ import logo from '../../imagens/logo.svg'; import './menu.css'; export default class Menu extends Component { - componentWillMount() { + constructor(props) { + super(props); + this.state = { + windowWidth: window.innerWidth, + mobileNavVisible: false + }; + } + + componentDidMount() { + window.addEventListener('resize', screenSize => this.handleResize(screenSize)); + } + + componentWillUnmount() { + window.removeEventListener('resize', screenSize => this.handleResize(screenSize)); + } + + handleResize() { + this.setState({ windowWidth: window.innerWidth }); + } + + handleNavClick() { + if (!this.state.mobileNavVisible) { + this.setState({ mobileNavVisible: true }); + } else { + this.setState({ mobileNavVisible: false }); + } + } + + navigationLinks() { + return [ + + ]; + } + + renderMobileNav() { + if (this.state.mobileNavVisible) { + return this.navigationLinks(); + } + return null; + } + + renderNavigation() { + if (this.state.windowWidth <= 1080) { + return [ +
+ this.handleNavClick(elementClicked)} + > + menu + {this.renderMobileNav()} +
+ ]; + } + return [ +
+ {this.navigationLinks()} +
+ ]; } render() { return ( -
+
- - Logo Verdade Seja Dita - -
-
- SOBRE - E DEPOIS DA DENÚNCIA? - O COLETIVO ENEGRECER - DENUNCIAR + Logo Verdade Seja Dita
+ {this.renderNavigation()}
); } diff --git a/src/components/menu/__snapshots__/Menu.test.js.snap b/src/components/menu/__snapshots__/Menu.test.js.snap index 1e66dbd9..159e2a8e 100644 --- a/src/components/menu/__snapshots__/Menu.test.js.snap +++ b/src/components/menu/__snapshots__/Menu.test.js.snap @@ -2,7 +2,7 @@ exports[`Menu deve construir a pagina corretamente 1`] = `
- - SOBRE - - - E DEPOIS DA DENÚNCIA? - - - O COLETIVO ENEGRECER - - - DENUNCIAR - + + menu + +
`; diff --git a/src/components/menu/menu.css b/src/components/menu/menu.css index 0dfb5727..17496ef4 100644 --- a/src/components/menu/menu.css +++ b/src/components/menu/menu.css @@ -14,11 +14,15 @@ .links { width: 59%; +} + +.links > ul{ + display: flex; justify-content: space-between; } -.links a { +.links ul > li > a { padding:5px; font-family: Roboto; font-size: 14px; @@ -30,3 +34,39 @@ text-align: center; color: #c3c3c3; } + +.mobile_nav { + padding-left: 20%; + z-index: 999; +} + +.mobile_nav > ul { + position: absolute; + width: auto; + margin-top: 2%; + margin-left: 10%; +} + +.mobile_nav ul > li > a { + background-color: #eee; + font-family: Roboto; + font-size: 14px; + font-weight: 500; + font-style: normal; + font-stretch: normal; + line-height: normal; + letter-spacing: normal; + text-align: center; + color: black; + display: block; + padding: 8%; + text-decoration: none; +} + + +i.icon-white { + color: white; + position: absolute; + top: 30px; + margin-left: 30%; +} \ No newline at end of file