Skip to content

Commit b71ddbb

Browse files
committed
a11y: support noscript, i18n: force Asia/Tokyo time
1 parent 0037c2d commit b71ddbb

File tree

5 files changed

+32
-22
lines changed

5 files changed

+32
-22
lines changed

bun.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"name": "website",
66
"dependencies": {
77
"@astrojs/mdx": "^4.1.0",
8+
"@date-fns/tz": "^1.2.0",
89
"@iconify-json/feather": "^1.2.1",
910
"@tailwindcss/typography": "^0.5.16",
1011
"astro": "^5.4.2",
@@ -81,6 +82,8 @@
8182

8283
"@biomejs/cli-win32-x64": ["@biomejs/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA=="],
8384

85+
"@date-fns/tz": ["@date-fns/[email protected]", "", {}, "sha512-LBrd7MiJZ9McsOgxqWX7AaxrDjcFVjWH/tIKJd7pnR7McaslGYOP1QmmiBXdJH/H/yLCT+rcQ7FaPBUxRGUtrg=="],
86+
8487
"@emmetio/abbreviation": ["@emmetio/[email protected]", "", { "dependencies": { "@emmetio/scanner": "^1.0.4" } }, "sha512-mgv58UrU3rh4YgbE/TzgLQwJ3pFsHHhCLqY20aJq+9comytTXUDNGG/SMtSeMJdkpxgXSXunBGLD8Boka3JyVA=="],
8588

8689
"@emmetio/css-abbreviation": ["@emmetio/[email protected]", "", { "dependencies": { "@emmetio/scanner": "^1.0.4" } }, "sha512-s9yjhJ6saOO/uk1V74eifykk2CBYi01STTK3WlXWGOepyKa23ymJ053+DNQjpFcy1ingpaO7AxCcwLvHFY9tuw=="],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"dependencies": {
2424
"@astrojs/mdx": "^4.1.0",
25+
"@date-fns/tz": "^1.2.0",
2526
"@iconify-json/feather": "^1.2.1",
2627
"@tailwindcss/typography": "^0.5.16",
2728
"astro": "^5.4.2",

src/components/LazyImage.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface Props {
1616
const props = Astro.props;
1717
---
1818

19-
<div class="skeleton">
19+
<div class="skeleton h-fit w-fit">
2020
<Picture
2121
loading={props.loading || "lazy"}
2222
{...props}

src/pages/index.astro

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import GlobalLayout from "../layouts/GlobalLayout.astro";
1111
import Hero from "../images/hero.jpg";
1212
import LabCafe from "../images/lab-cafe.jpg";
1313
import LogoGMOMedia from "../images/logo-gmo-media.png";
14-
import LazyImage from "../components/LazyImage.astro";
1514
import { Picture } from "astro:assets";
1615
---
1716

@@ -102,23 +101,23 @@ import { Picture } from "astro:assets";
102101
</section>
103102
<section class="bg-black py-80 text-white">
104103
<div
105-
class="mx-auto block items-center gap-12 px-8 xl:flex xl:flex-row-reverse 2xl:mx-16 2xl:gap-20"
104+
class="mx-auto block items-center justify-evenly gap-12 px-8 xl:flex xl:flex-row-reverse"
106105
>
107-
<LazyImage
106+
<Picture
107+
formats={["avif", "webp"]}
108108
alt=""
109109
src={LabCafe}
110-
width="1000"
111-
height="800"
112-
layout="fixed"
113-
class="mr-6 ml-auto hidden h-full w-full max-w-2xl flex-1 overflow-clip rounded-3xl object-cover md:block xl:mb-60 xl:max-w-3xl"
110+
layout="none"
111+
class="mr-6 ml-auto block max-w-[80%] min-w-0 flex-1 overflow-clip rounded-3xl object-cover md:max-w-2xl xl:mb-60 xl:max-w-xl"
114112
/>
115-
<article class="mt-12 self-center md:ml-12">
113+
<article class="mt-12 flex-shrink-0 self-center md:ml-12 lg:w-150">
116114
<h1 class="max-w-2xl text-4xl leading-snug sm:text-5xl md:text-6xl">
117115
<span
118116
id="text-future-software"
119117
class="mb-3 inline-block bg-white text-black"
120118
onmouseover="document.getElementById('text-future-software')?.setAttribute('data-highlighted', '');"
121119
tabindex="0"
120+
data-highlighted={true /* enable by default then immediately disable using JS s.t. it will show with noscript */}
122121
onfocus="document.getElementById('text-future-software')?.setAttribute('data-highlighted', '');"
123122
>未来の<wbr />ソフトウェア</span
124123
>を<br /><span>デザインしよう</span>
@@ -135,14 +134,15 @@ import { Picture } from "astro:assets";
135134
</article>
136135
<script>
137136
var text = document.getElementById("text-future-software");
137+
text?.removeAttribute("data-highlighted");
138138
document.onscroll = () => {
139139
if (!text) return;
140140
if (!document.scrollingElement) return;
141141
var screenTop = document.scrollingElement.scrollTop;
142142
var screenBottom = screenTop && +innerHeight;
143143
var textTop = text.getBoundingClientRect().top;
144144

145-
if (textTop < screenBottom - 500) {
145+
if (textTop < screenBottom - 400) {
146146
text.setAttribute("data-highlighted", "");
147147
}
148148
};
@@ -208,19 +208,20 @@ import { Picture } from "astro:assets";
208208
allow="picture-in-picture; web-share"
209209
allow-fullscreen></iframe>
210210
</section>
211-
<section class="bg-gray-50">
212-
<div class="container mx-auto px-8 py-24">
213-
<SectionHeader title="協賛企業様" />
214-
<div class="mt-8 flex flex-wrap items-center justify-center gap-4">
215-
<LazyImage
216-
size="small"
211+
<section class="bg-gray-50 py-24">
212+
<SectionHeader title="協賛企業様" />
213+
<ul
214+
class="mx-auto mt-8 flex flex-row flex-wrap items-center justify-center gap-16 px-24"
215+
>
216+
<li>
217+
<Picture
217218
alt="GMOメディア株式会社"
218219
src={LogoGMOMedia}
219-
width="400"
220-
height="600"
220+
class="object-contain"
221+
width="320"
221222
/>
222-
</div>
223-
</div>
223+
</li>
224+
</ul>
224225
</section>
225226
<section class="bg-gray-200">
226227
<div class="container mx-auto px-8 py-12">
@@ -264,7 +265,9 @@ import { Picture } from "astro:assets";
264265
no-repeat;
265266
transition: background-size 0.8s ease-in-out;
266267
}
267-
#text-future-software[data-highlighted] {
268+
#text-future-software[data-highlighted],
269+
#text-future-software:hover,
270+
#text-future-software:active {
268271
--bg-left: 100%;
269272
}
270273
}

src/schema.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { TZDate } from "@date-fns/tz";
12
import { type ImageFunction, reference } from "astro:content";
23
import { z } from "astro:schema";
34

@@ -9,7 +10,9 @@ export const CreateArticleSchema = ({ image }: { image: ImageFunction }) =>
910
z.object({
1011
// excerpt: z.string().nullable(),
1112
// longExcerpt: z.string().nullable(),
12-
date: z.date(),
13+
date: z
14+
.date()
15+
.transform((date) => new TZDate(date).withTimeZone("Asia/Tokyo")),
1316
slug: z.string().nullable(),
1417
title: z.string().nullable(),
1518
image: image(),

0 commit comments

Comments
 (0)