Skip to content

feat: Saving WIP of Lesson 26 #646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added lesson_22/ananatawa's folder/hero.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lesson_22/ananatawa's folder/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
228 changes: 228 additions & 0 deletions lesson_22/ananatawa's folder/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
/* Basic Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

html, body {
margin: 0;
padding: 0;
overflow-x: hidden; /* Prevents horizontal scroll */
width: 100vw; /* Ensures full-viewport fit */
}

body {
font-family: 'Poppins', 'Montserrat', sans-serif;
line-height: 1.6;
background-color: #ffffff;
color: #333;
}


.header {
position: fixed;
top: 0;
left: 0;
width: 100vw;
background-color: #ffffff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 40px 60px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
z-index: 1000;
transition: padding 0.3s ease, box-shadow 0.3s ease;
box-sizing: border-box;
}

.header.shrunk {
padding: 15px 60px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-logo img {
height: 75px;
}

.header-top-menu {
list-style: none;
display: flex;
gap: 20px;
}

.header-top-menu li a {
text-decoration: none;
color: #333;
font-weight: 600;
transition: color 0.3s ease;
}

.header-top-menu li a {
position: relative;
text-decoration: none;
color: #333;
font-weight: 600;
padding: 5px 0;
transition: color 0.3s ease;
}

.header-top-menu li a::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 0%;
height: 2px;
background-color: orange;
transition: width 0.3s ease;
}

/* Normal hover effect */
.header-top-menu li a:hover::after {
width: 100%;
}

/* New: Always underline the FIRST link (Home) */
.header-top-menu li:first-child a::after {
width: 100%;
}

.header-cta .sign-up-button {
background-color: #f37f0b;
color: #fff;
padding: 10px 20px;
text-decoration: none;
border-radius: 5px;
.btn-contact {
font-weight: 600;
font-family: 'Inter', sans-serif;
/* Optional matching styles: */
text-transform: uppercase;
letter-spacing: 0.05em;
}
transition: background-color 0.3s ease;
}

.header-cta .sign-up-button:hover {
background-color: #0056b3;
}

.main {
padding-top: 120px; /* So the hero and rest of page starts AFTER header */
padding-left: 0px;
padding-right: 0px;
}



.hero-section {
position: relative;
background-image: url("hero.jpg");
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
height: 100vh;
width: 100vw;
overflow: hidden;
filter: brightness(1.5);
padding-top: 125px; /* <-- NEW, creates white space under the header */
box-sizing: border-box;
}


.hero-overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.5);
}

.hero-content {
position: relative;
z-index: 2;
max-width: 800px;
}

.hero-title {
font-family: 'Poppins', sans-serif;
font-weight: 700;
font-size: 48px;
line-height: 1.2;
color: #ffffff;
text-align: left;
max-width: 600px; /* keeps the line breaks like the real site */
margin: 0 auto 0 0;

}

.highlight {
color: #ddff00; /* Gold Highlight */
}

.hero-text {
font-size: 1.2rem;
}

.programs-section {
margin-top: 60px;
text-align: center;
}

.programs-section h2 {
font-size: 2rem;
margin-bottom: 30px;
}

.programs {
list-style: none;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
padding: 0;
}

.program {
background-color: #f4f4f4;
padding: 20px;
border-radius: 8px;
transition: box-shadow 0.3s ease;
}

.program:hover {
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.program h3 {
margin-bottom: 10px;
font-size: 1.5rem;
}

.program p {
font-size: 1rem;
}

.footer {
background-color: #222;
color: #fff;
text-align: center;
padding: 20px;
margin-top: 40px;
}

.highlight {
color: inherit;
background-image: linear-gradient(to bottom, transparent 65%, #f37f0b 65%);
background-repeat: no-repeat;
background-size: 100% 100%;
}

.hero-content {
position: relative;
z-index: 2;
max-width: 800px;
margin-left: 60px;
margin-top: 100px; /* vertically aligns the hero-title */
}
Binary file added lesson_26.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void run(String[] args) throws Exception {

private void printLibraryInfo(Library library) {
LibraryInfo info = library.getInfo();
Map<UUID, Set<MediaItem>> checkedOutItemsByGuest = info.getCheckedOutItemsByGuest();
Map<UUID, Set<MediaItem>> checkedOutItemsByGuest = info.getCheckedOutItemsByGuestMap();
int numCheckedOutItems = checkedOutItemsByGuest.values().stream().mapToInt(Set::size).sum();
System.out.println();
System.out.println("========================================");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.codedifferently.lesson26.library;

import java.util.List;
import java.util.UUID;

/** Represents a librarian of a library. */
public class Librarian extends LibraryGuestBase {
public Librarian(String name, String email) {
Expand All @@ -10,4 +13,33 @@ public Librarian(String name, String email) {
public String toString() {
return "Librarian{" + "id='" + getEmail() + '\'' + ", name='" + getName() + '\'' + '}';
}

public MediaItem getItem(String id) {
try {
return getLibrary().findById(id);
} catch (Exception e) {
return null;
}
}

public void removeItem(String id) {
getLibrary().deleteById(id);
}

public MediaItem createItem(String title, String type, String genre, String author) {
UUID id = UUID.randomUUID();
MediaItem item;

switch (type.toLowerCase()) {
case "book" -> item = new Book(id, title, "1234567890", List.of(author), 100);
case "dvd" -> item = new Dvd(id, title);
case "magazine" -> item = new Magazine(id, title);
case "newspaper" -> item = new Newspaper(id, title);
default -> throw new IllegalArgumentException("Unknown media type: " + type);
}

item.setLibrary(getLibrary());
getLibrary().addItem(item);
return item;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public class Library {
*
* @param id The id of the library.
*/
public void addItem(MediaItem item) {
this.itemsById.put(item.getId(), item);
}

public Library(String id) {
this.id = id;
this.searcher = new CatalogSearcher(this.itemsById.values());
Expand Down Expand Up @@ -280,7 +284,7 @@ public LibraryInfo getInfo() {
.id(this.id)
.items(Collections.unmodifiableSet(new HashSet<>(this.itemsById.values())))
.guests(Collections.unmodifiableSet(new HashSet<>(this.guestsById.values())))
.checkedOutItemsByGuest(Collections.unmodifiableMap(itemsByGuest))
.checkedOutItemsByGuestMap(Collections.unmodifiableMap(itemsByGuest))
.build();
}

Expand All @@ -297,4 +301,13 @@ public String toString() {
+ guestsById
+ '}';
}

public MediaItem findById(String id) {
return itemsById.get(id);
}

public void deleteById(String id) {
UUID uuid = UUID.fromString(id);
itemsById.remove(uuid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
/** Base implementation of a library guest. */
public class LibraryGuestBase implements LibraryGuest {

private Library library;
protected Library library;
private final UUID id = UUID.randomUUID();
private final String name;
private final String email;

public Library getLibrary() {
return library;
}

public LibraryGuestBase(String name, String email) {
this.name = name;
this.email = email;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public class LibraryInfo {
public String id;
public Set<MediaItem> items;
public Set<LibraryGuest> guests;
public Map<UUID, Set<MediaItem>> checkedOutItemsByGuest;
public Map<UUID, Set<MediaItem>> checkedOutItemsByGuestMap;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
public class CreateMediaItemRequest {
@NotNull(message = "item is required") @Valid
private MediaItemRequest item;

public MediaItemRequest getItem() {
return item;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
package com.codedifferently.lesson26.web;

import com.codedifferently.lesson26.library.MediaItem;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CreateMediaItemResponse {
private MediaItemResponse item;
private UUID id;

public static CreateMediaItemResponse from(MediaItem item) {
return CreateMediaItemResponse.builder().id(item.getId()).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.codedifferently.lesson26.web;

import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class ErrorResponse {
private List<String> errors;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
@Data
@Builder
public class GetMediaItemsResponse {
@Singular private List<MediaItemResponse> items;
@Singular List<MediaItemResponse> items;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class MediaItemRequest {
@NotBlank(message = "Title is required")
private String title;

private String genre;
private String author;

private String[] authors;
private String edition;
private int pages;
Expand Down
Loading