Browse Source

Write HTML & CSS for subjects page

Eldar Mukhtarov 9 months ago
parent
commit
e7af4c0745

+ 244 - 0
project/frontend-angular/src/app/subjects/subjects.css

@@ -0,0 +1,244 @@
+/* Subjects Container */
+.subjects-container {
+  max-width: 800px;
+  margin: 0 auto;
+  padding: 0;
+}
+
+/* Section Styling */
+.add-subject-section {
+  background: linear-gradient(135deg, rgba(140, 35, 30, 0.1), rgba(255, 255, 255, 0.02));
+  border: 1px solid rgba(255, 255, 255, 0.1);
+  border-radius: 16px;
+  padding: 30px;
+  margin-bottom: 40px;
+}
+
+.subjects-list-section {
+  background: rgba(255, 255, 255, 0.02);
+  border: 1px solid rgba(255, 255, 255, 0.1);
+  border-radius: 16px;
+  padding: 30px;
+}
+
+.section-title {
+  font-size: 24px;
+  font-weight: 600;
+  color: #ffffff;
+  margin-bottom: 24px;
+  text-align: center;
+}
+
+/* Form Styling */
+.subject-form {
+  display: flex;
+  flex-direction: column;
+  gap: 20px;
+  max-width: 400px;
+  margin: 0 auto;
+}
+
+.form-group {
+  display: flex;
+  flex-direction: column;
+  gap: 8px;
+}
+
+.form-input {
+  background: rgba(255, 255, 255, 0.05);
+  border: 1px solid rgba(255, 255, 255, 0.1);
+  border-radius: 8px;
+  padding: 12px 16px;
+  font-size: 14px;
+  color: #ffffff;
+  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
+  transition: all 0.3s ease;
+}
+
+.form-input::placeholder {
+  color: #888;
+}
+
+.form-input:focus {
+  outline: none;
+  border-color: rgba(140, 35, 30, 0.5);
+  background: rgba(255, 255, 255, 0.08);
+  box-shadow: 0 0 0 2px rgba(140, 35, 30, 0.2);
+}
+
+.form-input:hover {
+  border-color: rgba(255, 255, 255, 0.2);
+  background: rgba(255, 255, 255, 0.08);
+}
+
+/* Button Styling */
+.btn-primary {
+  background: linear-gradient(135deg, #8C231E, #a52a24);
+  color: white;
+  border: none;
+  border-radius: 8px;
+  padding: 12px 24px;
+  font-size: 14px;
+  font-weight: 600;
+  cursor: pointer;
+  transition: all 0.3s ease;
+  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
+}
+
+.btn-primary:hover {
+  background: linear-gradient(135deg, #a52a24, #8C231E);
+  transform: translateY(-2px);
+  box-shadow: 0 4px 15px rgba(140, 35, 30, 0.4);
+}
+
+.btn-primary:active {
+  transform: translateY(0);
+}
+
+/* Form Actions */
+.form-actions {
+  display: flex;
+  flex-direction: column;
+  gap: 12px;
+  align-items: center;
+}
+
+/* Error Messages */
+.error-message {
+  color: #ff6b6b;
+  font-size: 13px;
+  font-weight: 500;
+  background: rgba(255, 107, 107, 0.1);
+  border: 1px solid rgba(255, 107, 107, 0.2);
+  border-radius: 6px;
+  padding: 8px 12px;
+  text-align: center;
+}
+
+/* Empty State */
+.empty-state {
+  text-align: center;
+  padding: 40px 20px;
+}
+
+.empty-message {
+  color: #888;
+  font-size: 16px;
+  font-style: italic;
+}
+
+/* Subjects Grid */
+.subjects-grid {
+  display: grid;
+  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
+  gap: 16px;
+  margin-top: 20px;
+}
+
+.subject-card {
+  background: rgba(255, 255, 255, 0.05);
+  border: 1px solid rgba(255, 255, 255, 0.1);
+  border-radius: 12px;
+  transition: all 0.3s ease;
+  overflow: hidden;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.subject-card:hover {
+  transform: translateY(-4px);
+  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
+  border-color: rgba(140, 35, 30, 0.3);
+  background: rgba(255, 255, 255, 0.08);
+}
+
+.subject-link {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  padding: 20px;
+  text-decoration: none;
+  color: inherit;
+  width: 100%;
+  height: 100%;
+  gap: 12px;
+}
+
+.subject-name {
+  font-size: 18px;
+  font-weight: 600;
+  color: #ffffff;
+  margin: 0;
+  flex: 1;
+  text-align: center;
+}
+
+.subject-arrow {
+  color: #888;
+  font-size: 20px;
+  font-weight: bold;
+  transition: all 0.3s ease;
+  opacity: 0.6;
+}
+
+.subject-card:hover .subject-arrow {
+  color: #8C231E;
+  opacity: 1;
+  transform: translateX(4px);
+}
+
+/* Responsive Design */
+@media (max-width: 768px) {
+  .subjects-container {
+    padding: 0 15px;
+  }
+
+  .add-subject-section,
+  .subjects-list-section {
+    padding: 20px;
+    margin-bottom: 24px;
+  }
+
+  .section-title {
+    font-size: 20px;
+    margin-bottom: 20px;
+  }
+
+  .subject-form {
+    max-width: 100%;
+  }
+
+  .subjects-grid {
+    grid-template-columns: 1fr;
+    gap: 12px;
+  }
+
+  .subject-card {
+    border-radius: 8px;
+  }
+
+  .subject-link {
+    padding: 16px;
+  }
+
+  .subject-name {
+    font-size: 16px;
+  }
+}
+
+/* Animation */
+.subjects-container {
+  animation: fadeIn 0.6s ease-in;
+}
+
+@keyframes fadeIn {
+  from {
+    opacity: 0;
+    transform: translateY(20px);
+  }
+  to {
+    opacity: 1;
+    transform: translateY(0);
+  }
+}

+ 37 - 28
project/frontend-angular/src/app/subjects/subjects.html

@@ -1,33 +1,42 @@
-<div>
-  <div>
-    <form name="form" (ngSubmit)="f.form.valid && addSubject()" #f="ngForm" novalidate>
-      <div>
-        <input type="text" name="name" placeholder="Name" [(ngModel)]="form.name" #name="ngModel" required />
-        @if (f.submitted && name.invalid) {
-          <div>Name is required</div>
-        }
+<div class="subjects-container">
+  <div class="add-subject-section">
+    <h1 class="section-title">Add New Subject</h1>
+    <form name="form" (ngSubmit)="f.form.valid && addSubject()" #f="ngForm" novalidate class="subject-form">
+      <div class="form-group">
+        <input 
+          type="text" 
+          name="name" 
+          placeholder="Subject Name" 
+          [(ngModel)]="form.name" 
+          #name="ngModel" 
+          required 
+          class="form-input"
+        />
+        <div class="error-message" *ngIf="f.submitted && name.invalid">
+          Name is required
+        </div>
       </div>
-      <div>
-        <button type="submit">Add subject</button>
-        @if (f.submitted && isAddFailed) {
-          <div>
-            Subject addition failed: {{ errorMessage }}
-          </div>
-        }
+      <div class="form-actions">
+        <button type="submit" class="btn-primary">Add Subject</button>
+        <div class="error-message" *ngIf="f.submitted && isAddFailed">
+          Subject addition failed: {{ errorMessage }}
+        </div>
       </div>
     </form>
-    <hr />
   </div>
-</div>
 
-<div>
-  <h2>Your subjects:</h2>
-  <div *ngIf="subjectList?.length === 0">You have no subjects yet</div>
-  <ul>
-    <li *ngFor="let subject of subjectList">
-      <a [routerLink]="['/subjects/', subject.id]">
-        <h2>{{ subject.name }}</h2>
-      </a>
-    </li>
-  </ul>
-</div>
+  <div class="subjects-list-section">
+    <h2 class="section-title">Your Subjects</h2>
+    <div class="empty-state" *ngIf="(subjectList?.length || 0) === 0">
+      <p class="empty-message">You have no subjects yet</p>
+    </div>
+    <div class="subjects-grid" *ngIf="(subjectList?.length || 0) > 0">
+      <div class="subject-card" *ngFor="let subject of subjectList">
+        <a [routerLink]="['/subjects/', subject.id]" class="subject-link">
+          <h3 class="subject-name">{{ subject.name }}</h3>
+          <div class="subject-arrow">→</div>
+        </a>
+      </div>
+    </div>
+  </div>
+</div>