Browse Source

Improved styling added red border to better visualize errors

nikolaik 2 weeks ago
parent
commit
906201e977

+ 4 - 0
src-angl/is/src/app/article-delete-button/article-delete-button.css

@@ -8,4 +8,8 @@
 .icon-btn:disabled {
     cursor: not-allowed;
     opacity: 0.5;
+}
+
+.delete{
+    color: red;
 }

+ 1 - 1
src-angl/is/src/app/article-delete-button/article-delete-button.html

@@ -1,6 +1,6 @@
 <button class="icon-btn" [disabled]="busy" (click)="delete()">
 	<i
 			class="fa-solid"
-			[ngClass]="busy ? 'fa-spinner fa-spin' : 'fa-trash-can'">
+			[ngClass]="busy ? 'fa-spinner fa-spin' : 'fa-trash-can delete'">
 	</i>
 </button>

+ 4 - 0
src-angl/is/src/app/article-edit-button/article-edit-button.css

@@ -3,4 +3,8 @@
     border: none;
     padding: 0;
     cursor: pointer;
+}
+
+.edit{
+    color: Dodgerblue;
 }

+ 1 - 1
src-angl/is/src/app/article-edit-button/article-edit-button.html

@@ -1,3 +1,3 @@
 <button class='icon-btn' [disabled]='busy' (click)="edit()">
-	<i class="fa-solid" [ngClass]="busy ? 'fa-spinner fa-spin' : 'fa-edit'"></i>
+	<i class="fa-solid" [ngClass]="busy ? 'fa-spinner fa-spin' : 'fa-edit edit'"></i>
 </button>

+ 54 - 1
src-angl/is/src/app/article-form/article-form.css

@@ -1,13 +1,58 @@
+.form-container{
+    margin-top: 5rem;
+}
+
 form{
     display: flex;
     flex-direction: column;
     width: 15rem;
     margin: 0 auto;
     border-radius: 25px;
-    background-color: turquoise;
+    box-shadow:
+            0 1px 2px rgba(0, 0, 0, 0.08),
+            0 2px 6px rgba(0, 0, 0, 0.12);
     padding: 2rem;
 }
 
