Skip to content

Commit 4aded01

Browse files
Add slot to todo items (#86)
* Wrap input in todo-main * Add slot to todo-item
1 parent c99208a commit 4aded01

File tree

2 files changed

+56
-24
lines changed

2 files changed

+56
-24
lines changed

typescript/packages/common-ui/src/components/common-input.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export class CommonInputElement extends LitElement {
1212
--height: 24px;
1313
}
1414
15+
.input-wrapper {
16+
display: flex;
17+
flex-direction: column;
18+
justify-content: center;
19+
}
20+
1521
.input {
1622
appearance: none;
1723
border: 0;
@@ -43,11 +49,14 @@ export class CommonInputElement extends LitElement {
4349
}
4450

4551
return html`
46-
<input
47-
class="input"
48-
@input="${oninput}"
49-
.value="${this.value}"
50-
.placeholder="${this.placeholder}"
51-
type="text" />`;
52+
<div class="input-wrapper">
53+
<input
54+
class="input"
55+
@input="${oninput}"
56+
.value="${this.value}"
57+
.placeholder="${this.placeholder}"
58+
type="text" />
59+
</div>
60+
`;
5261
}
5362
}

typescript/packages/common-ui/src/components/common-todo.ts

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,40 @@ export class CommonTodoElement extends LitElement {
4242
baseStyles,
4343
css`
4444
:host {
45+
--todo-height: 40px;
4546
display: block;
4647
}
4748
4849
.todo {
4950
display: grid;
5051
grid-template-columns: min-content 1fr;
51-
align-items: center;
5252
column-gap: var(--pad);
53-
min-height: 40px;
5453
}
5554
5655
.todo-ctl {
5756
display: flex;
5857
gap: var(--gap);
5958
align-items: center;
59+
height: var(--todo-height);
60+
}
61+
62+
.todo-main {
63+
display: flex;
64+
flex-direction: column;
65+
gap: var(--pad);
66+
min-height: var(--todo-height);
67+
}
68+
69+
.todo-value {
70+
display: flex;
71+
flex-direction: column;
72+
justify-content: center;
73+
height: var(--todo-height);
74+
}
75+
76+
.todo-input {
77+
--height: var(--todo-height);
78+
height: var(--todo-height);
6079
}
6180
6281
.todo-checkbox {
@@ -92,29 +111,33 @@ export class CommonTodoElement extends LitElement {
92111
new CommonTodoInputEvent({
93112
id: this.id,
94113
value: this.value,
95-
checked: this.checked,
114+
checked: this.checked
96115
})
97116
);
98117
};
99118

100119
return html`
101-
<div class="todo">
102-
<div class="todo-ctl">
103-
<input
104-
class="todo-checkbox"
105-
type="checkbox"
106-
@change="${oncheck}"
107-
.checked="${this.checked}"
108-
/>
120+
<div class="todo">
121+
<div class="todo-ctl">
122+
<input
123+
class="todo-checkbox"
124+
type="checkbox"
125+
@change="${oncheck}"
126+
.checked="${this.checked}"
127+
/>
128+
</div>
129+
<div class="todo-main">
130+
<div class="todo-value">
131+
<common-input
132+
class="todo-input"
133+
@input="${oninput}"
134+
.placeholder="${this.placeholder}"
135+
.value="${this.value}">
136+
</common-input>
109137
</div>
110-
<common-input
111-
class="unibox-input"
112-
@input="${oninput}"
113-
.placeholder="${this.placeholder}"
114-
.value="${this.value}"
115-
>
116-
</common-input>
138+
<slot></slot>
117139
</div>
140+
</div>
118141
`;
119142
}
120143
}

0 commit comments

Comments
 (0)