-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from iceljc/features/add-loading-dots-markdown
Features/add loading dots markdown
- Loading branch information
Showing
10 changed files
with
196 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<script> | ||
import { range } from "$lib/helpers/utils"; | ||
/** @type {string} */ | ||
export let color = '#FF3E00'; | ||
/** @type {string} */ | ||
export let unit = 'px'; | ||
/** @type {string} */ | ||
export let duration = '1.5s'; | ||
/** @type {string | number} */ | ||
export let size = '60'; | ||
/** @type {boolean} */ | ||
export let pause = false; | ||
/** @type {'dot' | 'cube'} */ | ||
export let shape = 'dot'; | ||
/** @type {number} */ | ||
export let count = 3; | ||
/** @type {string | number} */ | ||
export let gap = '10'; | ||
const unitRegex = /[a-zA-Z]/; | ||
const durationUnit = duration.match(unitRegex)?.[0] ?? 's'; | ||
const durationNum = duration.replace(unitRegex, ''); | ||
</script> | ||
<div class="loading-wrapper" style="--size: {size}{unit}; --color: {color}; --duration: {duration}; --count: {count}; --gap: {gap}{unit}"> | ||
{#each range(count, 0) as version} | ||
<div | ||
class={`animation ${shape === 'cube' ? 'cube' : 'dot'}`} | ||
class:pause-animation={pause} | ||
style="animation-delay: {version * (+durationNum / 10)}{durationUnit};" | ||
/> | ||
{/each} | ||
</div> | ||
<style> | ||
.loading-wrapper { | ||
position: relative; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: calc(var(--size) * var(--count) + var(--gap) * (var(--count) - 1)); | ||
height: calc(var(--size)); | ||
gap: var(--gap); | ||
} | ||
.animation { | ||
background-color: var(--color); | ||
animation: motion var(--duration) cubic-bezier(0.895, 0.03, 0.685, 0.22) infinite; | ||
} | ||
.cube { | ||
width: calc(var(--size) / 2); | ||
height: var(--size); | ||
} | ||
.dot { | ||
width: var(--size); | ||
height: var(--size); | ||
border-radius: 50%; | ||
} | ||
.pause-animation { | ||
animation-play-state: paused; | ||
} | ||
@keyframes motion { | ||
0% { | ||
opacity: 1; | ||
} | ||
50% { | ||
opacity: 0; | ||
} | ||
100% { | ||
opacity: 1; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function range(size = 3, startAt = 0) { | ||
return [...Array(size).keys()].map((i) => i + startAt); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/routes/chat/[agentId]/[conversationId]/rc-markdown.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<script> | ||
import { marked } from 'marked'; | ||
import { replaceNewLine } from '$lib/helpers/http'; | ||
// /** @type {import('$types').TextMessage} */ | ||
// export let message; | ||
/** @type {string} */ | ||
export let message = "The SQL statement to create a new service category named 'DSC Equipment' is: <br /> ```sql INSERT INTO data_ServiceCategory (Name) VALUES ('DSC Equipment');``` <br /> I have executed the query to create the new service category."; | ||
</script> | ||
|
||
<span>{@html marked(replaceNewLine(message || ''))}</span> |