Skip to content

Commit 8832c76

Browse files
committed
Improve Nothing styles for small screens
1 parent 883a7de commit 8832c76

File tree

5 files changed

+41
-9
lines changed

5 files changed

+41
-9
lines changed

assets/components.js

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ window.LIST_EVENTS = {
99
DELETE: 'list:delete',
1010
}
1111

12+
/**
13+
* @param {string} eventName
14+
* @param {string} task
15+
* @param {boolean} isDone
16+
* @param {HTMLElement} target
17+
*/
1218
function dispatchTaskEvent(eventName, task, isDone, target) {
1319
target = target || document
1420
const taskChangeEvent = new CustomEvent(eventName, { detail: { task: task, done: isDone } })
@@ -31,8 +37,10 @@ class TaskControl extends HTMLElement {
3137
static TAG = 'task-control'
3238
static TEMPLATE_ID = 'newtask-template'
3339

40+
/** @return {HTMLElement} */
3441
get form() { return this.querySelector('form') }
3542

43+
/** @return {HTMLElement} */
3644
get taskList() { return Sortable.utils.closest(this, TaskList.TAG) }
3745

3846
setup() {
@@ -69,6 +77,7 @@ class TaskItem extends HTMLElement {
6977
static TAG = 'task-item'
7078
static TEMPLATE_ID = 'taskitem-template'
7179

80+
/** @return {HTMLElement} */
7281
get checkbox() { return this.querySelector('input[type=checkbox]') }
7382

7483
get done() { return this.checkbox.checked }
@@ -84,6 +93,7 @@ class TaskItem extends HTMLElement {
8493
}
8594
}
8695

96+
/** @return {HTMLElement} */
8797
get label() { return this.querySelector('.task-item--name') }
8898

8999
get name() { return this.getAttribute('name') }

assets/components_base.js

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
// https://javascript.info/mixins
2-
// Object.assign(ComponentClass, CustomElementStaticMixin)
1+
/**
2+
* @example Add mixin to a class
3+
*
4+
* Object.assign(ComponentClass, CustomElementStaticMixin)
5+
*
6+
* @see https://javascript.info/mixins
7+
*/
38
const CustomElementStaticMixin = {
49
/**
510
* Create custom element with provided attributes
@@ -22,7 +27,11 @@ const CustomElementStaticMixin = {
2227
},
2328
}
2429

25-
// Object.assign(ComponentClass.prototype, CustomElementMixin)
30+
/**
31+
* @example Add mixin to a class
32+
*
33+
* Object.assign(ComponentClass.prototype, CustomElementMixin)
34+
*/
2635
const CustomElementMixin = {
2736
connectedCallback() {
2837
this.events = this.events || []
@@ -74,9 +83,13 @@ const CustomElementMixin = {
7483
},
7584
}
7685

77-
// for (let k in CustomElementGetSetMixin) {
78-
// Object.defineProperty(ComponentClass.prototype, k, CustomElementGetSetMixin[k])
79-
// }
86+
/**
87+
* @example Add getters and setters to class prototype
88+
*
89+
* for (let k in CustomElementGetSetMixin) {
90+
* Object.defineProperty(ComponentClass.prototype, k, CustomElementGetSetMixin[k])
91+
* }
92+
*/
8093
const CustomElementGetSetMixin = {
8194
template: {
8295
get: function() {

assets/styles.css

+11-2
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,20 @@ task-item .delete,
430430
font-size: 1.5em;
431431
}
432432

433+
.task-control label {
434+
width: 100%;
435+
}
436+
437+
.task-control .icon {
438+
margin: 0 0 0 0.5rem;
439+
flex: 0 1 auto;
440+
}
441+
433442
.task-control .text-field {
434443
font-family: var(--theme-font, 'xkcd');
435-
min-width: 80%;
436-
max-width: 85%;
444+
flex: 1 0 80%;
437445
flex-grow: 1;
446+
width: initial;
438447
}
439448

440449
fieldset {

bin/run bin/dev

File renamed without changes.

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ <h3 class="task-list--title">
252252
<template id="newtask-template">
253253
<form action="#" class="new-task--form">
254254
<label for="task">
255-
<span class="icon mx-2">+</span>
255+
<span class="icon">+</span>
256256
<span class="sr-only">Task</span>
257257

258258
<input

0 commit comments

Comments
 (0)