|
| 1 | +--- |
| 2 | +import { formatDate } from "../../utils"; |
| 3 | +
|
| 4 | +interface Props { |
| 5 | + title: string; |
| 6 | + description: string; |
| 7 | + date: Date; |
| 8 | + image?: string; |
| 9 | + href: string; |
| 10 | + category: string; |
| 11 | + tags?: string[]; |
| 12 | +} |
| 13 | +
|
| 14 | +const { |
| 15 | + title, |
| 16 | + description, |
| 17 | + date, |
| 18 | + image, |
| 19 | + href, |
| 20 | + tags = [], |
| 21 | + category, |
| 22 | +} = Astro.props; |
| 23 | +--- |
| 24 | + |
| 25 | +<div class="story-card-horizontal group"> |
| 26 | + {/* Main Link Overlay */} |
| 27 | + <a href={href} class="story-cover-link" aria-label={`Read ${title}`}> |
| 28 | + <span class="sr-only">Read Story</span> |
| 29 | + </a> |
| 30 | + |
| 31 | + <div class="image-container"> |
| 32 | + { |
| 33 | + image ? ( |
| 34 | + <img src={image} alt={title} loading="lazy" /> |
| 35 | + ) : ( |
| 36 | + <div class="pattern-fallback" aria-hidden="true"> |
| 37 | + <div class="logo-fallback"> |
| 38 | + CIVIC |
| 39 | + <br /> |
| 40 | + Thesis |
| 41 | + </div> |
| 42 | + </div> |
| 43 | + ) |
| 44 | + } |
| 45 | + </div> |
| 46 | + <div class="content"> |
| 47 | + <div class="meta-top"> |
| 48 | + {category && <span class="category-tag">{category}</span>} |
| 49 | + <!-- <time datetime={date.toISOString()}>{formatDate(date)}</time> --> |
| 50 | + </div> |
| 51 | + |
| 52 | + <h3 class="title">{title}</h3> |
| 53 | + </div> |
| 54 | +</div> |
| 55 | + |
| 56 | +<style> |
| 57 | + .story-card-horizontal { |
| 58 | + display: flex; |
| 59 | + flex-direction: row; |
| 60 | + background: var(--color-surface); |
| 61 | + border-radius: 12px; |
| 62 | + overflow: hidden; |
| 63 | + position: relative; |
| 64 | + transition: |
| 65 | + transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), |
| 66 | + box-shadow 0.4s ease, |
| 67 | + border-color 0.3s ease; |
| 68 | + border: 1px solid var(--color-border); |
| 69 | + height: 100%; /* Fill grid cell */ |
| 70 | + min-height: 140px; |
| 71 | + /* Override accent color */ |
| 72 | + --card-accent: #d97706; |
| 73 | + } |
| 74 | + |
| 75 | + .story-card-horizontal:hover { |
| 76 | + border-color: var(--card-accent); |
| 77 | + /* background-color: var(--color-surface-offset, #f9fafb); */ |
| 78 | + z-index: 10; |
| 79 | + transform: translateY(-2px); |
| 80 | + } |
| 81 | + |
| 82 | + .story-cover-link { |
| 83 | + position: absolute; |
| 84 | + inset: 0; |
| 85 | + z-index: 1; |
| 86 | + } |
| 87 | + |
| 88 | + .image-container { |
| 89 | + position: relative; |
| 90 | + width: 35%; /* Fixed width for image part */ |
| 91 | + min-width: 120px; |
| 92 | + max-width: 200px; |
| 93 | + flex-shrink: 0; |
| 94 | + overflow: hidden; |
| 95 | + z-index: 2; |
| 96 | + pointer-events: none; |
| 97 | + } |
| 98 | + |
| 99 | + .image-container img { |
| 100 | + width: 100%; |
| 101 | + height: 100%; |
| 102 | + object-fit: cover; |
| 103 | + transition: transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94); |
| 104 | + } |
| 105 | + |
| 106 | + .story-card-horizontal:hover .image-container img { |
| 107 | + transform: scale(1.05); |
| 108 | + } |
| 109 | + |
| 110 | + .pattern-fallback { |
| 111 | + width: 100%; |
| 112 | + height: 100%; |
| 113 | + background-color: var(--color-surface-offset, #f3f4f6); |
| 114 | + display: flex; |
| 115 | + align-items: center; |
| 116 | + justify-content: center; |
| 117 | + position: relative; |
| 118 | + } |
| 119 | + |
| 120 | + .logo-fallback { |
| 121 | + font-family: var(--font-heading); |
| 122 | + font-weight: 900; |
| 123 | + font-size: 1rem; |
| 124 | + line-height: 1; |
| 125 | + text-align: center; |
| 126 | + color: var(--color-text-muted); |
| 127 | + opacity: 0.2; |
| 128 | + transform: rotate(-10deg); |
| 129 | + text-transform: uppercase; |
| 130 | + pointer-events: none; |
| 131 | + } |
| 132 | + |
| 133 | + .content { |
| 134 | + padding: 1.25rem; |
| 135 | + display: flex; |
| 136 | + flex-direction: column; |
| 137 | + justify-content: center; /* Center content vertically */ |
| 138 | + gap: 0.5rem; |
| 139 | + flex-grow: 1; |
| 140 | + position: relative; |
| 141 | + z-index: 2; |
| 142 | + pointer-events: none; |
| 143 | + } |
| 144 | + |
| 145 | + .meta-top { |
| 146 | + display: flex; |
| 147 | + justify-content: space-between; |
| 148 | + align-items: center; |
| 149 | + font-size: 0.75rem; |
| 150 | + margin-bottom: 0.25rem; |
| 151 | + } |
| 152 | + |
| 153 | + .category-tag { |
| 154 | + font-family: var(--font-mono); |
| 155 | + color: var(--card-accent); |
| 156 | + font-weight: 700; |
| 157 | + text-transform: uppercase; |
| 158 | + letter-spacing: 0.05em; |
| 159 | + font-size: 0.7rem; |
| 160 | + } |
| 161 | + |
| 162 | + time { |
| 163 | + color: var(--color-text-muted); |
| 164 | + } |
| 165 | + |
| 166 | + .title { |
| 167 | + font-family: var(--font-carrois); |
| 168 | + font-size: 1.2rem; |
| 169 | + font-weight: 700; |
| 170 | + line-height: 1.3; |
| 171 | + margin: 0; |
| 172 | + color: var(--color-heading); |
| 173 | + transition: color 0.2s ease; |
| 174 | + /* Limit to 3 lines */ |
| 175 | + display: -webkit-box; |
| 176 | + -webkit-line-clamp: 3; |
| 177 | + -webkit-box-orient: vertical; |
| 178 | + overflow: hidden; |
| 179 | + } |
| 180 | + |
| 181 | + .story-card-horizontal:hover .title { |
| 182 | + color: var(--card-accent); |
| 183 | + } |
| 184 | + |
| 185 | + @media (max-width: 480px) { |
| 186 | + /* On very small screens, maybe just reduce padding */ |
| 187 | + .content { |
| 188 | + padding: 1rem; |
| 189 | + } |
| 190 | + .image-container { |
| 191 | + width: 30%; |
| 192 | + } |
| 193 | + .title { |
| 194 | + font-size: 1rem; |
| 195 | + } |
| 196 | + } |
| 197 | +</style> |
0 commit comments