Editor tweaks (#829)

* Show border around selected embeds

* Make editor tooltips not animate
This commit is contained in:
Sinclair Chen 2022-08-31 20:52:12 -07:00 committed by GitHub
parent 2c3cd34444
commit 7c1e663b26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View File

@ -73,7 +73,9 @@ export function useTextEditor(props: {
const editorClass = clsx(
proseClass,
!simple && 'min-h-[6em]',
'outline-none pt-2 px-4'
'outline-none pt-2 px-4',
'prose-img:select-auto',
'[&_.ProseMirror-selectednode]:outline-dotted [&_*]:outline-indigo-300' // selected img, emebeds
)
const editor = useEditor(
@ -164,7 +166,7 @@ export function TextEditor(props: {
<EditorContent editor={editor} />
{/* Toolbar, with buttons for images and embeds */}
<div className="flex h-9 items-center gap-5 pl-4 pr-1">
<Tooltip className="flex items-center" text="Add image" noTap>
<Tooltip text="Add image" noTap noFade>
<FileUploadButton
onFiles={upload.mutate}
className="-m-2.5 flex h-10 w-10 items-center justify-center rounded-full text-gray-400 hover:text-gray-500"
@ -172,7 +174,7 @@ export function TextEditor(props: {
<PhotographIcon className="h-5 w-5" aria-hidden="true" />
</FileUploadButton>
</Tooltip>
<Tooltip className="flex items-center" text="Add embed" noTap>
<Tooltip text="Add embed" noTap noFade>
<button
type="button"
onClick={() => setIframeOpen(true)}
@ -186,7 +188,7 @@ export function TextEditor(props: {
<CodeIcon className="h-5 w-5" aria-hidden="true" />
</button>
</Tooltip>
<Tooltip className="flex items-center" text="Add market" noTap>
<Tooltip text="Add market" noTap noFade>
<button
type="button"
onClick={() => setMarketOpen(true)}

View File

@ -21,8 +21,9 @@ export function Tooltip(props: {
className?: string
placement?: Placement
noTap?: boolean
noFade?: boolean
}) {
const { text, children, className, placement = 'top', noTap } = props
const { text, children, className, placement = 'top', noTap, noFade } = props
const arrowRef = useRef(null)
@ -64,10 +65,10 @@ export function Tooltip(props: {
{/* conditionally render tooltip and fade in/out */}
<Transition
show={open}
enter="transition ease-out duration-200"
enterFrom="opacity-0 "
enter="transition ease-out duration-50"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="transition ease-in duration-150"
leave={noFade ? '' : 'transition ease-in duration-150'}
leaveFrom="opacity-100"
leaveTo="opacity-0"
// div attributes