Skip to content

Commit

Permalink
feat(project): profiles loading overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
kiremitrov123 committed Jul 14, 2023
1 parent 9bb2fa5 commit b37cd94
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/components/LoadingOverlay/LoadingOverlay.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@
height: 100%;
background-color: rgba(variables.$black, 0.3);
}

.profile {
img {
position: absolute;
width: calc(#{variables.$base-spacing} * 8);
height: calc(#{variables.$base-spacing} * 8);
border-radius: 50%;
}
}
7 changes: 5 additions & 2 deletions src/components/LoadingOverlay/LoadingOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ import Spinner from '#components/Spinner/Spinner';
type Props = {
transparentBackground?: boolean;
inline?: boolean;
profileImageUrl?: string;
};

const LoadingOverlay = ({ transparentBackground = false, inline = false }: Props): JSX.Element => {
const LoadingOverlay = ({ transparentBackground = false, inline = false, profileImageUrl = '' }: Props): JSX.Element => {
const className = classNames(styles.loadingOverlay, {
[styles.transparent]: transparentBackground,
[styles.fixed]: !inline,
[styles.inline]: inline,
[styles.profile]: profileImageUrl,
});

return (
<div className={className}>
<Spinner />
{profileImageUrl && <img src={profileImageUrl} alt="Profile Avatar" />}
<Spinner size={profileImageUrl ? 'large' : 'medium'} />
</div>
);
};
Expand Down
14 changes: 14 additions & 0 deletions src/components/Spinner/Spinner.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@
height: variables.$base-spacing;
}

.large {
width: 142px;
height: 142px;
}

.large div {
width: calc(#{variables.$base-spacing} * 8);
height: calc(#{variables.$base-spacing} * 8);
}

.large.buffer div {
border-color: variables.$red-dark variables.$white variables.$white variables.$white;
}

.buffer div:nth-child(1) {
animation-delay: -0.45s;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Spinner/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import React from 'react';
import styles from './Spinner.module.scss';

type Props = {
size?: 'small' | 'medium';
size?: 'small' | 'medium' | 'large';
className?: string;
};

const Spinner = ({ size = 'medium', className = '' }: Props): JSX.Element => {
return (
<div className={classNames(styles.buffer, className, { [styles.small]: size === 'small' })}>
<div className={classNames(styles.buffer, className, { [styles.small]: size === 'small', [styles.large]: size === 'large' })}>
<div />
<div />
<div />
Expand Down

0 comments on commit b37cd94

Please sign in to comment.