Skip to content

Commit

Permalink
Improve loader behaviour, add loading text
Browse files Browse the repository at this point in the history
  • Loading branch information
iaincollins committed Sep 9, 2024
1 parent a3b70cb commit 2615dc8
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 11 deletions.
3 changes: 2 additions & 1 deletion components/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Head from 'next/head'
export default ({
title = 'Ardent Industry – Trade & Exploration',
loading = false,
loadingText,
children
}) =>
<>
Expand All @@ -14,6 +15,6 @@ export default ({
<meta name='author' content='Iain Collins' />
<meta name='viewport' content='width=device-width' />
</Head>
<Loader visible={loading} />
<Loader visible={loading} text={loadingText} />
{children}
</>
5 changes: 3 additions & 2 deletions components/loader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function Loader ({ visible }) {
export default function Loader ({ visible, text}) {
return (
<>
{/* <div className='loader__background' style={{ opacity: visible ? 1 : 0 }} /> */}
<div className='loader__background' style={{ opacity: visible ? 1 : 0 }} />
<div className='loader__spinner' style={{ opacity: visible ? 1 : 0 }}>
<div className='loader__row'>
<div className='loader__arrow loader__arrow--outer-18' />
Expand Down Expand Up @@ -36,6 +36,7 @@ export default function Loader ({ visible }) {
<div className='loader__arrow loader__arrow--down loader__arrow--outer-9' />
</div>
</div>
{text && <div className='loader__text' style={{ opacity: visible ? 1 : 0 }}>{text}</div>}
</>
)
}
Expand Down
30 changes: 26 additions & 4 deletions css/components/loader.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* CSS specific to the loader animation */

.loader__spinner {
position: absolute;
position: fixed;
top: 50%;
left: 0;
width: 100%;
Expand All @@ -17,7 +17,7 @@
}

.loader__spinner::before {
position: absolute;
position: fixed;
top: -1.8rem;
height: 9rem;
width: 9rem;
Expand All @@ -28,14 +28,36 @@
filter: blur(3rem);
}

.loader__text {
position: fixed;
top: 50%;
left: 0;
width: 100%;
margin-top: 4rem;
display: flex;
flex-direction: column;
align-items: center;
zoom: 1.5;
transition: .25s ease-in-out;
z-index: 3000;
pointer-events: none;
text-align: center;
text-shadow: 0 0 .5rem #000;
font-family: 'Jura';
font-synthesis: weight;
font-weight: bold;
text-transform: uppercase;
font-size: .8rem;
}

.loader__background {
z-index: 2999;
position: absolute;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0,0,0,.05);
background: rgba(0,0,0,.5);
backdrop-filter: blur(.05rem);
box-shadow: inset 0 0 10rem rgba(0,0,0,.5);
border-radius: .2rem;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ardent-www",
"version": "0.45.3",
"version": "0.45.4",
"description": "Ardent Industry",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion pages/commodities.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default () => {
}, [])

return (
<Layout loading={commodities === undefined}>
<Layout loading={commodities === undefined} loadingText='Loading commodities…'>
<Head>
<link rel='canonical' href='https://ardent-industry.com/commodities' />
</Head>
Expand Down
2 changes: 1 addition & 1 deletion pages/commodity/[commodity-name]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default () => {
}, [])

return (
<Layout loading={commodity === undefined || imports === undefined || updating}>
<Layout loading={commodity === undefined || imports === undefined || updating} loadingText={'Loading trade data…'}>
<Head>
<link rel='canonical' href={`https://ardent-industry.com/system/${commodity?.symbol}/${tabs[tabIndex]}`} />
</Head>
Expand Down
2 changes: 1 addition & 1 deletion pages/system/[system-name]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default () => {
}, [router.query['system-name']])

return (
<Layout loading={system === undefined}>
<Layout loading={system === undefined} loadingText='Loading system data…'>
<Head>
<link rel='canonical' href={`https://ardent-industry.com/system/${system?.systemName}/${tabs[tabIndex]}`} />
</Head>
Expand Down

0 comments on commit 2615dc8

Please sign in to comment.