Skip to content

Commit 542ee4b

Browse files
committed
Move create task button to tasks section and fix alignment
The create task button consumed unnecessary space on mobile devices because it was pushed under the primary title. Moving to the task list makes better use of the view port. Secondly there's now horrizontal rules under the tasks list heading and create button and the line separating tasks extends the full width of the bounding box.
1 parent 3c14fde commit 542ee4b

File tree

6 files changed

+182
-97
lines changed

6 files changed

+182
-97
lines changed

AGENTS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ Prioritize clean code:
5151
Code should follow a hexagonal architecture. Avoid packages/module names such as common, util and
5252
const. Instead focus on colocating code based on the feature or capability it belongs to.
5353

54-
Before implementing a feature or refactor, talk through your design to provide an opportunity for
55-
feedback.
54+
Do not implement any changes without sharing your proposal. This includes refactors, styling changes,
55+
and new functionality. Include a summary where you explain the problem back to the user and provide
56+
an overview of your proposed changes. Additionally include a details section with specifics on what
57+
you plan to do.
5658

5759
### Testing & Linting
5860

custom_components/maint/frontend/main.js

Lines changed: 81 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

custom_components/maint/frontend/main.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/main.ts

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ export class MaintPanel extends LitElement {
192192
protected render() {
193193
const hasEntries = this.dataState.entries.length > 0;
194194
const formDisabled = !this.dataState.selectedEntryId;
195-
const createDisabled = formDisabled || this.busy;
196195

197196
return html`
198197
<div class="container">
@@ -201,14 +200,6 @@ export class MaintPanel extends LitElement {
201200
<h1>${this.panelText("title")}</h1>
202201
<p class="subtext">${this.panelText("subtitle")}</p>
203202
</div>
204-
<button
205-
type="button"
206-
class="button-primary"
207-
?disabled=${createDisabled}
208-
@click=${this.openCreateModal}
209-
>
210-
${this.panelText("buttons.create")}
211-
</button>
212203
</div>
213204
${this.error ? html`<div class="error global-error">${this.error}</div>` : nothing}
214205
${hasEntries
@@ -223,22 +214,45 @@ export class MaintPanel extends LitElement {
223214
}
224215

225216
private renderTasksSection(formDisabled: boolean) {
217+
const createDisabled = formDisabled || this.busy;
218+
const header = html`
219+
<div class="tasks-section-header">
220+
<h2>${this.panelText("section_tasks")}</h2>
221+
<button
222+
type="button"
223+
class="button-primary tasks-create-button"
224+
?disabled=${createDisabled}
225+
@click=${this.openCreateModal}
226+
>
227+
${this.panelText("buttons.create")}
228+
</button>
229+
</div>
230+
<div class="tasks-section-divider" role="presentation"></div>
231+
`;
232+
226233
if (formDisabled) {
227234
return html`<section class="tasks-section">
228-
<h2>${this.panelText("section_tasks")}</h2>
229-
<p class="info">${this.panelText("info_enable_tracking")}</p>
235+
${header}
236+
<div class="tasks-section-content">
237+
<p class="info tasks-section-empty">${this.panelText("info_enable_tracking")}</p>
238+
</div>
230239
</section>`;
231240
}
232241

233-
return this.taskListFeature.render({
234-
tasks: this.dataState.tasks,
235-
hass: this.hass,
236-
entryId: this.dataState.selectedEntryId ?? null,
237-
busy: this.busy,
238-
editing: Boolean(this.editState.taskId),
239-
panelText: this.panelText.bind(this),
240-
localizeText: this.localizeText.bind(this)
241-
});
242+
return html`<section class="tasks-section">
243+
${header}
244+
<div class="tasks-section-content">
245+
${this.taskListFeature.render({
246+
tasks: this.dataState.tasks,
247+
hass: this.hass,
248+
entryId: this.dataState.selectedEntryId ?? null,
249+
busy: this.busy,
250+
editing: Boolean(this.editState.taskId),
251+
panelText: this.panelText.bind(this),
252+
localizeText: this.localizeText.bind(this)
253+
})}
254+
</div>
255+
</section>`;
242256
}
243257

244258
private renderCreateModal(formDisabled: boolean) {

frontend/src/styles.ts

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,40 @@ export const styles = css`
6363
6464
.tasks-section {
6565
margin-top: 12px;
66+
padding: 0;
67+
overflow: hidden;
68+
}
69+
70+
.tasks-section-header {
71+
display: flex;
72+
align-items: center;
73+
gap: 12px;
74+
padding: 14px 20px;
75+
}
76+
77+
.tasks-section-header h2 {
78+
margin: 0;
79+
flex: 1;
80+
}
81+
82+
.tasks-create-button {
83+
margin-left: auto;
84+
}
85+
86+
.tasks-section-divider {
87+
height: 1px;
88+
width: 100%;
89+
background: var(--divider-color);
90+
}
91+
92+
.tasks-section-content {
93+
display: flex;
94+
flex-direction: column;
95+
}
96+
97+
.tasks-section-empty {
98+
margin: 0;
99+
padding: 14px 20px;
66100
}
67101
68102
select,
@@ -107,7 +141,6 @@ export const styles = css`
107141
display: flex;
108142
flex-direction: column;
109143
gap: 0;
110-
margin-top: 12px;
111144
}
112145
113146
.task-row {
@@ -132,6 +165,7 @@ export const styles = css`
132165
display: flex;
133166
flex-direction: column;
134167
gap: 12px;
168+
padding-left: 20px;
135169
}
136170
137171
.task-description-line {
@@ -193,19 +227,16 @@ export const styles = css`
193227
flex-direction: column;
194228
align-items: flex-end;
195229
gap: 6px;
196-
margin-left: 12px;
197230
min-width: 140px;
231+
padding-right: 20px;
232+
box-sizing: border-box;
198233
}
199234
200235
.action-buttons {
201236
display: flex;
202237
gap: 8px;
203238
}
204239
205-
.tasks-section h2 {
206-
margin-bottom: 12px;
207-
}
208-
209240
.icon-button {
210241
background: none;
211242
color: var(--primary-text-color);

0 commit comments

Comments
 (0)