mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-11 12:23:20 +00:00
text expander update
This commit is contained in:
1 parent
c6c5ad1131
commit
124a8ba690
2 files changed
+9
-5
No files matched your search
@@ -2,17 +2,18 @@ import React, { useState } from "react";
|
||||
|
||||
interface Props {
|
||||
text: string;
|
||||
cutLength: number;
|
||||
}
|
||||
|
||||
export const TextExpander: React.FC<Props> = ({ text }) => {
|
||||
export const TextExpander: React.FC<Props> = ({ text, cutLength }) => {
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
|
||||
const shortText = text.slice(0, 250);
|
||||
const shortText = text.slice(0, cutLength);
|
||||
|
||||
return (
|
||||
<>
|
||||
{expanded || text.length <= 250 ? text : shortText + "..."}
|
||||
{text.length > 250 && (
|
||||
{expanded || text.length <= cutLength ? text : shortText + "..."}
|
||||
{text.length > cutLength && (
|
||||
<button
|
||||
className="btn-link fw-medium p-0 ps-1"
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
|
||||
@@ -478,7 +478,10 @@ function TtsResultViewPage(props: Props) {
|
||||
</div>*/}
|
||||
|
||||
<motion.p className="mb-3 result-text mt-4 pt-2">
|
||||
<TextExpander text={ttsInferenceResult.raw_inference_text} />
|
||||
<TextExpander
|
||||
text={ttsInferenceResult.raw_inference_text}
|
||||
cutLength={250}
|
||||
/>
|
||||
</motion.p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user