feat: remove tab number limit
This commit is contained in:
@@ -22,7 +22,7 @@ export const useTimelineList = (options?: {
|
||||
const savedHidden = (timelineTabs?.hidden ?? []).filter((id) => ids.includes(id))
|
||||
const extra = ids.filter((id) => !savedVisible.includes(id) && !savedHidden.includes(id))
|
||||
|
||||
const visible = [...savedVisible, ...extra].slice(0, 5)
|
||||
const visible = [...savedVisible, ...extra]
|
||||
if (options?.visible) return visible
|
||||
const hidden = [...savedHidden, ...extra].filter((id) => !visible.includes(id))
|
||||
if (options?.hidden) return hidden
|
||||
|
||||
+2
-33
@@ -27,8 +27,6 @@ import { useModalStack } from "~/components/ui/modal/stacked/hooks"
|
||||
import { parseView } from "~/hooks/biz/useRouteParams"
|
||||
import { useTimelineList } from "~/hooks/biz/useTimelineList"
|
||||
|
||||
const MAX_VISIBLE = 5
|
||||
|
||||
function ContainerDroppable({ id, children }: { id: "visible" | "hidden"; children: ReactNode }) {
|
||||
const { setNodeRef, isOver } = useDroppable({ id, data: { container: id } })
|
||||
return (
|
||||
@@ -130,27 +128,6 @@ const TimelineTabsSettings = () => {
|
||||
const sourceList = current(sourceKey)
|
||||
const targetList = current(targetKey)
|
||||
|
||||
// If moving into visible and it's full, replace the hovered item
|
||||
if (targetKey === "visible" && targetList.length >= MAX_VISIBLE) {
|
||||
const replaceIndex = targetList.indexOf(overId)
|
||||
if (replaceIndex === -1) return // container hover; ignore
|
||||
const replacedId = targetList[replaceIndex]!
|
||||
|
||||
const nextVisible = [...targetList]
|
||||
nextVisible[replaceIndex] = activeId
|
||||
|
||||
const activeIndexInSource = sourceList.indexOf(activeId)
|
||||
const nextSource = sourceList.filter((i) => i !== activeId)
|
||||
const insertIndex = activeIndexInSource !== -1 ? activeIndexInSource : nextSource.length
|
||||
nextSource.splice(insertIndex, 0, replacedId)
|
||||
|
||||
setUISetting("timelineTabs", {
|
||||
visible: nextVisible,
|
||||
hidden: targetKey === "visible" ? nextSource : hidden,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Normal cross-container insert
|
||||
const newIndexOfOver = targetList.indexOf(overId)
|
||||
const insertIndex = newIndexOfOver !== -1 ? newIndexOfOver : targetList.length
|
||||
@@ -183,15 +160,9 @@ const TimelineTabsSettings = () => {
|
||||
|
||||
return (
|
||||
<div
|
||||
className="mx-auto w-[600px] max-w-full space-y-4 overflow-hidden"
|
||||
className="mx-auto w-[600px] max-w-full space-y-4 overflow-hidden pt-2"
|
||||
onPointerDown={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="mb-2">
|
||||
<h2 className="text-title2 font-semibold text-text">Timeline Tabs</h2>
|
||||
<p className="text-headline text-text-secondary">
|
||||
First tab is fixed. Drag to choose up to {MAX_VISIBLE} visible tabs.
|
||||
</p>
|
||||
</div>
|
||||
<DndContext
|
||||
sensors={sensors}
|
||||
collisionDetection={closestCenter}
|
||||
@@ -200,9 +171,7 @@ const TimelineTabsSettings = () => {
|
||||
>
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<h3 className="mb-2 text-subheadline font-medium text-text">
|
||||
Visible ({visible.length}/{MAX_VISIBLE})
|
||||
</h3>
|
||||
<h3 className="mb-2 text-subheadline font-medium text-text">Visible</h3>
|
||||
<ContainerDroppable id="visible">
|
||||
<SortableContext items={visible} strategy={verticalListSortingStrategy}>
|
||||
{visible.map((id) => (
|
||||
|
||||
Reference in New Issue
Block a user