public checkbox
This commit is contained in:
parent
384da1e832
commit
e93c892c53
4 changed files with 42 additions and 9 deletions
|
@ -4,7 +4,11 @@ import Button from './buttons/Button.tsx'
|
|||
import { openFileDialog } from '../utils/openFileDialog.ts'
|
||||
|
||||
interface NewPostWidgetProps {
|
||||
onSubmit: (content: string, media: { file: File; width: number; height: number }[]) => void
|
||||
onSubmit: (
|
||||
content: string,
|
||||
media: { file: File; width: number; height: number }[],
|
||||
isPublic: boolean,
|
||||
) => void
|
||||
isSubmitting?: boolean
|
||||
}
|
||||
|
||||
|
@ -19,6 +23,7 @@ interface Attachment {
|
|||
export default function NewPostWidget({ onSubmit, isSubmitting = false }: NewPostWidgetProps) {
|
||||
const [content, setContent] = useState('')
|
||||
const [attachments, setAttachments] = useState<Attachment[]>([])
|
||||
const [isPublic, setIsPublic] = useState(false)
|
||||
|
||||
const onContentInput = (value: string) => {
|
||||
setContent(value)
|
||||
|
@ -39,7 +44,7 @@ export default function NewPostWidget({ onSubmit, isSubmitting = false }: NewPos
|
|||
return
|
||||
}
|
||||
|
||||
onSubmit(content, attachments)
|
||||
onSubmit(content, attachments, isPublic)
|
||||
|
||||
attachments.forEach(({ objectUrl }) => URL.revokeObjectURL(objectUrl))
|
||||
setContent('')
|
||||
|
@ -85,9 +90,21 @@ export default function NewPostWidget({ onSubmit, isSubmitting = false }: NewPos
|
|||
)}
|
||||
|
||||
<div className="flex justify-between items-center pt-2">
|
||||
<Button secondary onClick={onAddMediaClicked}>
|
||||
+ add media
|
||||
</Button>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button secondary onClick={onAddMediaClicked}>
|
||||
+ add media
|
||||
</Button>
|
||||
<label className="flex items-center gap-1 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={isPublic}
|
||||
onChange={(e) => setIsPublic(e.target.checked)}
|
||||
disabled={isSubmitting}
|
||||
className="form-checkbox h-4 w-4 text-blue-600"
|
||||
/>
|
||||
<span className="text-primary-500">public</span>
|
||||
</label>
|
||||
</div>
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
disabled={isSubmitting || (content.trim() === '' && attachments.length === 0)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue