Skip to content

Commit 2054b81

Browse files
committed
responsive grid setup for toolbar button
1 parent f4345ed commit 2054b81

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

src/packages/rte/tiptap/components/input-tiptap/tiptap-fixed-menu.element.ts

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,19 @@ export class UmbTiptapFixedMenuElement extends UmbLitElement {
6262
}
6363

6464
override render() {
65-
return html`
66-
${map(
67-
this.toolbar,
68-
(row) => html`
69-
<div class="row">
70-
${map(row, (group) => html`<div class="group">${map(group, (alias) => this._lookup?.get(alias))}</div>`)}
71-
</div>
72-
`,
73-
)}
74-
`;
65+
return html`${map(this.toolbar, (row, rowIndex) =>
66+
map(
67+
row,
68+
(group, groupIndex) =>
69+
html`${map(group, (alias, aliasIndex) => {
70+
const newRow = rowIndex !== 0 && groupIndex === 0 && aliasIndex === 0;
71+
return html`<div class="item" ?data-new-row=${newRow} style="${newRow ? 'grid-column: 1 / span 3' : ''}">
72+
${this._lookup?.get(alias)}
73+
</div>`;
74+
})}
75+
<div class="separator"></div> `,
76+
),
77+
)} `;
7578
}
7679

7780
static override readonly styles = css`
@@ -87,8 +90,9 @@ export class UmbTiptapFixedMenuElement extends UmbLitElement {
8790
border-bottom-right-radius: 0;
8891
background-color: var(--uui-color-surface);
8992
color: var(--color-text);
90-
display: flex;
91-
flex-direction: column;
93+
display: grid;
94+
grid-template-columns: repeat(auto-fill, minmax(10px, 1fr));
95+
grid-auto-flow: row;
9296
position: sticky;
9397
top: -25px;
9498
left: 0px;
@@ -97,15 +101,19 @@ export class UmbTiptapFixedMenuElement extends UmbLitElement {
97101
z-index: 9999999;
98102
}
99103
100-
.row {
101-
display: flex;
102-
flex-direction: row;
103-
gap: var(--uui-size-space-3);
104+
.item {
105+
grid-column: span 3;
104106
}
105107
106-
.group {
107-
display: flex;
108-
flex-direction: row;
108+
.separator {
109+
background-color: var(--uui-color-border);
110+
width: 1px;
111+
place-self: center;
112+
height: 22px;
113+
}
114+
.separator:last-child,
115+
.separator:has(+ [data-new-row]) {
116+
display: none;
109117
}
110118
`;
111119
}

0 commit comments

Comments
 (0)