MVP-ish initial implementation of Quote
The menuExtras is hacky, I know.
This commit is contained in:
parent
4843970e1b
commit
0e1be5dbdc
5 changed files with 41 additions and 5 deletions
|
@ -1788,6 +1788,7 @@ body > .szh-menu-container {
|
||||||
animation-duration: 0.3s;
|
animation-duration: 0.3s;
|
||||||
animation-timing-function: ease-in-out;
|
animation-timing-function: ease-in-out;
|
||||||
width: auto;
|
width: auto;
|
||||||
|
min-width: min(12em, 90vw);
|
||||||
}
|
}
|
||||||
.szh-menu .footer {
|
.szh-menu .footer {
|
||||||
margin: 8px 0 -8px;
|
margin: 8px 0 -8px;
|
||||||
|
|
|
@ -103,4 +103,5 @@ export const ICONS = {
|
||||||
'arrows-right': () => import('@iconify-icons/mingcute/arrows-right-line'),
|
'arrows-right': () => import('@iconify-icons/mingcute/arrows-right-line'),
|
||||||
code: () => import('@iconify-icons/mingcute/code-line'),
|
code: () => import('@iconify-icons/mingcute/code-line'),
|
||||||
copy: () => import('@iconify-icons/mingcute/copy-2-line'),
|
copy: () => import('@iconify-icons/mingcute/copy-2-line'),
|
||||||
|
quote: () => import('@iconify-icons/mingcute/quote-left-line'),
|
||||||
};
|
};
|
||||||
|
|
|
@ -235,6 +235,12 @@ function Compose({
|
||||||
};
|
};
|
||||||
const focusTextarea = () => {
|
const focusTextarea = () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (!textareaRef.current) return;
|
||||||
|
// status starts with newline, focus on first position
|
||||||
|
if (draftStatus?.status?.startsWith?.('\n')) {
|
||||||
|
textareaRef.current.selectionStart = 0;
|
||||||
|
textareaRef.current.selectionEnd = 0;
|
||||||
|
}
|
||||||
console.debug('FOCUS textarea');
|
console.debug('FOCUS textarea');
|
||||||
textareaRef.current?.focus();
|
textareaRef.current?.focus();
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Menu, MenuItem, SubMenu } from '@szhsin/react-menu';
|
import { MenuItem, SubMenu } from '@szhsin/react-menu';
|
||||||
import { cloneElement } from 'preact';
|
import { cloneElement } from 'preact';
|
||||||
import { useRef } from 'preact/hooks';
|
import { useRef } from 'preact/hooks';
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ function MenuConfirm({
|
||||||
confirmLabel,
|
confirmLabel,
|
||||||
menuItemClassName,
|
menuItemClassName,
|
||||||
menuFooter,
|
menuFooter,
|
||||||
|
menuExtras,
|
||||||
...props
|
...props
|
||||||
}) {
|
}) {
|
||||||
const { children, onClick, ...restProps } = props;
|
const { children, onClick, ...restProps } = props;
|
||||||
|
@ -53,6 +54,7 @@ function MenuConfirm({
|
||||||
<MenuItem className={menuItemClassName} onClick={onClick}>
|
<MenuItem className={menuItemClassName} onClick={onClick}>
|
||||||
{confirmLabel}
|
{confirmLabel}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
{menuExtras}
|
||||||
{menuFooter}
|
{menuFooter}
|
||||||
</Parent>
|
</Parent>
|
||||||
);
|
);
|
||||||
|
|
|
@ -748,10 +748,24 @@ function Status({
|
||||||
confirmLabel={
|
confirmLabel={
|
||||||
<>
|
<>
|
||||||
<Icon icon="rocket" />
|
<Icon icon="rocket" />
|
||||||
<span>{reblogged ? 'Unboost?' : 'Boost to everyone?'}</span>
|
<span>{reblogged ? 'Unboost' : 'Boost'}</span>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
className={`menu-reblog ${reblogged ? 'checked' : ''}`}
|
className={`menu-reblog ${reblogged ? 'checked' : ''}`}
|
||||||
|
menuExtras={
|
||||||
|
<MenuItem
|
||||||
|
onClick={() => {
|
||||||
|
states.showCompose = {
|
||||||
|
draftStatus: {
|
||||||
|
status: `\n${url}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon icon="quote" />
|
||||||
|
<span>Quote</span>
|
||||||
|
</MenuItem>
|
||||||
|
}
|
||||||
menuFooter={
|
menuFooter={
|
||||||
mediaNoDesc &&
|
mediaNoDesc &&
|
||||||
!reblogged && (
|
!reblogged && (
|
||||||
|
@ -1920,11 +1934,23 @@ function Status({
|
||||||
confirmLabel={
|
confirmLabel={
|
||||||
<>
|
<>
|
||||||
<Icon icon="rocket" />
|
<Icon icon="rocket" />
|
||||||
<span>
|
<span>{reblogged ? 'Unboost' : 'Boost'}</span>
|
||||||
{reblogged ? 'Unboost?' : 'Boost to everyone?'}
|
|
||||||
</span>
|
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
menuExtras={
|
||||||
|
<MenuItem
|
||||||
|
onClick={() => {
|
||||||
|
states.showCompose = {
|
||||||
|
draftStatus: {
|
||||||
|
status: `\n${url}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon icon="quote" />
|
||||||
|
<span>Quote</span>
|
||||||
|
</MenuItem>
|
||||||
|
}
|
||||||
menuFooter={
|
menuFooter={
|
||||||
mediaNoDesc &&
|
mediaNoDesc &&
|
||||||
!reblogged && (
|
!reblogged && (
|
||||||
|
|
Loading…
Add table
Reference in a new issue