From df119dcc03f21b6b50fd913f3c4127eb44df22b5 Mon Sep 17 00:00:00 2001 From: marc-i Date: Thu, 14 May 2026 15:26:01 +0200 Subject: [PATCH] extract html & css --- src/app/app.component.css | 181 ++++++++++++++++++++++ src/app/app.component.html | 109 ++++++++++++++ src/app/app.component.ts | 300 +------------------------------------ 3 files changed, 293 insertions(+), 297 deletions(-) create mode 100644 src/app/app.component.css create mode 100644 src/app/app.component.html diff --git a/src/app/app.component.css b/src/app/app.component.css new file mode 100644 index 0000000..585d441 --- /dev/null +++ b/src/app/app.component.css @@ -0,0 +1,181 @@ +/* ── Layout ──────────────────────────────────────────── */ +.container { + max-width: 640px; + margin: 2rem auto; + padding: 0 1rem; + font-family: inherit; /* übernimmt Font aus styles.css */ +} + +/* ── Header ──────────────────────────────────────────── */ +.app-header { + text-align: center; + margin-bottom: 2rem; +} +.app-header h1 { + font-size: 2rem; + margin: 0; +} +.subtitle { + color: #888; + font-size: 0.85rem; + margin: 0.25rem 0 0; +} + +/* ── Fehlermeldung ───────────────────────────────────── */ +.error-box { + display: flex; + justify-content: space-between; + align-items: center; + background: #fee2e2; + border: 1px solid #fca5a5; + color: #b91c1c; + padding: 0.75rem 1rem; + border-radius: 8px; + margin-bottom: 1rem; +} +.close-btn { + background: none; + border: none; + cursor: pointer; + color: #b91c1c; + font-size: 1rem; +} + +/* ── Formular ────────────────────────────────────────── */ +.add-form { + display: flex; + gap: 0.5rem; + margin-bottom: 1.5rem; +} +.add-form input { + flex: 1; + padding: 0.6rem 0.8rem; + border: 1px solid #d1d5db; + border-radius: 8px; + font-size: 1rem; + outline: none; + transition: border-color 0.2s; +} +.add-form input:focus { + border-color: #2563eb; +} +.add-form button { + padding: 0.6rem 1.2rem; + background: #2563eb; + color: #fff; + border: none; + border-radius: 8px; + font-size: 1rem; + cursor: pointer; + white-space: nowrap; + transition: background 0.2s; +} +.add-form button:hover:not(:disabled) { + background: #1d4ed8; +} +.add-form button:disabled { + opacity: 0.5; + cursor: default; +} + +/* ── Ladeindikator ───────────────────────────────────── */ +.loading { + text-align: center; + color: #6b7280; + padding: 2rem; +} + +/* ── ToDo-Liste ──────────────────────────────────────── */ +.todo-list { + list-style: none; + margin: 0; + padding: 0; + display: flex; + flex-direction: column; + gap: 0.5rem; +} +.empty-state { + text-align: center; + color: #9ca3af; + padding: 2rem; +} +.todo-item { + display: flex; + align-items: center; + gap: 0.75rem; + padding: 0.75rem 1rem; + background: #fff; + border: 1px solid #e5e7eb; + border-radius: 8px; + transition: background 0.15s; +} +.todo-item:hover { + background: #f9fafb; +} + +/* Abgehaktes ToDo: Text wird durchgestrichen und ausgegraut */ +.todo-item.completed .todo-title { + text-decoration: line-through; + color: #9ca3af; +} + +.todo-item input[type="checkbox"] { + width: 1.1rem; + height: 1.1rem; + cursor: pointer; + flex-shrink: 0; +} +.todo-title { + flex: 1; + cursor: pointer; +} +.user-badge { + font-size: 0.7rem; + color: #6b7280; + background: #f3f4f6; + border-radius: 99px; + padding: 0.15rem 0.5rem; + white-space: nowrap; +} +.delete-btn { + background: none; + border: none; + color: #d1d5db; + font-size: 1rem; + cursor: pointer; + padding: 0.25rem; + line-height: 1; + border-radius: 4px; + transition: color 0.15s; +} +.delete-btn:hover { + color: #ef4444; +} + +/* ── Pagination ──────────────────────────────────────── */ +.pagination { + display: flex; + justify-content: center; + align-items: center; + gap: 1rem; + margin-top: 1.5rem; +} +.pagination button { + padding: 0.5rem 1rem; + border: 1px solid #d1d5db; + background: #fff; + border-radius: 8px; + cursor: pointer; + transition: background 0.15s; +} +.pagination button:hover:not(:disabled) { + background: #f3f4f6; +} +.pagination button:disabled { + opacity: 0.4; + cursor: default; +} +.page-info { + color: #6b7280; + font-size: 0.9rem; +} diff --git a/src/app/app.component.html b/src/app/app.component.html new file mode 100644 index 0000000..2f530b8 --- /dev/null +++ b/src/app/app.component.html @@ -0,0 +1,109 @@ +
+ +
+

ToDo-App

+

Angular 21 · Vite · REST-API

+
+ + +
+ Fehler: {{ error }} + +
+ + +
+ + +
+ + +
Daten werden geladen…
+ + + + + + + +
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 5942537..07b5cf8 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -25,303 +25,9 @@ import { Todo } from './todo.model'; // imports: Andere Angular-Module/Komponenten, die im Template verwendet werden imports: [CommonModule, FormsModule], - // template: Das HTML-Template der Komponente (inline, kein separates File) - template: ` -
- -
-

ToDo-App

-

Angular 21 · Vite · REST-API

-
- - -
- Fehler: {{ error }} - -
- - -
- - -
- - -
Daten werden geladen…
- - - - - - - -
- `, - - // styles: Komponenten-spezifisches CSS (ist automatisch auf diese Komponente begrenzt) - styles: [` - /* ── Layout ──────────────────────────────────────────── */ - .container { - max-width: 640px; - margin: 2rem auto; - padding: 0 1rem; - font-family: inherit; /* übernimmt Font aus styles.css */ - } - - /* ── Header ──────────────────────────────────────────── */ - .app-header { - text-align: center; - margin-bottom: 2rem; - } - .app-header h1 { - font-size: 2rem; - margin: 0; - } - .subtitle { - color: #888; - font-size: 0.85rem; - margin: 0.25rem 0 0; - } - - /* ── Fehlermeldung ───────────────────────────────────── */ - .error-box { - display: flex; - justify-content: space-between; - align-items: center; - background: #fee2e2; - border: 1px solid #fca5a5; - color: #b91c1c; - padding: 0.75rem 1rem; - border-radius: 8px; - margin-bottom: 1rem; - } - .close-btn { - background: none; - border: none; - cursor: pointer; - color: #b91c1c; - font-size: 1rem; - } - - /* ── Formular ────────────────────────────────────────── */ - .add-form { - display: flex; - gap: 0.5rem; - margin-bottom: 1.5rem; - } - .add-form input { - flex: 1; - padding: 0.6rem 0.8rem; - border: 1px solid #d1d5db; - border-radius: 8px; - font-size: 1rem; - outline: none; - transition: border-color 0.2s; - } - .add-form input:focus { - border-color: #2563eb; - } - .add-form button { - padding: 0.6rem 1.2rem; - background: #2563eb; - color: #fff; - border: none; - border-radius: 8px; - font-size: 1rem; - cursor: pointer; - white-space: nowrap; - transition: background 0.2s; - } - .add-form button:hover:not(:disabled) { - background: #1d4ed8; - } - .add-form button:disabled { - opacity: 0.5; - cursor: default; - } - - /* ── Ladeindikator ───────────────────────────────────── */ - .loading { - text-align: center; - color: #6b7280; - padding: 2rem; - } - - /* ── ToDo-Liste ──────────────────────────────────────── */ - .todo-list { - list-style: none; - margin: 0; - padding: 0; - display: flex; - flex-direction: column; - gap: 0.5rem; - } - .empty-state { - text-align: center; - color: #9ca3af; - padding: 2rem; - } - .todo-item { - display: flex; - align-items: center; - gap: 0.75rem; - padding: 0.75rem 1rem; - background: #fff; - border: 1px solid #e5e7eb; - border-radius: 8px; - transition: background 0.15s; - } - .todo-item:hover { - background: #f9fafb; - } - - /* Abgehaktes ToDo: Text wird durchgestrichen und ausgegraut */ - .todo-item.completed .todo-title { - text-decoration: line-through; - color: #9ca3af; - } - - .todo-item input[type="checkbox"] { - width: 1.1rem; - height: 1.1rem; - cursor: pointer; - flex-shrink: 0; - } - .todo-title { - flex: 1; - cursor: pointer; - } - .user-badge { - font-size: 0.7rem; - color: #6b7280; - background: #f3f4f6; - border-radius: 99px; - padding: 0.15rem 0.5rem; - white-space: nowrap; - } - .delete-btn { - background: none; - border: none; - color: #d1d5db; - font-size: 1rem; - cursor: pointer; - padding: 0.25rem; - line-height: 1; - border-radius: 4px; - transition: color 0.15s; - } - .delete-btn:hover { - color: #ef4444; - } - - /* ── Pagination ──────────────────────────────────────── */ - .pagination { - display: flex; - justify-content: center; - align-items: center; - gap: 1rem; - margin-top: 1.5rem; - } - .pagination button { - padding: 0.5rem 1rem; - border: 1px solid #d1d5db; - background: #fff; - border-radius: 8px; - cursor: pointer; - transition: background 0.15s; - } - .pagination button:hover:not(:disabled) { - background: #f3f4f6; - } - .pagination button:disabled { - opacity: 0.4; - cursor: default; - } - .page-info { - color: #6b7280; - font-size: 0.9rem; - } - `], + // Template und Styles sind ausgelagert für bessere Wartbarkeit + templateUrl: './app.component.html', + styleUrl: './app.component.css', }) export class AppComponent implements OnInit {