+form input,
+form select {
+    border-radius: 3px;
+    height: 2rem;
+    box-sizing: border-box;
+}
+
+form select {
+    background-color: white;
+    border: 1px solid #8f8f9d;
+}
+
+form label {
+    color: grey;
+    margin-bottom: 0.1rem;
+}
+
+form input[type=text] {
+    outline: 2px solid transparent;
+    border: 1px solid #8f8f9d;
+    transition: outline-color 0.2s ease;
+    padding: 0.2rem 0.4rem;
+}
+
+form input[type=text]:focus {
+    outline: 2px solid #7ecfff;
+    outline-offset: -2px;
+}
+
+form input[type=submit] {
+    background-color: Dodgerblue;
+    color: white;
+    border: 1px solid #8f8f9d;
+}
+
+form input[type=submit]:hover {
+    background-color: #1EB6FF;
+}
+
 .form-header{
     text-align: center;
     margin: 0 0 1.5rem 0;
@@ -17,6 +62,14 @@ form{
     margin-bottom: 0.5rem;
 }
 
+.error-border {
+    border: 1px solid red !important;
+}
+
+.error-border:focus {
+    outline: 2px solid red !important;
+}
+
 
 .input-error{
     color: red;

+ 50 - 57
src-angl/is/src/app/article-form/article-form.html

@@ -1,60 +1,53 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-	<meta charset="UTF-8">
-	<title>Title</title>
-</head>
-<body>
-<form [formGroup]="articleForm" (ngSubmit)="handleSubmit()">
-	<h2 class="form-header">{{ title }} Article</h2>
-	<label>Title</label>
-	<input type="text" formControlName="title" required/>
-	<span class="input-error">
-		@if (formSubmitted && articleForm.controls.title.errors?.['required']) {
-			Please enter a title
-		}
+<div class="form-container">
+	<form [formGroup]="articleForm" (ngSubmit)="handleSubmit()">
+		<h2 class="form-header">{{ title }} Article</h2>
+		<label>Title:</label>
+		<input type="text" formControlName="title" required [ngClass]="{'error-border': (formSubmitted && articleForm.controls.title.errors?.['required']) || articleForm.controls.title.errors?.['invalidString']}">
+		<span class="input-error">
+			@if (formSubmitted && articleForm.controls.title.errors?.['required']) {
+				Please enter a title
+			}
 
-		@if (articleForm.controls.title.errors?.['invalidString']) {
-			Please ensure the title only contains letters
-		}
+			@if (articleForm.controls.title.errors?.['invalidString']) {
+				Please ensure the title only contains letters
+			}
+		</span>
+		<label>Text:</label>
+		<input type="text" formControlName="text" required [ngClass]="{'error-border': (formSubmitted && articleForm.controls.text.errors?.['required']) || articleForm.controls.text.errors?.['invalidString']}">
+		<span class="input-error">
+			@if (formSubmitted && articleForm.controls.text.errors?.['required']) {
+				Please enter a text
+			}
 
-	</span>
-	<label>Text</label>
-	<input type="text" formControlName="text" required/>
-	<span class="input-error">
-		@if (formSubmitted && articleForm.controls.text.errors?.['required']) {
-			Please enter a text
-		}
+			@if (articleForm.controls.text.errors?.['invalidString']) {
+				Please ensure the text only contains letters
+			}
+		</span>
+		<label>Category:</label>
+		<select id="categoryNames" formControlName="categoryName" required>
+			<option [value]="null" disabled>--Select a category--</option>
+			@for (cn of categoryNames; track cn) {
+				<option [value]="cn">{{ cn }}</option>
+			}
+		</select>
+		<span class="input-error">
+			@if (formSubmitted && articleForm.controls.categoryName.errors?.['required']) {
+				Please select a category
+			}
+		</span>
+		<label>Article Group:</label>
+		<select id="articleGroups" formControlName="articleGroupId">
+			<option [value]="null" disabled>--Select a Article Group--</option>
+			@for (ag of articleGroups$ | async; track ag.id) {
+				<option [value]="ag.id">{{ ag.name }}</option>
+			}
+		</select>
+		<span class="input-error">
+			@if (formSubmitted && articleForm.controls.articleGroupId.errors?.['required']) {
+				Please select a Article Group
+			}
+		</span>
+		<input type="submit" value='{{ submitButtonName }}'>
+	</form>
+</div>
 
-		@if (articleForm.controls.text.errors?.['invalidString']) {
-			Please ensure the text only contains letters
-		}
-	</span>
-	<label>Category</label>
-	<select id="categoryNames" formControlName="categoryName" required>
-		<option [value]="null" disabled>--Select a category--</option>
-		@for (cn of categoryNames; track cn) {
-			<option [value]="cn">{{ cn }}</option>
-		}
-	</select>
-	<span class="input-error">
-	@if (formSubmitted && articleForm.controls.categoryName.errors?.['required']) {
-		Please select a category
-	}
-	</span>
-	<label>Article Group</label>
-	<select id="articleGroups" formControlName="articleGroupId">
-		<option [value]="null" disabled>--Select a Article Group--</option>
-		@for (ag of articleGroups$ | async; track ag.id) {
-			<option [value]="ag.id">{{ ag.name }}</option>
-		}
-	</select>
-	<span class="input-error">
-	@if (formSubmitted && articleForm.controls.articleGroupId.errors?.['required']) {
-		Please select a Article Group
-	}
-	</span>
-	<input type="submit" value='{{ submitButtonName }}'>
-</form>
-</body>
-</html>

+ 3 - 2
src-angl/is/src/app/article-form/article-form.ts

@@ -1,5 +1,5 @@
 import { Component, EventEmitter, inject, Input, OnInit, Output } from '@angular/core';
-import { AsyncPipe } from '@angular/common';
+import { AsyncPipe, NgClass } from '@angular/common';
 import { DataService } from '../data-service';
 import { Observable } from 'rxjs';
 import {  CategoryName } from '../bo/article';
@@ -13,7 +13,8 @@ import { FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators }
 	imports: [
 		AsyncPipe,
 		FormsModule,
-		ReactiveFormsModule
+		ReactiveFormsModule,
+		NgClass
 	]
 })
 export class ArticleForm implements OnInit {

+ 0 - 9
src-angl/is/src/app/articles/articles.html

@@ -1,10 +1,3 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-	<meta charset="UTF-8">
-	<title>Title</title>
-</head>
-<body>
 <div>
 	<table>
 		<tr>
@@ -33,5 +26,3 @@
 	</table>
 	<is-app-floatButton/>
 </div>
-</body>
-</html>

+ 6 - 3
src-angl/is/src/app/float-button/float-button.css

@@ -6,11 +6,14 @@
 }
 
 .float-button {
-    border: 1px solid black;
+    border: none;
+    box-shadow:
+            0 1px 2px rgba(0, 0, 0, 0.08),
+            0 2px 6px rgba(0, 0, 0, 0.12);
     border-radius: 50%;
     width: 30px;
     height: 30px;
-    background-color: turquoise;
-    color: black;
+    background-color: green;
+    color: white;
     cursor: pointer;
 }