Skip to content

Commit

Permalink
Uses CSS module instead of Stitches for Loader component
Browse files Browse the repository at this point in the history
Signed-off-by: Mihovil Ilakovac <[email protected]>
  • Loading branch information
infomiho committed Jul 12, 2024
1 parent 201c32d commit 14b60a2
Show file tree
Hide file tree
Showing 23 changed files with 316 additions and 287 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.loader {
color: var(--loader-color, #1a202c);
}

.loaderCircle {
display: inline-block;
border-top: 2px solid currentcolor;
border-right: 2px solid currentcolor;
border-bottom: 2px solid transparent;
border-left: 2px solid transparent;
border-radius: 99999px;
animation: fullRotation 0.45s linear infinite;
width: var(--spinner-size);
height: var(--spinner-size);
--spinner-size: var(--loader-spinner-size, 2rem);
}

.loaderAccessibilityText {
border: 0px;
clip: rect(0px, 0px, 0px, 0px);
width: 1px;
height: 1px;
margin: -1px;
padding: 0px;
overflow: hidden;
white-space: nowrap;
position: absolute;
}

@keyframes fullRotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
55 changes: 8 additions & 47 deletions waspc/data/Generator/templates/react-app/src/components/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,12 @@
import { styled, keyframes } from 'wasp/core/stitches.config'
import styles from './Loader.module.css'

const fullRotationKeyframes = keyframes({
'0%': { transform: 'rotate(0deg)' },
'100%': { transform: 'rotate(360deg)' },
})

// DefaultLoader is a React component that spans accross the whole screen and displays
// a spinner in the very middle.
// Spans a accross the whole screen and displays a spinner in the very middle.
export function Loader() {
const loaderClassName = ['loader', styles.loader].join(' ')
return (
<SpinnerWrapper className="loader">
<Spinner />
<SpinnerAccessbilityText>Loading...</SpinnerAccessbilityText>
</SpinnerWrapper>
<div className={loaderClassName}>
<div className={styles.loaderCircle} />
<div className={styles.loaderAccessibilityText}>Loading...</div>
</div>
)
}

const SpinnerWrapper = styled('div', {
color: '$gray900',
})

// Taken from Chakra UI Spinner component
const Spinner = styled('div', {
display: 'inline-block',
borderTop: '2px solid currentcolor',
borderRight: '2px solid currentcolor',
borderBottomStyle: 'solid',
borderLeftStyle: 'solid',
borderRadius: '99999px',
borderBottomWidth: '2px',
borderLeftWidth: '2px',
borderBottomColor: 'transparent',
borderLeftColor: 'transparent',
animation: `0.45s linear 0s infinite normal none running ${fullRotationKeyframes}`,
width: 'var(--spinner-size)',
height: 'var(--spinner-size)',
'--spinner-size': '2rem',
})

const SpinnerAccessbilityText = styled('span', {
border: '0px',
clip: 'rect(0px, 0px, 0px, 0px)',
width: '1px',
height: '1px',
margin: '-1px',
padding: '0px',
overflow: 'hidden',
whiteSpace: 'nowrap',
position: 'absolute',
})
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 14b60a2

Please sign in to comment.