mirror of
https://github.com/remvze/moodist.git
synced 2025-09-29 15:30:49 -04:00
feat: add scroll for lower heights
This commit is contained in:
parent
d055e66dd9
commit
758f2f48dc
@ -1,5 +1,6 @@
|
|||||||
.divider {
|
.divider {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 1px;
|
height: 1px;
|
||||||
|
min-height: 1px;
|
||||||
background-color: var(--color-neutral-200);
|
background-color: var(--color-neutral-200);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
|
min-height: 40px;
|
||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
font-size: var(--font-sm);
|
font-size: var(--font-sm);
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
@ -28,30 +28,11 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
row-gap: 4px;
|
row-gap: 4px;
|
||||||
width: 240px;
|
width: 240px;
|
||||||
|
height: max-content;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
|
overflow: auto;
|
||||||
background-color: var(--color-neutral-100);
|
background-color: var(--color-neutral-100);
|
||||||
border: 1px solid var(--color-neutral-300);
|
border: 1px solid var(--color-neutral-300);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
|
||||||
& .menuItem {
|
|
||||||
position: flex;
|
|
||||||
align-items: center;
|
|
||||||
width: 100%;
|
|
||||||
padding: 12px 8px;
|
|
||||||
font-size: var(--font-sm);
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--color-foreground-subtle);
|
|
||||||
cursor: pointer;
|
|
||||||
background-color: transparent;
|
|
||||||
border: 1px solid var(--color-neutral-200);
|
|
||||||
border-radius: 4px;
|
|
||||||
outline: none;
|
|
||||||
transition: 0.2s;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: var(--color-foreground);
|
|
||||||
background-color: var(--color-neutral-200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { IoMenu, IoClose } from 'react-icons/io5/index';
|
import { IoMenu, IoClose } from 'react-icons/io5/index';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
|
||||||
import {
|
import {
|
||||||
useFloating,
|
useFloating,
|
||||||
autoUpdate,
|
autoUpdate,
|
||||||
offset,
|
offset,
|
||||||
flip,
|
flip,
|
||||||
shift,
|
shift,
|
||||||
|
size,
|
||||||
useClick,
|
useClick,
|
||||||
useDismiss,
|
useDismiss,
|
||||||
useRole,
|
useRole,
|
||||||
@ -25,8 +25,6 @@ import { Divider } from './divider';
|
|||||||
import { ShareLinkModal } from '@/components/modals/share-link';
|
import { ShareLinkModal } from '@/components/modals/share-link';
|
||||||
import { Notepad } from '@/components/toolbox';
|
import { Notepad } from '@/components/toolbox';
|
||||||
|
|
||||||
import { slideY, fade, mix } from '@/lib/motion';
|
|
||||||
|
|
||||||
import styles from './menu.module.css';
|
import styles from './menu.module.css';
|
||||||
|
|
||||||
export function Menu() {
|
export function Menu() {
|
||||||
@ -35,10 +33,20 @@ export function Menu() {
|
|||||||
const [showShareLink, setShowShareLink] = useState(false);
|
const [showShareLink, setShowShareLink] = useState(false);
|
||||||
const [showNotepad, setShowNotepad] = useState(false);
|
const [showNotepad, setShowNotepad] = useState(false);
|
||||||
|
|
||||||
const variants = mix(slideY(-20), fade());
|
|
||||||
|
|
||||||
const { context, floatingStyles, refs } = useFloating({
|
const { context, floatingStyles, refs } = useFloating({
|
||||||
middleware: [offset(12), flip(), shift()],
|
middleware: [
|
||||||
|
offset(12),
|
||||||
|
flip(),
|
||||||
|
shift(),
|
||||||
|
size({
|
||||||
|
apply({ availableHeight, elements }) {
|
||||||
|
Object.assign(elements.floating.style, {
|
||||||
|
maxHeight: `${availableHeight}px`,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
padding: 10,
|
||||||
|
}),
|
||||||
|
],
|
||||||
onOpenChange: setIsOpen,
|
onOpenChange: setIsOpen,
|
||||||
open: isOpen,
|
open: isOpen,
|
||||||
placement: 'top-end',
|
placement: 'top-end',
|
||||||
@ -68,20 +76,13 @@ export function Menu() {
|
|||||||
{isOpen ? <IoClose /> : <IoMenu />}
|
{isOpen ? <IoClose /> : <IoMenu />}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<AnimatePresence>
|
|
||||||
{isOpen && (
|
{isOpen && (
|
||||||
<FloatingFocusManager context={context} modal={false}>
|
<FloatingFocusManager context={context} modal={false}>
|
||||||
<div
|
<div
|
||||||
ref={refs.setFloating}
|
ref={refs.setFloating}
|
||||||
style={floatingStyles}
|
style={floatingStyles}
|
||||||
{...getFloatingProps()}
|
{...getFloatingProps()}
|
||||||
>
|
|
||||||
<motion.div
|
|
||||||
animate="show"
|
|
||||||
className={styles.menu}
|
className={styles.menu}
|
||||||
exit="hidden"
|
|
||||||
initial="hidden"
|
|
||||||
variants={variants}
|
|
||||||
>
|
>
|
||||||
<ShareItem open={() => setShowShareLink(true)} />
|
<ShareItem open={() => setShowShareLink(true)} />
|
||||||
<ShuffleItem />
|
<ShuffleItem />
|
||||||
@ -90,11 +91,9 @@ export function Menu() {
|
|||||||
<Divider />
|
<Divider />
|
||||||
<DonateItem />
|
<DonateItem />
|
||||||
<SourceItem />
|
<SourceItem />
|
||||||
</motion.div>
|
|
||||||
</div>
|
</div>
|
||||||
</FloatingFocusManager>
|
</FloatingFocusManager>
|
||||||
)}
|
)}
|
||||||
</AnimatePresence>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ShareLinkModal
|
<ShareLinkModal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user