Skip to content

Commit

Permalink
Add loading skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
David Emanuel Luksic committed Dec 30, 2022
1 parent c38612d commit 83593d5
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.0",
"@vitejs/plugin-basic-ssl": "^1.0.1",
"autoprefixer": "^10.4.13",
"cloc": "^2.11.0",
"debug": "^4.3.4",
"eslint": "^8.30.0",
Expand Down
30 changes: 30 additions & 0 deletions pnpm-lock.yaml

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

1 change: 0 additions & 1 deletion src/components/Card.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
padding: var(--space-4);
border-radius: var(--space-4);
background-color: var(--color-bg-1);
border: 1px solid gray;
min-width: 20rem;
box-shadow: var(--shadow-1);

Expand Down
30 changes: 30 additions & 0 deletions src/components/Spinner.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@keyframes rotate {
from {
transform: rotate(0deg);
}

to {
transform: rotate(360deg);
}
}

.spinner {
--_track-width: var(--track-width, calc(0.125 * 1em));
width: 1em;
height: 1em;
mask-image: radial-gradient(
/* 1px for anti-aliasing */
transparent calc(1em * 0.5 - var(--_track-width) - 1px),
white calc(1em * 0.5 - var(--_track-width)),
white calc(1em * 0.5 - 2px),
transparent calc(1em * 0.5 - 1px));

&::after {
content: "";
display: block;
background: conic-gradient(transparent, currentColor);
animation: rotate 2s infinite linear;
width: 100%;
height: 100%;
}
}
5 changes: 5 additions & 0 deletions src/components/Spinner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import ui from './Spinner.module.css'

export function Spinner() {
return <div class={ui.spinner}></div>
}
12 changes: 11 additions & 1 deletion src/routes/space/[id].module.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
display: flex;
flex-direction: column;
padding: var(--space-4);
gap: var(--space-3);
overflow: hidden;
}

Expand Down Expand Up @@ -67,7 +68,7 @@
.network-controls {
grid-area: network;
display: flex;
gap: var(--space-2);
gap: var(--space-3);
align-items: center;
justify-self: flex-end
}
Expand All @@ -80,6 +81,7 @@
align-items: flex-end;

& button {
background-color: white;
border-radius: 100vmax;
}
}
Expand Down Expand Up @@ -112,6 +114,14 @@
}
}

.spinner {
display: grid;
place-content: center;
height: 100%;
font-size: 3rem;
color: #0004;
}

@media (max-width: 900px) {
.space-name {
text-align: start;
Expand Down
17 changes: 16 additions & 1 deletion src/routes/space/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { A } from '@solidjs/router'
import { CardComponent, CreateCard, MyCardComponent } from '~/components/Card'
import { For, Show, Suspense, createResource, createSignal } from 'solid-js'
import { SpaceContext, useSpace } from '~/components/SpaceContext'
import { Spinner } from '~/components/Spinner'
import { UserIDContext, useUserID } from '~/components/UserIDContext'
import { autofocus } from '~/utils/autofocus'
import { createSyncedStore, createUndoRedo } from '~/utils/createSyncedStore'
Expand Down Expand Up @@ -126,6 +127,20 @@ function NetworkControls(props: { online: boolean, setOnline: (value: boolean) =
)
}

function SpaceSkeleton() {
return (
<div class={ui.layout}>
<section class={ui.myCardsContainer}>
</section>
<div class={ui.main}>
<div class={ui.spinner}>
<Spinner />
</div>
</div>
</div>
)
}

export default function SpaceComponent() {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (isServer) {
Expand All @@ -150,7 +165,7 @@ export default function SpaceComponent() {
)
)
return (
<Suspense fallback={<div>Loading...</div>}>
<Suspense fallback={SpaceSkeleton}>
<Show when={userID() && spaceStore()}>
<UserIDContext.Provider value={() => userID()!}>
<SpaceContext.Provider value={spaceStore()!}>
Expand Down
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from 'vite'
import autoprefixer from 'autoprefixer'
import basicSsl from '@vitejs/plugin-basic-ssl'
import devtools from 'solid-devtools/vite'
import postcssNetsing from 'postcss-nesting'
Expand All @@ -19,7 +20,7 @@ export default defineConfig({
localsConvention: 'camelCaseOnly',
},
postcss: {
plugins: [postcssNetsing],
plugins: [postcssNetsing, autoprefixer],
},
},
server: {
Expand Down

1 comment on commit 83593d5

@vercel
Copy link

@vercel vercel bot commented on 83593d5 Dec 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

space-dex – ./

space-dex-git-main-deluksic.vercel.app
space-dex-deluksic.vercel.app
space-dex.vercel.app

Please sign in to comment.