Skip to content
Snippets Groups Projects
Commit 948306dc authored by Sivert Kronen Hatteberg's avatar Sivert Kronen Hatteberg
Browse files

Add a simple loading component and spinner animation

parent dd855b08
No related branches found
No related tags found
1 merge request!52Add a simple loading component and spinner animation
Pipeline #92767 passed
...@@ -5,5 +5,6 @@ ...@@ -5,5 +5,6 @@
}, },
"language": { "language": {
"change": "Change language to {{lang}}" "change": "Change language to {{lang}}"
} },
"loading": "Loading..."
} }
...@@ -5,5 +5,6 @@ ...@@ -5,5 +5,6 @@
}, },
"language": { "language": {
"change": "Bytt språk til {{lang}}" "change": "Bytt språk til {{lang}}"
} },
"loading": "Laster..."
} }
...@@ -5,5 +5,6 @@ ...@@ -5,5 +5,6 @@
}, },
"language": { "language": {
"change": "Bytt språk til {{lang}}" "change": "Bytt språk til {{lang}}"
} },
"loading": "Lastar..."
} }
...@@ -3,7 +3,8 @@ import { useTranslation } from 'react-i18next' ...@@ -3,7 +3,8 @@ import { useTranslation } from 'react-i18next'
import './App.css' import './App.css'
import { Button } from './components/button' import { Button } from 'components/button'
import Loading from 'components/loading'
import { appTimezone, appVersion, appTheme } from './appConfig' import { appTimezone, appVersion, appTheme } from './appConfig'
...@@ -54,6 +55,7 @@ const App = () => { ...@@ -54,6 +55,7 @@ const App = () => {
lang: i18n.language === 'en' ? 'Norsk' : 'Engelsk', lang: i18n.language === 'en' ? 'Norsk' : 'Engelsk',
})} })}
</Button> </Button>
<Loading />
<p> <p>
Version {appVersion} Version {appVersion}
<br /> <br />
......
import styled from 'styled-components/macro'
const Spinner = styled.div`
position: relative;
display: inline-block;
width: 1.5rem;
height: 1.5rem;
margin-left: 0;
margin-right: 1rem;
margin-top: 0;
border: 3px solid rgba(200, 200, 200);
border-width: 3px;
border-radius: 50%;
border-top-color: rgba(50, 50, 50);
animation: spin 0.8s linear infinite;
@keyframes spin {
to {
transform: rotate(360deg);
}
}
`
export default Spinner
import styled, { DefaultTheme } from 'styled-components/macro' import styled from 'styled-components/macro'
type ButtonProps = { export const Button = styled.a`
theme: DefaultTheme
}
export const Button = styled.a<ButtonProps>`
display: inline-block; display: inline-block;
border-radius: 3px; border-radius: 3px;
padding: 0.5rem 0; padding: 0.5rem 0;
...@@ -14,8 +10,8 @@ export const Button = styled.a<ButtonProps>` ...@@ -14,8 +10,8 @@ export const Button = styled.a<ButtonProps>`
color: white; color: white;
border: 2px solid white; border: 2px solid white;
:hover { :hover {
background: ${(props) => props.theme.colors.secondary}; background: ${({ theme }) => theme.colors.secondary};
color: black; color: black;
} }
background: ${(props) => props.theme.colors.main}; background: ${({ theme }) => theme.colors.main};
` `
import React from 'react'
import { useTranslation } from 'react-i18next'
import Spinner from 'components/animations/spinner'
import styled from 'styled-components/macro'
const SpinnerWrapper = styled.div`
display: flex;
justify-content: center;
align-items: center;
`
function Loading() {
const { t } = useTranslation(['common'])
return (
<SpinnerWrapper>
<Spinner />
{t('common:loading')}
</SpinnerWrapper>
)
}
export default Loading
import React, { Suspense } from 'react' import React, { Suspense } from 'react'
import ReactDOM from 'react-dom' import ReactDOM from 'react-dom'
import { ThemeProvider } from 'styled-components/macro' import { ThemeProvider } from 'styled-components/macro'
import 'i18n' import 'i18n'
import getCurrentTheme from 'theme' import getCurrentTheme from 'theme'
import GlobalStyle from 'globalStyles' import GlobalStyle from 'globalStyles'
import App from './App' import App from './App'
import reportWebVitals from './reportWebVitals' import reportWebVitals from './reportWebVitals'
import Loading from 'components/loading'
function appRoot() { function appRoot() {
return ( return (
<> <>
<React.StrictMode> <React.StrictMode>
<GlobalStyle /> <GlobalStyle />
<Suspense fallback="loading"> <Suspense fallback={<Loading />}>
<ThemeProvider theme={getCurrentTheme()}> <ThemeProvider theme={getCurrentTheme()}>
<App /> <App />
</ThemeProvider> </ThemeProvider>
......
import { DefaultTheme } from 'styled-components' import { DefaultTheme } from 'styled-components/macro'
const white = '#FFFFFF' const white = '#FFFFFF'
const hotPink = '#FF69B4' const hotPink = '#FF69B4'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment