Files
hobbypj-contents/assets/css/home.css
T
Bkk1234 db7724b237 feat(home): link the homepage of every local project in the workspace
- server: GET /api/local-projects scans sibling folders for index.html
  (title from <title>/<h1>, generic titles fall back to the folder name,
  sorted by newest edit) and GET /projects/<folder>/ serves that folder
- both endpoints are loopback-only; node_modules/.git/.hermes blocked and
  path traversal rejected; WORKSPACE_DIR=none disables the feature
- home: new 'โปรเจคในเครื่อง' list (2 columns >=700px) that hides itself when
  the API is absent, so the live static site never shows fake rows
- SW skips /projects/* so other projects' files are never cached; version 2026.11.19.5
- docs: README/AGENTS/DESIGN cover the endpoints, the loopback rule and the layout
2026-11-20 14:26:54 +07:00

604 lines
13 KiB
CSS

/* ==========================================================================
home.css — หน้าแรก: ฮีโร่ + ช่องค้นหา + การ์ดโปรเจค
========================================================================== */
.hero {
position: relative;
overflow: hidden;
border: 1px solid var(--border);
border-radius: var(--radius-xl);
background:
radial-gradient(120% 140% at 12% 0%, #fff 0%, var(--brand-50) 46%, var(--brand-100) 100%);
padding: var(--space-8) var(--space-5);
}
.hero__inner {
position: relative;
z-index: 1;
max-width: 46rem;
}
.hero__eyebrow {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 6px 14px;
border-radius: var(--radius-pill);
background: #fff;
border: 1px solid var(--brand-200);
color: var(--brand-700);
font-size: 13px;
font-weight: 500;
}
.hero__eyebrow svg {
width: 15px;
height: 15px;
}
.hero__title {
margin-top: var(--space-3);
font-size: clamp(1.6rem, 1.15rem + 2.05vw, 2.5rem);
letter-spacing: -0.015em;
line-height: 1.35;
max-width: 24ch;
}
/* --------------------------------------------------- คำว่า hobbyproject */
.hero__wordmark {
margin-top: var(--space-4);
font-size: clamp(1.5rem, 1.15rem + 1.05vw, 2rem);
font-weight: 700;
line-height: 1.15;
letter-spacing: -0.02em;
}
.hero__wordmark .wm-dark {
color: var(--brand-900); /* 12.21:1 บนพื้นฮีโร่เข้มสุด */
}
.hero__wordmark .wm-light {
color: var(--brand-500); /* 3.12:1 — ผ่านเกณฑ์ large text (≥24px ตัวหนา) */
}
.hero__title em {
font-style: normal;
color: var(--brand-600);
}
.hero__lead {
margin-top: var(--space-3);
max-width: 44ch;
color: #4b3a30;
font-size: clamp(0.98rem, 0.94rem + 0.3vw, 1.08rem);
}
/* ------------------------------------------------------------- searchbar */
.searchbar {
margin-top: var(--space-6);
display: flex;
align-items: center;
gap: 8px;
padding: 8px;
border: 1px solid var(--border-strong);
border-radius: var(--radius-pill);
background: #fff;
box-shadow: var(--shadow-md);
max-width: 560px;
}
.searchbar:focus-within {
border-color: var(--brand-500);
box-shadow: 0 0 0 4px rgba(196, 112, 60, 0.16);
}
.searchbar__icon {
flex: none;
margin-left: 8px;
color: var(--brand-500);
}
.searchbar__icon svg {
width: 20px;
height: 20px;
}
.searchbar input {
flex: 1 1 auto;
min-width: 0;
border: 0;
background: transparent;
padding: 8px 0;
font-size: 15px;
}
.searchbar input:focus {
outline: none;
}
.searchbar input::placeholder {
color: #8d7d73;
}
.searchbar__clear {
flex: none;
display: inline-flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border: 0;
border-radius: 50%;
background: var(--brand-50);
color: var(--brand-700);
cursor: pointer;
}
.searchbar__clear[hidden] {
display: none;
}
.searchbar__clear svg {
width: 16px;
height: 16px;
}
.hero__meta {
margin-top: var(--space-5);
display: flex;
flex-wrap: wrap;
gap: var(--space-3) var(--space-6);
font-size: 14px;
color: var(--muted-foreground);
}
.hero__meta span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.hero__meta svg {
width: 16px;
height: 16px;
color: var(--brand-500);
}
/* --------------------------------------------------- ฮีโร่: การ์ดลอย (จอใหญ่) */
.hero__deco {
display: none;
}
@media (min-width: 1080px) {
.hero__deco {
display: flex;
flex-direction: column;
gap: 12px;
position: absolute;
top: 50%;
inset-inline-end: var(--space-10);
width: 302px;
transform: translateY(-50%);
pointer-events: none;
}
.hero__deco-card {
display: flex;
align-items: center;
gap: 10px;
padding: 12px 16px;
border: 1px solid var(--border-strong);
border-radius: var(--radius-md);
background: #fff;
box-shadow: var(--shadow-md);
font-size: 14px;
font-weight: 500;
color: var(--brand-900);
transform: translateX(calc(var(--i) * 14px)) rotate(calc((var(--i) - 1) * -0.8deg));
opacity: 0.97;
}
.hero__deco-card:nth-child(2) {
border-color: var(--brand-300);
}
.hero__deco-icon {
flex: none;
display: grid;
place-items: center;
width: 30px;
height: 30px;
border-radius: 9px;
background: var(--brand-50);
border: 1px solid var(--brand-200);
color: var(--brand-700);
}
.hero__deco-icon svg {
width: 17px;
height: 17px;
}
.hero__deco-name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
/* ---------------------------------------------------------------- chips */
.chips {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: var(--space-8);
}
.chip {
display: inline-flex;
align-items: center;
gap: 7px;
min-height: 40px;
padding: 8px 16px;
border: 1px solid var(--border);
border-radius: var(--radius-pill);
background: #fff;
color: var(--brand-800);
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition:
background 160ms var(--ease),
border-color 160ms var(--ease),
color 160ms var(--ease);
}
.chip:hover {
background: var(--brand-50);
border-color: var(--brand-300);
}
.chip[aria-pressed="true"] {
background: var(--brand-700);
border-color: var(--brand-700);
color: var(--on-brand);
}
.chip svg {
width: 16px;
height: 16px;
}
/* ------------------------------------------------------------- section */
.section-head {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: var(--space-4);
margin-top: var(--space-12);
margin-bottom: var(--space-5);
}
.section-head__title {
font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.4rem);
}
.section-head__sub {
margin-top: 4px;
font-size: 14px;
color: var(--muted-foreground);
}
.section-head__count {
flex: none;
font-size: 13px;
color: var(--brand-700);
background: var(--brand-100);
border-radius: var(--radius-pill);
padding: 5px 12px;
font-weight: 500;
white-space: nowrap;
}
/* ---------------------------------------------------------------- grid */
.project-grid {
display: grid;
gap: var(--space-4);
grid-template-columns: 1fr;
}
.project-card {
position: relative;
display: flex;
flex-direction: column;
gap: var(--space-3);
padding: var(--space-5);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
background: var(--surface);
transition:
border-color 180ms var(--ease),
box-shadow 180ms var(--ease),
transform 180ms var(--ease);
}
.project-card:hover,
.project-card:focus-within {
border-color: var(--brand-300);
box-shadow: var(--shadow-md);
/* ใช้ translate (คนละพร็อพเพอร์ตีกับ transform) เพื่อไม่ชนกับคีย์เฟรม reveal */
translate: 0 -3px;
}
.project-card__top {
display: flex;
align-items: flex-start;
gap: var(--space-3);
}
.project-card__icon {
flex: none;
display: grid;
place-items: center;
width: 46px;
height: 46px;
border-radius: 13px;
background: var(--brand-50);
border: 1px solid var(--brand-200);
color: var(--brand-700);
}
.project-card__icon svg {
width: 24px;
height: 24px;
}
.project-card__heading {
min-width: 0;
flex: 1 1 auto;
}
.project-card__name {
font-size: 1.02rem;
font-weight: 700;
color: var(--brand-900);
line-height: 1.35;
}
.project-card__name a {
color: inherit;
text-decoration: none;
}
.project-card__name a::after {
/* ขยายพื้นที่คลิกให้ครอบการ์ดทั้งใบ */
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
}
.project-card__name a:hover {
text-decoration: none;
}
.project-card__desc {
margin-top: 6px;
color: var(--muted-foreground);
font-size: 14.5px;
line-height: 1.55;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
.project-card__foot {
margin-top: auto;
padding-top: var(--space-3);
border-top: 1px solid var(--brand-50);
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--space-3);
}
.project-card__host {
font-size: 13px;
color: var(--muted-foreground);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.project-card__go {
flex: none;
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 14px;
font-weight: 500;
color: var(--brand-700);
pointer-events: none;
}
.project-card__go svg {
width: 16px;
height: 16px;
transition: transform 160ms var(--ease);
}
.project-card:hover .project-card__go svg {
transform: translateX(3px);
}
.badge {
position: absolute;
top: var(--space-4);
inset-inline-end: var(--space-4);
padding: 3px 10px;
border-radius: var(--radius-pill);
background: var(--brand-100);
color: var(--brand-800);
font-size: 12px;
font-weight: 500;
}
.project-card[draggable="true"] {
cursor: grab;
}
/* ------------------------------------------------ โปรเจคในเครื่อง (localhost) */
.local-section {
margin-top: var(--space-4);
}
.local-section[hidden] {
display: none;
}
.local-list {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: 8px;
}
.local-row__link {
display: flex;
align-items: center;
gap: var(--space-3);
min-height: 64px;
padding: 12px var(--space-4);
border: 1px solid var(--border);
border-radius: var(--radius-md);
background: var(--surface);
color: inherit;
text-decoration: none;
transition:
border-color 160ms var(--ease),
background 160ms var(--ease),
translate 160ms var(--ease);
}
.local-row__link:hover {
border-color: var(--brand-300);
background: var(--brand-50);
translate: 0 -1px;
text-decoration: none;
}
.local-row__icon {
flex: none;
display: grid;
place-items: center;
width: 34px;
height: 34px;
border-radius: 10px;
background: var(--brand-50);
border: 1px solid var(--brand-200);
color: var(--brand-700);
}
.local-row__icon svg {
width: 18px;
height: 18px;
}
.local-row__body {
flex: 1 1 auto;
min-width: 0;
display: flex;
flex-direction: column;
gap: 2px;
}
.local-row__title {
font-weight: 500;
color: var(--brand-900);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.local-row__meta {
font-size: 12.5px;
color: var(--muted-foreground);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.local-row__meta code {
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 11.5px;
background: var(--brand-50);
border: 1px solid var(--border);
border-radius: 5px;
padding: 0 5px;
}
.local-row__go {
flex: none;
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 13.5px;
font-weight: 500;
color: var(--brand-700);
}
.local-row__go svg {
width: 16px;
height: 16px;
transition: transform 160ms var(--ease);
}
.local-row__link:hover .local-row__go svg {
transform: translateX(3px);
}
@media (max-width: 560px) {
.local-row__go-text {
display: none;
}
}
@media (min-width: 700px) {
.local-list {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (prefers-reduced-motion: reduce) {
.local-row__link:hover {
translate: none;
}
}
/* ------------------------------------------------------------ empty state */
.empty {
margin-top: var(--space-4);
padding: var(--space-10) var(--space-5);
border: 1px dashed var(--border-strong);
border-radius: var(--radius-lg);
background: var(--surface-2);
text-align: center;
}
.empty__icon {
display: inline-grid;
place-items: center;
width: 48px;
height: 48px;
border-radius: 14px;
background: #fff;
border: 1px solid var(--brand-200);
color: var(--brand-600);
margin-bottom: var(--space-3);
}
.empty__icon svg {
width: 24px;
height: 24px;
}
.empty__title {
font-weight: 700;
color: var(--brand-900);
}
.empty__text {
margin-top: 6px;
color: var(--muted-foreground);
font-size: 14.5px;
}
/* -------------------------------------------------------- skeleton/loading */
.loading {
display: grid;
gap: var(--space-4);
grid-template-columns: 1fr;
margin-top: var(--space-4);
}
.skeleton {
height: 168px;
border-radius: var(--radius-lg);
border: 1px solid var(--border);
background: linear-gradient(100deg, var(--surface-2) 30%, #fff 50%, var(--surface-2) 70%);
background-size: 220% 100%;
animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer {
from {
background-position: 130% 0;
}
to {
background-position: -30% 0;
}
}
@media (min-width: 700px) {
.project-grid,
.loading {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.hero {
padding: var(--space-12) var(--space-10);
}
}
@media (min-width: 1000px) {
.project-grid,
.loading {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
@media (prefers-reduced-motion: reduce) {
.skeleton {
animation: none;
}
.project-card:hover,
.project-card:focus-within {
transform: none;
}
}