Skip to content

Commit d8e7a48

Browse files
committed
index
1 parent 995a8a6 commit d8e7a48

File tree

5 files changed

+51
-50
lines changed

5 files changed

+51
-50
lines changed

public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<options-component></options-component>
2828

2929
<footer>
30+
3031
<p><a href="https://github.com/WernerWaage/typescript-todo" class="underline">typescript-todo</a></p>
3132
</footer>
3233

src/components/common-component-style.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,17 @@ export const commonStylesheet = css`
3434
background-color: #f082ac;
3535
}
3636
37+
h2 {
38+
margin:20px;
39+
padding-top:20px;
40+
display: block;
41+
font-size: 1.5em;
42+
margin-inline-start: 20px;
43+
font-weight: bold;
44+
line-height: 1.5em
45+
}
46+
3747
.taskContainer {
38-
//box-shadow: outset, inset/h-offset v-offset blur spread color;
39-
// width: 350px;
40-
// height: 200px;
41-
// border: solid 1px #555;
4248
max-width: 960px;
4349
margin: 0 auto;
4450
background-color: #fff;

src/components/options-component.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,21 @@ class OptionsComponent extends MobxLitElement {
2626
const optionsHtml = html`
2727
<div class="container taskContainer">
2828
<div>
29-
Hello from options!
30-
<h1 id="welcomeText">Welcome to the todo list</h1>
31-
<b>[Import tasks]</b>-<b>Export tasks</b>-<b>Clear tasks</b>
32-
<button class="button-1" role="button">Button 1</button>
29+
<h2>Options</h2>
30+
31+
<button class="button-1" role="button">Import tasks</button>
32+
<button class="button-1" role="button">Export tasks</button>
33+
<button class="button-1" role="button">Clear tasks</button>
3334
3435
<br>
3536
3637
3738
<label>
3839
<input
3940
type="checkbox"
40-
4141
/> Toggle completed tasks
4242
<br>
4343
44-
<!-- <button @click=${() => myOptions.toggle()}>Toggle Options</button>
45-
-->
4644
</label>
4745
4846

src/components/todo-component.ts

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,17 @@ export class ToDoList extends MobxLitElement {
2626

2727
static styles = css`
2828
${commonStylesheet}
29-
h2 {
30-
margin:20px;
31-
padding-top:20px;
32-
display: block;
33-
font-size: 1.5em;
34-
margin-inline-start: 20px;
35-
font-weight: bold;
36-
line-height: 1.5em
37-
}
29+
3830
.innerList {
3931
padding: 1px;
4032
}
4133
.completed {
4234
text-decoration-line: line-through;
4335
color: #777;
4436
}
37+
.feedback {
38+
margin-left:20px;
39+
}
4540
ul {
4641
list-style-type: none;
4742
}
@@ -111,18 +106,22 @@ export class ToDoList extends MobxLitElement {
111106
</ul>
112107
</div>
113108
`
114-
const caughtUpMessage = html` <p>You're all caught up!</p> `
109+
const caughtUpMessage = html` <p class="feedback">You're all caught up!</p> `
115110
const renderPlaceholder =
116111
items.length > 0 ? renderTodoList : caughtUpMessage
117112
const outputHeader = html`<h2>To Do</h2>`
113+
118114
// Main output of the component:
119115
return html`
120116
<div class="container taskContainer">
121-
${outputHeader} ${this._feedback} ${renderPlaceholder}
117+
${outputHeader}
118+
<p class="feedback">${this._feedback}</p>
119+
120+
${renderPlaceholder}
122121
123122
<div class="inputContainer">
124123
<input id="newitem" class="input-task" aria-label="New item" />
125-
<button @click=${this.addToDo}>Add</button>
124+
<button id="btnAddTodo" @click=${this.addToDo}>Add</button>
126125
</div>
127126
<br />
128127
@@ -132,6 +131,8 @@ export class ToDoList extends MobxLitElement {
132131
`
133132
}
134133

134+
135+
135136
toggleCompleted(item: Task) {
136137
item.completed = !item.completed
137138
this.requestUpdate()
@@ -190,3 +191,18 @@ export class ToDoList extends MobxLitElement {
190191
}
191192
}
192193
}
194+
195+
// Get the input field
196+
var input = document.getElementById("newitem");
197+
198+
// Execute a function when the user presses a key on the keyboard
199+
input?.addEventListener("keypress", function(event) {
200+
// If the user presses the "Enter" key on the keyboard
201+
if (event.key === "Enter") {
202+
// Cancel the default action, if needed
203+
event.preventDefault();
204+
// Trigger the button element with a click
205+
console.log("okay!")
206+
document.getElementById("btnAddTodo")?.click();
207+
}
208+
});

src/index.ts

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@ const TodoListObserver = observable(person)
1818

1919
const loadtimes = getLoadTimes()
2020
console.log('Loaded : ' + loadtimes + ' times')
21-
let timerCountdown1 = new Timer(3)
22-
23-
const welcomeText = document.getElementById('welcomeText')
24-
const todoHeader = document.getElementById('todoHeader')
25-
26-
welcomeText?.addEventListener('click', function handleClick(event) {
27-
console.log('clicked the header!')
28-
welcomeText!.innerHTML =
29-
'Todo list - You have ' + timerCountdown1.timeLeft() + ' seconds left'
30-
})
21+
22+
// welcomeText?.addEventListener('click', function handleClick(event) {
23+
// console.log('clicked the header!')
24+
// welcomeText!.innerHTML =
25+
// 'Todo list - You have ' + timerCountdown1.timeLeft() + ' seconds left'
26+
// })
3127

3228
// counter
3329
function getLoadTimes(): number {
@@ -44,20 +40,4 @@ function getLoadTimes(): number {
4440
localStorage.setItem('LOADTIMES', loadtimes.toString())
4541
return loadtimes
4642
}
47-
48-
// Model the application state.
49-
class ObservableTimer {
50-
secondsPassed = 0
51-
52-
constructor() {
53-
makeAutoObservable(this)
54-
}
55-
56-
increase() {
57-
this.secondsPassed += 1
58-
}
59-
60-
reset() {
61-
this.secondsPassed = 0
62-
}
63-
}
43+

0 commit comments

Comments
 (0)