@@ -4,6 +4,7 @@ import './index.scss';
44import React , { Component } from 'react' ;
55
66import Header from './Header/Header' ;
7+ import InfoBanner from './InfoBanner' ;
78import PropTypes from 'prop-types' ;
89
910class Layout extends Component {
@@ -20,14 +21,18 @@ class Layout extends Component {
2021 ? 'zh'
2122 : 'fi' ;
2223
24+ const visible = ! localStorage . getItem ( 'r18_banner_seen' ) ;
25+
26+ console . log ( visible ) ;
27+
2328 this . setState ( {
2429 siteLanguage : siteLanguage ,
25- visible : true ,
30+ visible,
2631 } ) ;
2732 }
2833
2934 hideNote ( ) {
30- console . log ( 'yes' ) ;
35+ localStorage . setItem ( 'r18_banner_seen' , 'yes' ) ;
3136 this . setState ( {
3237 siteLanguage : this . state . siteLanguage ,
3338 visible : false ,
@@ -37,66 +42,11 @@ class Layout extends Component {
3742 render ( ) {
3843 const { siteLanguage, visible } = this . state ;
3944
40- const style = {
41- padding : 10 ,
42- borderStyle : 'solid' ,
43- borderWidth : 2 ,
44- marginLeft : 80 ,
45- marginRight : 80 ,
46- position : 'sticky' ,
47- top : 100 ,
48- left : 40 ,
49- display : 'flex' ,
50- flexWrap : 'wrap' ,
51- flexDirection : 'row' ,
52- alignContent : 'space-between' ,
53- backgroundColor : '#E8E8E8' ,
54- zIndex : 2147483647 ,
55- } ;
56-
57- const linkStyle = {
58- color : 'grey' ,
59- textDecoration : 'underline' ,
60- } ;
61-
62- const textStyle = {
63- flex : 90 ,
64- } ;
65-
66- const buttonDiv = {
67- flex : 10 ,
68- textAlign : 'right' ,
69- } ;
70-
71- const buttonStyle = {
72- outline : 'none' ,
73- backgroundColor : 'transparent' ,
74- border : 'none' ,
75- } ;
76-
77- console . log ( this . state ) ;
78-
7945 return (
8046 < div className = "main-wrapper" >
8147 < Header lang = { siteLanguage } />
8248
83- { visible && (
84- < div style = { style } >
85- < div stule = { textStyle } >
86- Note that some libraries might not work with the new React version
87- 18. If you run in trouble with library compatibility, read{ ' ' }
88- < a href = "/en/part1/a_more_complex_state_debugging_react_apps#a-note-on-react-version" >
89- < span style = { linkStyle } > this</ span >
90- </ a >
91- .
92- </ div >
93- < div style = { buttonDiv } >
94- < button style = { buttonStyle } onClick = { ( ) => this . hideNote ( ) } >
95- x
96- </ button >
97- </ div >
98- </ div >
99- ) }
49+ < InfoBanner onHide = { ( ) => this . hideNote ( ) } visible = { visible } />
10050
10151 { this . props . children }
10252 </ div >
0 commit comments