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[./npcs.csv]{roll}
### 链接
文本里面可以有: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 (
<div class="ttrpg-table">
<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 */}
<Show when={hasGroup()}>
<div class="flex gap-2 border-b border-gray-100 pb-2">
@ -176,21 +176,22 @@ customElement('md-table', { roll: false, remix: false }, (props, { element }) =>
</div>
</Show>
{/* 内容 tabs */}
<div class="flex gap-2">
<div class="flex items-center gap-2">
<Show when={props.roll}>
<button
onClick={handleRoll}
class="text-gray-500 hover:text-gray-700"
class="text-gray-500 hover:text-gray-700 flex-shrink-0"
title="随机切换"
>
🎲
</button>
</Show>
<div class="flex gap-2 overflow-x-auto flex-1 min-w-0">
<For each={filteredRows()}>
{(row, index) => (
<button
onClick={() => setActiveTab(index())}
class={`font-medium transition-colors ${
class={`font-medium transition-colors flex-shrink-0 ${
activeTab() === index()
? 'text-blue-600 border-b-2 border-blue-600'
: 'text-gray-500 hover:text-gray-700'
@ -203,6 +204,7 @@ customElement('md-table', { roll: false, remix: false }, (props, { element }) =>
</div>
</div>
</div>
</div>
<div class="p-1 prose max-w-none">
<Show when={!csvData.loading && filteredRows().length > 0}>
<div innerHTML={bodyHtml()} />