Skip to content

Commit e9fbd27

Browse files
committed
Switch to grid instead of flex.
1 parent ad89d2e commit e9fbd27

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

src/pg/treeItem/treeItem.css

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,54 @@
4040
flex: 1;
4141
outline: 0;
4242
padding: 0 0.25rem;
43-
margin: -0.125rem -0.125rem -0.125rem -0.25rem;
43+
margin: -0.125rem -0.625rem -0.125rem -0.25rem;
4444
border-width: var(--pg-tree-item-border-width, 0);
4545
border-style: solid;
4646
border-color: var(--pg-tree-item-border-color, #453C4F);
4747
}
4848

4949
[part=item] {
50-
display: flex;
50+
display: grid;
5151
background: var(--pg-tree-item-background, transparent);
5252
border-radius: 0.25rem;
5353
padding: 0.25rem;
5454
gap: 0.5rem;
55-
}
56-
57-
[part=item] {
5855
user-select: none;
5956
padding-left: calc((var(--x) * 0.5rem) + 0.25rem);
6057
transition: background-color 0.1s ease-out;
6158
}
6259

60+
[part=item].items {
61+
grid-template-columns: min-content min-content auto min-content;
62+
grid-template-rows: auto;
63+
}
64+
[part=item]:not(.items) {
65+
grid-template-columns: min-content auto min-content;
66+
grid-template-rows: auto;
67+
}
68+
[part=dropon] {
69+
display: none;
70+
grid-row: 1;
71+
}
72+
[part=dropbelow] {
73+
display: none;
74+
grid-row: 1;
75+
}
76+
6377
[part=item]:hover {
6478
background: var(--pg-tree-item-background-hover, rgb(69, 60, 79, 0.1));
6579
}
6680

6781
[part=item].items.selected {
6882
background-color: var(--pg-tree-item-background-selected, rgb(69, 60, 79, 0.1));
6983
}
70-
[part=item].items.selected [part=toggle] {
71-
position: relative;
84+
[part=item].items.selected:not(.expanded) [part=toggle] {
85+
border-radius: 0.125rem;
86+
background-color: var(--pg-tree-item-background-selected, #453C4F);
87+
background-image: url("data:image/svg+xml; utf8, <svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27><path d=%27M 17,13L 17,11L 11,5L 9,7L 14,12L 9,17L 11,19%27 fill='white' /></svg>") !important;
88+
}
89+
90+
[part=item].items.selected.expanded [part=toggle] {
7291
border-radius: 0.125rem;
7392
background-color: var(--pg-tree-item-background-selected, #453C4F);
7493
background-image: url("data:image/svg+xml; utf8, <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M 11,17L 13,17L 19,11L 17,9L 12,14L 7,9L 5,11' fill='white' /></svg>") !important;

src/pg/treeItem/treeItem.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<button part="iconButton">
44
<pg-icon part="icon"></pg-icon>
55
</button>
6-
<input part="input" type="input" class="hide" />
6+
<input part="input" type="text" class="hide" />
77
<button part="labelButton">
88
<span part="label"></span>
99
</button>

src/pg/treeItem/treeItem.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ export default class PgTreeItem extends HTMLElement {
309309
}
310310
}
311311

312+
#canvas;
312313
#handleDragStart(event) {
313314
let dragCount = 0;
314315
this.dispatchEvent(new CustomEvent('itemdragstart', {
@@ -370,6 +371,7 @@ export default class PgTreeItem extends HTMLElement {
370371
);
371372
}
372373
event.dataTransfer.setDragImage(canvas, 0, 0);
374+
this.#canvas = canvas;
373375
}
374376

375377
#handleDragEnd(event) {
@@ -379,6 +381,7 @@ export default class PgTreeItem extends HTMLElement {
379381
detail: { indexes: [this.index] }
380382
}));
381383
this.$item.classList.toggle('dragging', false);
384+
this.#canvas.remove();
382385
}
383386

384387

0 commit comments

Comments
 (0)