Added ui components.
This commit is contained in:
parent
729a7fcb4e
commit
9563a5f2c0
@ -1,6 +1,8 @@
|
||||
import React from 'react';
|
||||
import useFetch from '../../hooks/fetch';
|
||||
import PickerItem from '../PickerItem/PickerItem';
|
||||
import Loading from '../ui/Loading';
|
||||
import ErrorMessage from '../ui/ErrorMessage';
|
||||
import './SlideshowPicker.css';
|
||||
|
||||
const SlideshowPicker = () => {
|
||||
@ -8,17 +10,13 @@ const SlideshowPicker = () => {
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div>
|
||||
LOADING
|
||||
</div>
|
||||
<Loading />
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div>
|
||||
{error}
|
||||
</div>
|
||||
<ErrorMessage error={error.message} />
|
||||
);
|
||||
}
|
||||
|
||||
|
21
src/components/ui/ErrorMessage.css
Normal file
21
src/components/ui/ErrorMessage.css
Normal file
@ -0,0 +1,21 @@
|
||||
.error {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
padding: 2rem;
|
||||
background: pink;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.error h2 {
|
||||
margin-bottom: 1rem;
|
||||
color: red;
|
||||
}
|
||||
|
||||
.error pre {
|
||||
padding: 1rem;
|
||||
background: #eee;
|
||||
border-radius: 5px;
|
||||
}
|
16
src/components/ui/ErrorMessage.js
Normal file
16
src/components/ui/ErrorMessage.js
Normal file
@ -0,0 +1,16 @@
|
||||
import React from 'react';
|
||||
import "./ErrorMessage.css";
|
||||
|
||||
const ErrorMessage = ({ error }) => {
|
||||
return (
|
||||
<div className="error">
|
||||
<h2>Something happened!</h2>
|
||||
|
||||
<pre>
|
||||
{JSON.stringify(error, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ErrorMessage;
|
19
src/components/ui/Loading.css
Normal file
19
src/components/ui/Loading.css
Normal file
@ -0,0 +1,19 @@
|
||||
.loading {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
|
||||
position: fixed;
|
||||
top: calc(50% - 25px);
|
||||
left: calc(50% - 25px);
|
||||
|
||||
animation: rotation 1.5s infinite linear;
|
||||
}
|
||||
|
||||
@keyframes rotation {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(359deg);
|
||||
}
|
||||
}
|
10
src/components/ui/Loading.js
Normal file
10
src/components/ui/Loading.js
Normal file
@ -0,0 +1,10 @@
|
||||
import React from 'react';
|
||||
import './Loading.css';
|
||||
|
||||
const Loading = () => {
|
||||
return (
|
||||
<img className="loading" src="/android-chrome-256x256.png" alt="logo" />
|
||||
);
|
||||
};
|
||||
|
||||
export default Loading;
|
Loading…
Reference in New Issue
Block a user