Skip to content

Commit

Permalink
skeleton screen for messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jgw96 committed Jun 4, 2024
1 parent db74b1e commit 46b5238
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class AppHeader extends LitElement {
margin-top: 0;
margin-bottom: 0;
font-size: 12px;
font-weight: bold;
font-weight: normal;
color: black;
}
Expand Down
58 changes: 58 additions & 0 deletions src/components/message-skeleton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { LitElement, html, css } from 'lit';
import { customElement } from 'lit/decorators.js';

@customElement('message-skeleton')
export class MessageSkeleton extends LitElement {
static styles = [
css`
:host {
display: block;
overflow-x: hidden;
}
.skeleton {
background: #ffffff0f;
margin-bottom: 4px;
width: 48vw;
height: 25px;
border-radius: 4px;
overflow-x: hidden;
}
.shimmer {
background: linear-gradient(to right, #ffffff0f, #5c5c5c , #ffffff0f);
animation: shimmer 3s infinite linear;
}
@media(prefers-color-scheme: light) {
.skeleton {
background: #e1e1e1;
}
.shimmer {
background: linear-gradient(to right, #e1e1e1, #f1f1f1 , #e1e1e1);
}
}
@keyframes shimmer {
from {
transform: translateX(-200%);
}
to {
transform: translateX(200%);
}
}
`
];

render() {
return html`
<div class="skeleton shimmer">
</div>
`;
}
}
3 changes: 2 additions & 1 deletion src/pages/app-home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { styles } from '../styles/shared-styles';
import { classMap } from 'lit/directives/class-map.js';

import '../components/loading-toast';
import '../components/message-skeleton';

@customElement('app-home')
export class AppHome extends LitElement {
Expand Down Expand Up @@ -181,7 +182,7 @@ export class AppHome extends LitElement {
...this.previousMessages,
{
type: "assistant",
content: ""
content: "<message-skeleton></message-skeleton>"
}
];

Expand Down

0 comments on commit 46b5238

Please sign in to comment.