fix: smooth the loader animation
This commit is contained in:
parent
73d34ea69b
commit
7ef6eae97a
@ -1,5 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
|
||||
import { motion as m } from 'framer-motion'
|
||||
|
||||
export default function GenerateResponse() {
|
||||
const [loader, setLoader] = useState(0)
|
||||
|
||||
@ -28,10 +30,17 @@ export default function GenerateResponse() {
|
||||
return (
|
||||
<div className=" mb-1 mt-2 py-2 text-center">
|
||||
<div className="relative inline-block overflow-hidden rounded-lg bg-[hsla(var(--loader-bg))] px-4 py-2 font-semibold text-[hsla(var(--loader-fg))] shadow-lg">
|
||||
<div
|
||||
<m.div
|
||||
initial={{ width: 0 }}
|
||||
className="absolute left-0 top-0 h-full bg-[hsla(var(--loader-active-bg))]"
|
||||
style={{ width: `${loader}%` }}
|
||||
style={{ width: 250 }}
|
||||
data-testid="response-loader"
|
||||
animate={{
|
||||
width: `${loader}%`,
|
||||
transition: {
|
||||
duration: 0.25,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<span className="relative z-10">Generating response...</span>
|
||||
</div>
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
|
||||
import { motion as m } from 'framer-motion'
|
||||
|
||||
import { useActiveModel } from '@/hooks/useActiveModel'
|
||||
|
||||
export default function ModelStart() {
|
||||
@ -37,10 +39,17 @@ export default function ModelStart() {
|
||||
return (
|
||||
<div className=" mb-1 mt-2 py-2 text-center">
|
||||
<div className="relative inline-block max-w-[300px] overflow-hidden text-ellipsis whitespace-nowrap rounded-lg bg-[hsla(var(--loader-bg))] px-4 py-2 font-semibold text-[hsla(var(--loader-fg))] shadow-lg">
|
||||
<div
|
||||
<m.div
|
||||
initial={{ width: 0 }}
|
||||
className="absolute left-0 top-0 h-full bg-[hsla(var(--loader-active-bg))]"
|
||||
style={{ width: `${loader}%` }}
|
||||
style={{ width: 250 }}
|
||||
data-testid="model-loader"
|
||||
animate={{
|
||||
width: `${loader}%`,
|
||||
transition: {
|
||||
duration: 0.25,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<span className="relative z-10 line-clamp-1 max-w-[300px]">
|
||||
{stateModel.state === 'start' ? 'Starting' : 'Stopping'}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user