Skip to content

Commit

Permalink
🚧 リクエストを適用
Browse files Browse the repository at this point in the history
  • Loading branch information
wappon28dev committed Apr 14, 2024
1 parent 1174352 commit 4b92529
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 65 deletions.
10 changes: 5 additions & 5 deletions client/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable import/no-unresolved */
import { defineConfig } from "astro/config";
import react from "@astrojs/react";
import pandacss from "@pandacss/astro";
import sitemap from "@astrojs/sitemap";
import metaTags from "astro-meta-tags";
import icon from "astro-icon";
import pandacss from "@pandacss/astro";
import { defineConfig } from "astro/config";
import compress from "astro-compress";
import icon from "astro-icon";
import metaTags from "astro-meta-tags";

// https://astro.build/config
export default defineConfig({
Expand All @@ -30,7 +30,7 @@ export default defineConfig({
},
vite: {
optimizeDeps: {
exclude: "mock/*.json",
exclude: "*.json",
},
},
});
5 changes: 3 additions & 2 deletions client/src/components/HamburgerMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ export function HamburgerMenu({
left="0"
position="fixed"
style={{
clipPath: isOpened ? "inset(0 0 0 0)" : "inset(0 0 100% 0)",
opacity: isOpened ? 1 : 0,
display: isOpened ? "block" : "none",
backgroundColor: token(bgColor),
}}
transition="clip-path .3s ease-in-out"
transition="opacity .3s ease-in-out"
width="100%"
zIndex="header"
>
Expand Down
10 changes: 6 additions & 4 deletions client/src/components/VisualMain.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
detectMediaKey,
type MediaKey,
} from "@client/lib/middlewares/rewriters/convert2media";
import { inferImageSize } from "@client/lib/services/image";
import { modifySrc } from "@client/lib/services/media";
import { YouTube, Vimeo } from "astro-embed";
import { Image, getImage } from "astro:assets";
import { css } from "panda/css";
import { styled as p } from "panda/jsx";
import { inferImageSize } from "src/lib/services/image";
import { VideoPlayer } from "./VideoPlayer";
type Props = {
Expand All @@ -28,8 +28,10 @@ let imgSize: { width: number; height: number } = { height: 0, width: 0 };
const media = async (): Promise<void> => {
const ext = url.split(".").at(-1);
if (ext == null) throw new Error(`ext is null: ${url}`);
imgSize = inferImageSize(modifySrc(url));
key = detectMediaKey(ext);
if (key === "img") {
imgSize = inferImageSize(modifySrc(url));
}
};
const youtube = async (): Promise<void> => {
Expand Down Expand Up @@ -67,7 +69,7 @@ if (url.startsWith(INFO.site.assets)) {
<p.div
className={css({
"& > *": {
maxH: "67.5vh", // タイトルが見える高さ
maxH: "66vh", // タイトルが見える高さ
aspectRatio: "16 / 9",
margin: "0 auto",
},
Expand All @@ -89,7 +91,7 @@ if (url.startsWith(INFO.site.assets)) {
/>
);
case "video":
return <VideoPlayer autoPlay controls muted src={modifySrc(url)} />;
return <VideoPlayer autoPlay loop muted src={modifySrc(url)} />;
case "youtube":
return (
<YouTube
Expand Down
15 changes: 13 additions & 2 deletions client/src/components/VisualSub.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,25 @@ type Img = { url: string; width: number; height: number };
const { data } = Astro.props;
---

<VStack gap="5">
<VStack
gap={{
base: "5",
mdDown: "3",
}}
>
{
data.map((row, rowIdx) => {
const imgList = row.imgList as Img[];

return (
// eslint-disable-next-line react/no-array-index-key
<HStack key={rowIdx} gap="5">
<HStack
key={rowIdx}
gap={{
base: "5",
mdDown: "3",
}}
>
{imgList.map((img, columnIdx) => (
// eslint-disable-next-line react/no-array-index-key
<p.div key={columnIdx}>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/list/BlogsList.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Props = {
};
const { needOmit = false, ommitLength = 3 } = Astro.props;
const blogsList = await getContentList("blogs", { fields: ["id", "title"] });
const blogsList = await getContentList("blogs");
const omittable = blogsList.contents.length > ommitLength;
const contents =
Expand Down
9 changes: 5 additions & 4 deletions client/src/components/list/WorksList.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Image } from "astro:assets";
import { css } from "panda/css";
import { styled as p } from "panda/jsx";
const worksList = await getContentList("works", { fields: ["id", "title"] });
const worksList = await getContentList("works");
---

<p.div
Expand Down Expand Up @@ -40,9 +40,9 @@ const worksList = await getContentList("works", { fields: ["id", "title"] });
>
<Image
alt={title}
height={ogpImg.height}
src={ogpImg.url}
width={ogpImg.width}
height={ogpImg?.height ?? 180}
src={ogpImg?.url ?? "/assets/external/works/test/color_bar.png"}
width={ogpImg?.width ?? 320}
/>
<p.div
h="100%"
Expand All @@ -64,6 +64,7 @@ const worksList = await getContentList("works", { fields: ["id", "title"] });
{videoOnHover != null && (
<VideoPlayer
client:visible
loop
muted
playOnHover
src={modifySrc(videoOnHover)}
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/middlewares/rewrite-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function rewriteHTML(

// eslint-disable-next-line no-restricted-syntax
for await (const rewriter of writers) {
result = await rewriter(result);
result = await rewriter(result ?? "");
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/services/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import imageSize from "image-size";

/**
* NOTE: This fn is only used in server-side code (in `dev`/`build`);
* Do not use this in client-side code. (caused by `image-size`)
* Do not use this in client-side code. (due to `image-size`)
* @param path path WITHOUT leading slash
* @returns URL to the `/public` path
*/
Expand Down
65 changes: 34 additions & 31 deletions client/src/lib/services/microcms.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { MicroCMSQueries } from "microcms-js-sdk";
import { createClient } from "microcms-js-sdk";
import blogsDetail from "../../../public/assets/mock/blogs-detail.json";
import blogsList from "../../../public/assets/mock/blogs-list.json";
import worksDetail from "../../../public/assets/mock/works-detail.json";
import worksList from "../../../public/assets/mock/works-list.json";
import type { EndPoints } from "../types/cms-types";
import blogsDetail from "~/assets/mock/blogs-detail.json";
import blogsList from "~/assets/mock/blogs-list.json";
import worksDetail from "~/assets/mock/works-detail.json";
import worksList from "~/assets/mock/works-list.json";

export const microcms = createClient({
serviceDomain: import.meta.env.CLIENT_MICROCMS_SERVICE_DOMAIN,
Expand All @@ -13,40 +13,43 @@ export const microcms = createClient({

export async function getContentList<T extends keyof EndPoints["gets"]>(
key: T,
_queries: MicroCMSQueries = {},
queries: MicroCMSQueries = {},
): Promise<EndPoints["gets"][T]> {
switch (key) {
case "blogs":
return blogsList as any;
case "works":
return worksList as any;
default:
throw new Error("Invalid key");
if (process.env.NODE_ENV === "development") {
switch (key) {
case "blogs":
return blogsList as any;
case "works":
return worksList as any;
default:
throw new Error("Invalid key");
}
}

// return await microcms.get({
// endpoint: key,
// queries,
// });
return await microcms.get({
endpoint: key,
queries,
});
}

export async function getContentDetail<T extends keyof EndPoints["get"]>(
key: T,
_id: string,
_queries: MicroCMSQueries = {},
id: string,
queries: MicroCMSQueries = {},
): Promise<EndPoints["get"][T]> {
switch (key) {
case "blogs":
return blogsDetail as any;
case "works":
return worksDetail as any;
default:
throw new Error("Invalid key");
if (process.env.NODE_ENV === "development") {
switch (key) {
case "blogs":
return blogsDetail as any;
case "works":
return worksDetail as any;
default:
throw new Error("Invalid key");
}
}

// return await microcms.getListDetail<EndPoints["get"][T]>({
// endpoint: key,
// contentId: id,
// queries,
// });
return await microcms.getListDetail<EndPoints["get"][T]>({
endpoint: key,
contentId: id,
queries,
});
}
7 changes: 0 additions & 7 deletions client/src/lib/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ export const contentStyle = css({
m: "3",
overflowY: "auto",
maxHeight: "50vh",
"&::-webkit-scrollbar": {
h: "3px",
w: "3px",
},
"&::-webkit-scrollbar-thumb": {
bg: "9u-white",
},
},
},
"& p > code": {
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { VStack, styled as p } from "panda/jsx";
import { WorksListOmitted } from "src/components/list/WorksListOmitted";
import logoBg from "~/assets/images/logos/bg.svg";
const worksList = await getContentList("works", { fields: ["id", "title"] });
const worksList = await getContentList("works");
---

<BaseLayout
Expand Down
12 changes: 6 additions & 6 deletions client/src/pages/works/[id].astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "@client/lib/services/microcms";
import { contentStyle } from "@client/lib/style";
import type { GetStaticPaths } from "astro";
import { styled as p } from "panda/jsx";
import { VStack, styled as p } from "panda/jsx";
export const getStaticPaths = (async () => {
const worksList = await getContentList("works", { fields: "id" });
Expand Down Expand Up @@ -41,7 +41,7 @@ const modifiedContent = await rewriteHTML(content as string);
description,
}}
>
<p.div className="slide-in" pb="20" viewTransitionName="slide-in">
<VStack className="slide-in" gap="5" pb="20" viewTransitionName="slide-in">
<p.div
className="content"
display="flex"
Expand Down Expand Up @@ -85,10 +85,10 @@ const modifiedContent = await rewriteHTML(content as string);
>
{description}
</p.section>
<p.hr w="100%" />
<VisualSub data={visualSub} />
<p.hr w="100%" />
</p.div>
<p.article>
<VisualSub data={visualSub} />
</p.article>
<p.article className={contentStyle} set:html={modifiedContent} w="100%" />
</p.div>
</VStack>
</BaseLayout>
19 changes: 19 additions & 0 deletions client/src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,22 @@ lite-youtube,
lite-vimeo {
max-width: unset !important;
}

:not(.code-block > pre)::-webkit-scrollbar {
display: none;
}

.code-block > pre {
&::-webkit-scrollbar {
height: 5px;
width: 5px;
border-radius: 10px;
}
&::-webkit-scrollbar-thumb {
background-color: var(--colors-9u-white);
border-radius: 10px;
}
&::-webkit-scrollbar-corner {
display: none;
}
}

0 comments on commit 4b92529

Please sign in to comment.