Skip to content

Commit

Permalink
make loading skeleton for editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmin-Mare committed May 26, 2024
1 parent 7637194 commit 545c4db
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/components/codemirror.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,23 @@

.container :global(.cm-panels) {
position: unset;
}

.containerSkeleton {
background: linear-gradient(
to right,
rgba(255, 255, 255, 0),
rgba(255, 255, 255, 0.5) 50%,
rgba(255, 255, 255, 0) 80%
),
lightgray;
background-repeat: repeat-y;
background-size: 50px 500px;
background-position: 0 0;
animation: shine 1s infinite ease-in-out;
}
@keyframes shine {
to {
background-position: 100% 0, /* move highlight to right */ 0 0;
}
}
9 changes: 8 additions & 1 deletion src/components/codemirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ export default function CodeMirror(props: CodeMirrorProps) {
}, [editorRef]);

return (
<div class={`${styles.container} ${props.class ?? ''}`} ref={parent} />
<div
class={`${styles.container} ${
editorRef === undefined
? styles.containerSkeleton
: ""
} ${props.class ?? ""}`}
ref={parent}
/>
)
}

0 comments on commit 545c4db

Please sign in to comment.