diff --git a/src/api/graphql/setup.tsx b/src/api/graphql/setup.tsx index 1b9d140..56e67ee 100644 --- a/src/api/graphql/setup.tsx +++ b/src/api/graphql/setup.tsx @@ -4,7 +4,7 @@ import { Setupper, SetupperProps } from "../setup"; const apolloClient = new ApolloClient({ // TODO: Change this from the environment variable - uri: "http://localhost:8000", + uri: "http://localhost:8000/graphql", cache: new InMemoryCache(), }); diff --git a/src/comps/shared/AwaitFetch.tsx b/src/comps/shared/AwaitFetch.tsx new file mode 100644 index 0000000..93da5ec --- /dev/null +++ b/src/comps/shared/AwaitFetch.tsx @@ -0,0 +1,37 @@ +import React from "react"; + +import styles from "./AwaitFetch.module.scss"; +import { Emoji } from "./Emoji"; + +export type AwaitFetchProps = { + loading: boolean; + error?: Error; + data: NonNullable | undefined; + children: (data: NonNullable) => React.ReactElement; +}; + +// TypeScript recognizes as JSX tag, however it doesn't when "". +// (adding trail comma) +export const AwaitFetch = ({ + loading, + error, + data, + children, +}: AwaitFetchProps) => { + if (error) + return ( +

+ + 読み込みに失敗しました! +

+ ); + if (loading || data === undefined) + return ( +

+ + Loading... +

+ ); + + return children(data); +}; diff --git a/src/comps/shared/Emoji.module.scss b/src/comps/shared/Emoji.module.scss index 631afde..0c979a6 100644 --- a/src/comps/shared/Emoji.module.scss +++ b/src/comps/shared/Emoji.module.scss @@ -1,5 +1,9 @@ .emoji-default { - height: 1em; + display: inline-block; + height: 1.2em; + margin-right: 0.2em; + + vertical-align: middle; img { height: 100%; diff --git a/src/comps/shared/LogoImage.module.scss b/src/comps/shared/LogoImage.module.scss index f7a58be..ebf22d8 100644 --- a/src/comps/shared/LogoImage.module.scss +++ b/src/comps/shared/LogoImage.module.scss @@ -32,8 +32,8 @@ $pcpc-range: 10deg; &.enable-animation { animation: - 1.5s 0.75s ease-out text-appear-scale, - 0.75s 0.75s ease-out text-appear-opacity; + 1.5s 0.75s ease-out forwards text-appear-scale, + 0.75s 0.75s ease-out both text-appear-opacity; g[id="main-text"] { mask: url(#masker); diff --git a/src/pages/about/About.tsx b/src/pages/about/About.tsx index cc75481..99fc59c 100644 --- a/src/pages/about/About.tsx +++ b/src/pages/about/About.tsx @@ -3,8 +3,8 @@ import { PageWrapper } from "~/comps/layout/PageWrapper"; import { Heading } from "~/comps/shared/Heading"; import styles from "./About.module.scss"; -import { Avatar } from "./Avatar"; -import { Introduction } from "./Introduction"; +import { Avatar } from "./atoms/Avatar"; +import { Introduction } from "./organisms/Introduction"; export const About = () => ( diff --git a/src/pages/about/Introduction.tsx b/src/pages/about/Introduction.tsx deleted file mode 100644 index a5ba67d..0000000 --- a/src/pages/about/Introduction.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from "react"; - -import styles from "./Introduction.module.scss"; - -export const Introduction = () => ( -
-
- フライさん - Flisan / loxygen.K -
-
-
- 茨城工業高等専門学校 - 3 年 情報系 -
-
- 茨城工業高等専門学校 - 3 年 情報系 -
-
- フライさんです. -
-); diff --git a/src/pages/about/atoms/Affiriation.module.scss b/src/pages/about/atoms/Affiriation.module.scss new file mode 100644 index 0000000..2f01110 --- /dev/null +++ b/src/pages/about/atoms/Affiriation.module.scss @@ -0,0 +1,13 @@ +.element { + display: flex; + flex-direction: column; +} + +.location { + font-size: 1.25em; + font-weight: 700; +} + +.assign { + font-size: 0.85em; +} diff --git a/src/pages/about/atoms/Affiriation.tsx b/src/pages/about/atoms/Affiriation.tsx new file mode 100644 index 0000000..863341e --- /dev/null +++ b/src/pages/about/atoms/Affiriation.tsx @@ -0,0 +1,11 @@ +import React from "react"; +import { Affiliation as AffiliationEntity } from "~/api/graphql/autogen/scheme"; + +import styles from "./Affiriation.module.scss"; + +export const Affiliation: React.VFC = (props) => ( +
+ {props.location} + {props.assign} +
+); diff --git a/src/pages/about/Avatar.module.scss b/src/pages/about/atoms/Avatar.module.scss similarity index 100% rename from src/pages/about/Avatar.module.scss rename to src/pages/about/atoms/Avatar.module.scss diff --git a/src/pages/about/Avatar.tsx b/src/pages/about/atoms/Avatar.tsx similarity index 100% rename from src/pages/about/Avatar.tsx rename to src/pages/about/atoms/Avatar.tsx diff --git a/src/pages/about/controller.ts b/src/pages/about/controller.ts new file mode 100644 index 0000000..a21f4c4 --- /dev/null +++ b/src/pages/about/controller.ts @@ -0,0 +1,23 @@ +import { gql, useQuery } from "@apollo/client"; +import { Basic } from "~/api/graphql/autogen/scheme"; + +const fetchBasic = gql` + query FetchBasic { + basic { + name { + primary + aka + } + introduction + affiliation { + location + assign + } + age + } + } +`; +type FetchIntroductionResponse = { basic: Basic }; + +export const useBasicAPI = () => + useQuery(fetchBasic); diff --git a/src/pages/about/Introduction.module.scss b/src/pages/about/organisms/Introduction.module.scss similarity index 68% rename from src/pages/about/Introduction.module.scss rename to src/pages/about/organisms/Introduction.module.scss index 27fe315..d1b426c 100644 --- a/src/pages/about/Introduction.module.scss +++ b/src/pages/about/organisms/Introduction.module.scss @@ -1,15 +1,18 @@ @use "~/styling/color.module.scss"; @use "~/styling/font.module.scss"; -.wrapper { +%list { display: flex; flex-direction: column; +} + +.wrapper { + @extend %list; gap: 0.5em; } -.name, .affiriation { - display: flex; - flex-direction: column; +.name { + @extend %list; } .primary { @@ -20,15 +23,12 @@ line-height: 110%; } -.element { - display: flex; - flex-direction: column; -} - .aka { color: color.get-theme-color(text-color-secondary) } -.location { - font-size: 1.25em; +.affiriation { + @extend %list; + gap: 0.5em; } + diff --git a/src/pages/about/organisms/Introduction.tsx b/src/pages/about/organisms/Introduction.tsx new file mode 100644 index 0000000..e6681d5 --- /dev/null +++ b/src/pages/about/organisms/Introduction.tsx @@ -0,0 +1,31 @@ +import React from "react"; +import { AwaitFetch } from "~/comps/shared/AwaitFetch"; +import { Affiliation } from "../atoms/Affiriation"; +import { useBasicAPI } from "../controller"; + +import styles from "./Introduction.module.scss"; + +export const Introduction = () => { + const { loading, error, data } = useBasicAPI(); + + return ( + + {(data) => ( +
+
+ {data.basic.name.primary} + + {data.basic.name.aka.join(" / ")} + +
+
+ {data.basic.affiliation.map((a, key) => ( + + ))} +
+

{data.basic.introduction}

+
+ )} +
+ ); +}; diff --git a/src/pages/splash/Splash.tsx b/src/pages/splash/Splash.tsx index 9251a84..6552d90 100644 --- a/src/pages/splash/Splash.tsx +++ b/src/pages/splash/Splash.tsx @@ -1,7 +1,7 @@ import React from "react"; import { useHistory } from "react-router-dom"; import { combineClassName } from "~/utils/combineClassName"; -import { TypingEffect } from "./comps/TypingEffect"; +import { TypingEffect } from "./organisms/TypingEffect"; import styles from "./Splash.module.scss"; export const Splash = () => { diff --git a/src/pages/splash/comps/TypingEffect.tsx b/src/pages/splash/organisms/TypingEffect.tsx similarity index 100% rename from src/pages/splash/comps/TypingEffect.tsx rename to src/pages/splash/organisms/TypingEffect.tsx