@@ -133,41 +133,40 @@ const App: React.FunctionComponent<AppProps> = (props) => {
133133 ) ;
134134} ;
135135
136- const headerImageStyle : React . CSSProperties = {
136+ const repeatingImageStyle : React . CSSProperties = {
137137 width : '95%' ,
138138 margin : '0 2.5%' ,
139139}
140- const Header = ( { image } : { image : Image } ) => image && (
141- < img src = { image . fileData . src } style = { headerImageStyle } />
142- ) ;
143-
144- const footerContainerStyle : React . CSSProperties = {
145- paddingTop : '1rem' ,
146- }
147- const footerImageWrapperStyle : React . CSSProperties = {
148- position : 'fixed' ,
149- bottom : 0 ,
150- right : 0 ,
151- width : '100%' ,
152- }
153- const placeHolderFooterImageWrapperStyle : React . CSSProperties = {
140+ const placeHolderImageWrapperStyle : React . CSSProperties = {
154141 width : '100%' ,
155142 visibility : 'hidden' ,
156143}
157- const footerImageStyle : React . CSSProperties = {
158- width : '95%' ,
159- margin : '0 2.5%' ,
160- }
161- const Footer = ( { image } : { image : Image } ) => image && (
162- < div style = { footerContainerStyle } >
163- < div style = { placeHolderFooterImageWrapperStyle } >
164- < img src = { image . fileData . src } style = { footerImageStyle } />
165- </ div >
166- < div style = { footerImageWrapperStyle } >
167- < img src = { image . fileData . src } style = { footerImageStyle } />
144+ type RepeatingPageImageEdge = 'top' | 'bottom' ;
145+ const RepeatingPageImage = ( { image, edge } : { image : Image ; edge : RepeatingPageImageEdge } ) => {
146+ if ( ! image ) return null ;
147+
148+ const containerStyle : React . CSSProperties = edge === 'top' ? { paddingBottom : '1rem' } : { paddingTop : '1rem' } ;
149+ const imageWrapperStyle : React . CSSProperties = {
150+ position : 'fixed' ,
151+ [ edge ] : 0 ,
152+ right : 0 ,
153+ width : '100%' ,
154+ } ;
155+
156+ return (
157+ < div style = { containerStyle } >
158+ < div style = { placeHolderImageWrapperStyle } >
159+ < img src = { image . fileData . src } style = { repeatingImageStyle } />
160+ </ div >
161+ < div style = { imageWrapperStyle } >
162+ < img src = { image . fileData . src } style = { repeatingImageStyle } />
163+ </ div >
168164 </ div >
169- </ div >
170- ) ;
165+ ) ;
166+ } ;
167+
168+ const Header = ( { image } : { image : Image } ) => < RepeatingPageImage image = { image } edge = "top" /> ;
169+ const Footer = ( { image } : { image : Image } ) => < RepeatingPageImage image = { image } edge = "bottom" /> ;
171170
172171const PersonalNote = ( { note } : { note : string } ) => note && (
173172 < h4 > { note } </ h4 >
0 commit comments