parent
bbcbfd1aa9
commit
6e24e0ee85
@ -168,17 +168,16 @@ export function StreamEditor({ ev, onFinish, options }: StreamEditorProps) {
|
|||||||
)}
|
)}
|
||||||
{(options?.canSetSummary ?? true) && (
|
{(options?.canSetSummary ?? true) && (
|
||||||
<StreamInput label={<FormattedMessage defaultMessage="Summary" />}>
|
<StreamInput label={<FormattedMessage defaultMessage="Summary" />}>
|
||||||
<input
|
<textarea
|
||||||
type="text"
|
rows={5}
|
||||||
placeholder={formatMessage({ defaultMessage: "A short description of the content" })}
|
placeholder={formatMessage({ defaultMessage: "A description of the stream" })}
|
||||||
value={summary}
|
value={summary}
|
||||||
onChange={e => setSummary(e.target.value)}
|
onChange={e => setSummary(e.target.value)} />
|
||||||
/>
|
|
||||||
</StreamInput>
|
</StreamInput>
|
||||||
)}
|
)}
|
||||||
{(options?.canSetImage ?? true) && (
|
{(options?.canSetImage ?? true) && (
|
||||||
<StreamInput label={<FormattedMessage defaultMessage="Cover Image" />}>
|
<StreamInput label={<FormattedMessage defaultMessage="Cover Image" />}>
|
||||||
{image && <img src={image} className="mb-2 aspect-video object-cover rounded-xl" />}
|
{image && <img src={image} className="mb-2 aspect-video object-cover rounded-xl max-h-[200px] mx-auto" />}
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<input type="text" placeholder="https://" value={image} onChange={e => setImage(e.target.value)} />
|
<input type="text" placeholder="https://" value={image} onChange={e => setImage(e.target.value)} />
|
||||||
<FileUploader onResult={v => setImage(v ?? "")} onError={e => setError(e.toString())} />
|
<FileUploader onResult={v => setImage(v ?? "")} onError={e => setError(e.toString())} />
|
||||||
|
@ -1,24 +1,38 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
|
import { Text } from "../text";
|
||||||
|
|
||||||
export function StreamSummary({ text }: { text: string }) {
|
export function StreamSummary({ text }: { text: string }) {
|
||||||
const [expand, setExpand] = useState(false);
|
const [expand, setExpand] = useState(false);
|
||||||
|
|
||||||
const cutOff = 100;
|
const cutOff = Math.min(100, [...text].reduce((acc, v, i) => {
|
||||||
|
if (v === '\n' && acc[0] < 3) {
|
||||||
|
acc[0] += 1;
|
||||||
|
acc[1] = i;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, [0, 0])[1]);
|
||||||
const shouldExpand = text.length > cutOff;
|
const shouldExpand = text.length > cutOff;
|
||||||
return (
|
return (
|
||||||
<div className="whitespace-pre text-pretty">
|
<div className="whitespace-pre text-pretty">
|
||||||
{shouldExpand && !expand ? text.slice(0, cutOff) : text}
|
{shouldExpand && !expand ? text.slice(0, cutOff) : <Text content={text} tags={[]} />}
|
||||||
{shouldExpand && (
|
{shouldExpand && <>
|
||||||
<span
|
<span
|
||||||
className="text-primary text-bold cursor-pointer"
|
className="text-primary text-bold cursor-pointer"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setExpand(x => !x);
|
setExpand(x => !x);
|
||||||
}}>
|
}}>
|
||||||
{expand && <FormattedMessage defaultMessage="Hide" />}
|
|
||||||
{!expand && <FormattedMessage defaultMessage="...more" />}
|
{!expand && <FormattedMessage defaultMessage="...more" />}
|
||||||
</span>
|
</span>
|
||||||
)}
|
{expand && <div className="text-primary text-bold cursor-pointer"
|
||||||
|
onClick={() => {
|
||||||
|
setExpand(x => !x);
|
||||||
|
}}>
|
||||||
|
<FormattedMessage defaultMessage="Hide" />
|
||||||
|
</div>}
|
||||||
|
</>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user