diff --git a/src/back/routes/common/show-first-row/show-first-row.css b/src/back/routes/common/show-first-row/show-first-row.css index d82206c..3f35bc6 100644 --- a/src/back/routes/common/show-first-row/show-first-row.css +++ b/src/back/routes/common/show-first-row/show-first-row.css @@ -10,10 +10,14 @@ transition: row-gap 200ms, overflow 200ms; overflow: hidden; - input:not(:checked) + & { - grid-template-rows: 1fr repeat(calc(var(--items-count) - 1), 0px); + .show-first-row__checkbox:not(:checked) + & { row-gap: 0; } + + & > * { + align-self: center; + justify-self: center; + } } .show-first-row__default-button { diff --git a/src/back/routes/common/show-first-row/show-first-row.tsx b/src/back/routes/common/show-first-row/show-first-row.tsx index 5c4dbb4..253f0a7 100644 --- a/src/back/routes/common/show-first-row/show-first-row.tsx +++ b/src/back/routes/common/show-first-row/show-first-row.tsx @@ -11,10 +11,15 @@ const showFirstRowIds = (function* () { } })(); +function min_container_width(columns: number, column_width: number, gap: number) { + return columns * column_width + (columns - 1) * gap; +} + export async function showFirstRow({ items, min_column_width_px = 250, column_gap_px = 10, + row_gap_px = column_gap_px, make_show_more_button = () => ( Show more ), @@ -29,18 +34,21 @@ export async function showFirstRow({ ), classes = [], + how_many_rows = () => 1, }: { items: FlatTemplatable[]; min_column_width_px?: number; make_show_more_button?: () => JSX.Element; make_show_less_button?: () => JSX.Element; column_gap_px?: number; + row_gap_px?: number; add_button_to_content?: ( content: JSX.Element, show_more_button: JSX.Element, show_less_button: JSX.Element ) => JSX.Element; classes?: classNames.ArgumentArray; + how_many_rows?: (columns_count: number) => number; }): Promise { const id = showFirstRowIds.next().value; const checkbox_id = "show-first-row__checkbox--" + id; @@ -54,24 +62,58 @@ export async function showFirstRow({ ]} style={`--min-column-width: ${min_column_width_px}px; --items-count: ${items.length}; --column-gap: ${column_gap_px}px`} > - { - /* HTML */ `` - } - + `; + }) + .join("\n")} + {add_button_to_content(
{items}
,