Skip to content

Commit beabddc

Browse files
authored
Merge pull request #43 from kanko-dori/feature/loading-icon
💄 Add load icon
2 parents b5f1388 + a95a790 commit beabddc

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

hosting/src/components/FavItemDetail.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface Props {
1616
* @return {boolean} Return bool that color is darken
1717
*/
1818
const isDarken = (color: string): boolean => {
19-
if (!color.match(/^#[0-9a-f]{6}$/i)) throw new TypeError('Color must stats with #');
19+
if (!color.match(/^#[0-9a-f]{6}$/i)) return false;
2020
const hsv = convert.hex.hsv(color.substring(1));
2121
const hue = Math.round(((hsv[0] + 135) % 360) / 360);
2222
const saturation = hsv[1] / 100;
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.load {
2+
position: fixed;
3+
top: 50%;
4+
left: 50%;
5+
transform: translate(-50%, -50%);
6+
width: 30px;
7+
height: 30px;
8+
}
9+
10+
.load::before, .load::after {
11+
position: absolute;
12+
content: '';
13+
display: block;
14+
border-radius: 50%;
15+
border-top: 3px solid rgba(0, 0, 0, 0.5);
16+
width: 100%;
17+
height: 100%;
18+
}
19+
20+
.load::before {
21+
animation: rotation-right 0.75s ease 0.1s infinite reverse none;
22+
}
23+
24+
@keyframes rotation-right {
25+
0% {
26+
transform: rotate(0deg);
27+
}
28+
100% {
29+
transform: rotate(360deg);
30+
}
31+
}

hosting/src/components/LoadIcon.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React from 'react';
2+
import classes from './LoadIcon.module.css';
3+
4+
const LoadIcon: React.FC = () => <div className={classes.load} />;
5+
6+
export default LoadIcon;

hosting/src/pages/Favox.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import classes from './Favox.module.css';
77
// import PostItem from '../components/PostItem';
88
import ImportSpotify from '../components/ImportSpotify';
99
import UserHead from '../components/UserHead';
10+
import LoadIcon from '../components/LoadIcon';
1011

1112
interface Props {
1213
match: {
@@ -35,6 +36,10 @@ const Favox: React.FC<Props> = (props: Props) => {
3536
<>
3637
<UserHead username={props.match.params.username} />
3738
<Header username={props.match.params.username} />
39+
{
40+
(data.length === 0)
41+
&& <LoadIcon />
42+
}
3843
<div className={classes.container}>
3944
{
4045
(data !== []) && data.map((item) => <FavItem key={item.title} item={item} />)

0 commit comments

Comments
 (0)