fix: table max width

This commit is contained in:
hypercross 2026-02-26 17:24:25 +08:00
parent af4cb15d2c
commit d171e7b094
3 changed files with 27 additions and 17 deletions

View File

@ -22,6 +22,8 @@
:md-table[./sparks.csv]{roll remix} :md-table[./sparks.csv]{roll remix}
:md-table[./npcs.csv]{roll}
### 链接 ### 链接
文本里面可以有:md-link[./stuff.md#啊什么]的啦 文本里面可以有:md-link[./stuff.md#啊什么]的啦

6
content/npcs.csv Normal file
View File

@ -0,0 +1,6 @@
label,body
"Hello world","**Hello**, world"
"Hello foo","**Hello**, foo"
"Hello bar","**Hello**, bar"
"Hello stuff","**Hello**, stuff"
"Hello again","**Hello**, again"
1 label body
2 Hello world **Hello**, world
3 Hello foo **Hello**, foo
4 Hello bar **Hello**, bar
5 Hello stuff **Hello**, stuff
6 Hello again **Hello**, again

View File

@ -145,7 +145,7 @@ customElement('md-table', { roll: false, remix: false }, (props, { element }) =>
return ( return (
<div class="ttrpg-table"> <div class="ttrpg-table">
<div class="flex items-center gap-2 border-b border-gray-200"> <div class="flex items-center gap-2 border-b border-gray-200">
<div class="flex flex-col w-full"> <div class="flex flex-col overflow-x-auto">
{/* 分组 tabs */} {/* 分组 tabs */}
<Show when={hasGroup()}> <Show when={hasGroup()}>
<div class="flex gap-2 border-b border-gray-100 pb-2"> <div class="flex gap-2 border-b border-gray-100 pb-2">
@ -176,30 +176,32 @@ customElement('md-table', { roll: false, remix: false }, (props, { element }) =>
</div> </div>
</Show> </Show>
{/* 内容 tabs */} {/* 内容 tabs */}
<div class="flex gap-2"> <div class="flex items-center gap-2">
<Show when={props.roll}> <Show when={props.roll}>
<button <button
onClick={handleRoll} onClick={handleRoll}
class="text-gray-500 hover:text-gray-700" class="text-gray-500 hover:text-gray-700 flex-shrink-0"
title="随机切换" title="随机切换"
> >
🎲 🎲
</button> </button>
</Show> </Show>
<For each={filteredRows()}> <div class="flex gap-2 overflow-x-auto flex-1 min-w-0">
{(row, index) => ( <For each={filteredRows()}>
<button {(row, index) => (
onClick={() => setActiveTab(index())} <button
class={`font-medium transition-colors ${ onClick={() => setActiveTab(index())}
activeTab() === index() class={`font-medium transition-colors flex-shrink-0 ${
? 'text-blue-600 border-b-2 border-blue-600' activeTab() === index()
: 'text-gray-500 hover:text-gray-700' ? 'text-blue-600 border-b-2 border-blue-600'
}`} : 'text-gray-500 hover:text-gray-700'
> }`}
{row.label} >
</button> {row.label}
)} </button>
</For> )}
</For>
</div>
</div> </div>
</div> </div>
</div> </div>