Skip to content

Commit

Permalink
♻️ refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
yutakobayashidev committed Jul 20, 2023
1 parent d9e8f2b commit bf87bc2
Show file tree
Hide file tree
Showing 20 changed files with 728 additions and 610 deletions.
73 changes: 37 additions & 36 deletions frontend/prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

async function main() {
Expand Down Expand Up @@ -58,113 +59,113 @@ async function main() {
name: "自由民主党",
description:
"自由民主党(じゆうみんしゅとう、英: Liberal Democratic Party、英文略称: LDP[ / Lib Dems)は、日本の政党。自由主義を掲げ、つねに改革を進める保守政党を標榜している。",
facebook: "jimin.official",
image:
"https://pbs.twimg.com/profile_images/1532645750521606145/CQPpEZtc_400x400.jpg",
facebook: "jimin.official",
twitter: "jimin_koho",
website: "https://www.jimin.jp/",
wikipedia:
"https://ja.wikipedia.org/wiki/%E8%87%AA%E7%94%B1%E6%B0%91%E4%B8%BB%E5%85%9A_(%E6%97%A5%E6%9C%AC)",
website: "https://www.jimin.jp/",
},
{
id: "RIKKEN",
name: "立憲民主党",
website: "https://cdp-japan.jp/",
image:
"https://pbs.twimg.com/profile_images/1311187310852022272/8TOEuyf-_400x400.jpg",
description:
"立憲民主党(りっけんみんしゅとう、英: The Constitutional Democratic Party of Japan、略称: CDP)は、日本の政党。立憲主義に基づく民主政治を綱領に掲げる、リベラル政党である。",
facebook: "rikkenminshu",
image:
"https://pbs.twimg.com/profile_images/1311187310852022272/8TOEuyf-_400x400.jpg",
twitter: "CDP2017",
website: "https://cdp-japan.jp/",
wikipedia:
"https://ja.wikipedia.org/wiki/%E7%AB%8B%E6%86%B2%E6%B0%91%E4%B8%BB%E5%85%9A_(%E6%97%A5%E6%9C%AC_2020)",
},
{
id: "KOMEI",
name: "公明党",
website: "https://www.komei.or.jp/",
twitter: "komei_koho",
description:
"公明党は、日本の政党。宗教団体の創価学会を支持母体として中道政治の実現を目指して結成された。 略称は公明。1字表記の際は公。現在の党キャッチコピーは、「小さな声を、聴く力。」。 1999年10月5日から2009年9月16日まで、および2012年12月26日から現在まで自由民主党と自公連立政権を構成している。",
facebook: "komeito",
wikipedia:
"https://ja.wikipedia.org/wiki/%E5%85%AC%E6%98%8E%E5%85%9A#:~:text=%E5%85%AC%E6%98%8E%E5%85%9A%E3%81%AF%E3%80%81%E8%B1%8A%E3%81%8B%E3%81%AA%E3%82%8B%E4%BA%BA%E9%96%93,%E3%81%AE%E5%A4%A7%E8%A1%86%E6%94%BF%E5%85%9A%E3%81%A7%E3%81%82%E3%82%8B%E3%80%82",
image:
"https://pbs.twimg.com/profile_images/1371640641873084417/vQuhD0GE_400x400.jpg",
description:
"公明党は、日本の政党。宗教団体の創価学会を支持母体として中道政治の実現を目指して結成された。 略称は公明。1字表記の際は公。現在の党キャッチコピーは、「小さな声を、聴く力。」。 1999年10月5日から2009年9月16日まで、および2012年12月26日から現在まで自由民主党と自公連立政権を構成している。",
twitter: "komei_koho",
website: "https://www.komei.or.jp/",
wikipedia:
"https://ja.wikipedia.org/wiki/%E5%85%AC%E6%98%8E%E5%85%9A#:~:text=%E5%85%AC%E6%98%8E%E5%85%9A%E3%81%AF%E3%80%81%E8%B1%8A%E3%81%8B%E3%81%AA%E3%82%8B%E4%BA%BA%E9%96%93,%E3%81%AE%E5%A4%A7%E8%A1%86%E6%94%BF%E5%85%9A%E3%81%A7%E3%81%82%E3%82%8B%E3%80%82",
},
{
id: "KYOSAN",
name: "日本共産党",
website: "https://www.jcp.or.jp",
twitter: "jcp_cc",
description:
"日本共産党は、日本の政党。科学的社会主義を理論的基礎とする社会主義・共産主義政党である。 略称は「JCP」。日本国内では単に「共産党」、「共産」と呼ばれる。「日共」とも。1字表記の際は、「共」と表記される。",
facebook: "kyosanto",
wikipedia:
"https://ja.wikipedia.org/wiki/%E6%97%A5%E6%9C%AC%E5%85%B1%E7%94%A3%E5%85%9A",
image:
"https://pbs.twimg.com/profile_images/920124778182144000/2NzWLV_Q_400x400.jpg",
description:
"日本共産党は、日本の政党。科学的社会主義を理論的基礎とする社会主義・共産主義政党である。 略称は「JCP」。日本国内では単に「共産党」、「共産」と呼ばれる。「日共」とも。1字表記の際は、「共」と表記される。",
twitter: "jcp_cc",
website: "https://www.jcp.or.jp",
wikipedia:
"https://ja.wikipedia.org/wiki/%E6%97%A5%E6%9C%AC%E5%85%B1%E7%94%A3%E5%85%9A",
},
{
id: "ISHIN",
name: "日本維新の会",
website: "https://o-ishin.jp",
twitter: "osaka_ishin",
description:
"日本維新の会は、日本の政党。行政改革や憲法改正、規制改革、機会平等、地方分権などを政策に掲げる保守政党である 。 略称は「維新」、1字表記は「維」。 自公連立政権に対しては、是々非々の立場を取っている。そのため、立憲民主党をはじめとするいわゆる野党共闘とは距離を置いており、これらの野党を批判することも多い。",
facebook: "nipponishinnokai",
wikipedia:
"https://ja.wikipedia.org/wiki/%E6%97%A5%E6%9C%AC%E7%B6%AD%E6%96%B0%E3%81%AE%E4%BC%9A_(2016-)",
image:
"https://pbs.twimg.com/profile_images/919020416076677120/yaugkUxG_400x400.jpg",
description:
"日本維新の会は、日本の政党。行政改革や憲法改正、規制改革、機会平等、地方分権などを政策に掲げる保守政党である 。 略称は「維新」、1字表記は「維」。 自公連立政権に対しては、是々非々の立場を取っている。そのため、立憲民主党をはじめとするいわゆる野党共闘とは距離を置いており、これらの野党を批判することも多い。",
twitter: "osaka_ishin",
website: "https://o-ishin.jp",
wikipedia:
"https://ja.wikipedia.org/wiki/%E6%97%A5%E6%9C%AC%E7%B6%AD%E6%96%B0%E3%81%AE%E4%BC%9A_(2016-)",
},
{
id: "KOKUMIN",
name: "国民民主党",
twitter: "DPFPnews",
website: "https://new-kokumin.jp",
description:
"国民民主党は、日本の政党。穏健保守からリベラルまでを包摂する中道政党である。 公職選挙法における略称は「民主党」。マスメディアでは、「国民民主」、「国民」。 旧・立憲民主党と旧・国民民主党の合流の際に、玉木雄一郎らを中心とする合流に参加しない国民民主党の一部の議員により2020年に結党された。",
facebook: "democratic.party.for.the.people",
image:
"https://pbs.twimg.com/profile_images/1060713235500814337/hNsdccnL_400x400.jpg",
description:
"国民民主党は、日本の政党。穏健保守からリベラルまでを包摂する中道政党である。 公職選挙法における略称は「民主党」。マスメディアでは、「国民民主」、「国民」。 旧・立憲民主党と旧・国民民主党の合流の際に、玉木雄一郎らを中心とする合流に参加しない国民民主党の一部の議員により2020年に結党された。",
twitter: "DPFPnews",
website: "https://new-kokumin.jp",
},
{
id: "REIWA",
name: "れいわ新選組",
twitter: "reiwashinsen",
website: "https://reiwa-shinsengumi.com",
description:
"れいわ新選組は、日本の政党。略称はれいわ。 2019年4月1日に元俳優で当時参議院議員であった山本太郎が設立した政党である。 同年7月の第25回参議院議員選挙比例区で得票率2%を上回り、設立から約3か月半で公職選挙法が規定する政党要件を満たした。",
facebook: "reiwa.shinsengumi",
image:
"https://pbs.twimg.com/profile_images/1326482970765484032/YHpERFmF_400x400.jpg",
description:
"れいわ新選組は、日本の政党。略称はれいわ。 2019年4月1日に元俳優で当時参議院議員であった山本太郎が設立した政党である。 同年7月の第25回参議院議員選挙比例区で得票率2%を上回り、設立から約3か月半で公職選挙法が規定する政党要件を満たした。",
twitter: "reiwashinsen",
website: "https://reiwa-shinsengumi.com",
},
];

for (const group of groups) {
await prisma.group.upsert({
where: { id: group.id as any },
create: {
id: group.id as any,
name: group.name,
website: group.website,
description: group.description,
image: group.image,
facebook: group.facebook,
image: group.image,
twitter: group.twitter,
website: group.website,
wikipedia: group.wikipedia,
},
update: {
id: group.id as any,
name: group.name,
website: group.website,
description: group.description,
image: group.image,
facebook: group.facebook,
image: group.image,
twitter: group.twitter,
website: group.website,
wikipedia: group.wikipedia,
},
where: { id: group.id as any },
});
}

Expand Down
217 changes: 85 additions & 132 deletions frontend/src/app/_components/BottomMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,145 +12,98 @@ import {
SearchIcon,
} from "@xpadev-net/designsystem-icons";
import cn from "classnames";
import type { Route } from "next";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { FC } from "react";

export default function MobileFooter() {
interface LinkIconItemProps {
Icon: FC<{ className: string; fill: string; height: string; width: string }>;
label: string;
OutlinedIcon: FC<{
className: string;
fill: string;
height: string;
width: string;
}>;
path: Route<string> | URL;
}

const LinkIconItem: FC<LinkIconItemProps> = ({
Icon,
label,
OutlinedIcon,
path,
}) => {
let pathname = usePathname() || "/";

return (
<li className="table-cell text-center">
<Link
href={path}
className={cn(
"flex pb-1.5 pt-2 flex-col font-bold overflow-hidden whitespace-nowrap",
{
"text-gray-400": pathname !== path,
"text-primary": pathname === path,
}
)}
>
{pathname === path ? (
<Icon
width="1em"
height="1em"
fill="currentColor"
className="text-primary inline-block w-auto text-2xl"
/>
) : (
<OutlinedIcon
width="1em"
height="1em"
fill="currentColor"
className="inline-block w-auto text-2xl text-gray-400"
/>
)}
<span className="mt-1">{label}</span>
</Link>
</li>
);
};

export default function MobileFooter() {
return (
<div className="block md:hidden">
<ul className="z-99 fixed bottom-0 left-0 m-0 table w-full table-fixed border bg-white">
<li className="table-cell text-center">
<Link
href="/"
className={cn(
"flex pb-1.5 pt-2 flex-col font-bold overflow-hidden whitespace-nowrap",
{
"text-gray-400": pathname !== "/",
"text-primary": pathname === "/",
}
)}
>
{pathname === "/" ? (
<HouseIcon
width="1em"
height="1em"
fill="currentColor"
className="inline-block w-auto text-2xl text-primary"
/>
) : (
<HouseOutlinedIcon
width="1em"
height="1em"
fill="currentColor"
className="inline-block w-auto text-2xl text-gray-400"
/>
)}
<span className="mt-1">ホーム</span>
</Link>
</li>
<li className="table-cell text-center">
<Link
href="/face"
className={cn(
"flex flex-col pb-1.5 pt-2 font-bold overflow-hidden whitespace-nowrap",
{
"text-gray-400": pathname !== "/face",
"text-primary": pathname === "/face",
}
)}
>
{pathname === "/face" ? (
<ChildIcon
width="1em"
height="1em"
fill="currentColor"
className="inline-block w-auto text-2xl text-primary"
/>
) : (
<ChildOutlinedIcon
width="1em"
height="1em"
fill="currentColor"
className="inline-block w-auto text-2xl text-gray-400"
/>
)}
<span className="mt-1">顔認識</span>
</Link>
</li>
<li className="table-cell text-center">
<Link
href="/chat"
className={cn(
"flex pb-1.5 pt-2 flex-col font-bold overflow-hidden whitespace-nowrap",
{
"text-gray-400": pathname !== "/chat",
"text-primary": pathname === "/chat",
}
)}
>
{pathname === "/chat" ? (
<InboxIcon
width="1em"
height="1em"
fill="currentColor"
className="inline-block w-auto text-2xl text-primary"
/>
) : (
<InboxOutlinedIcon
width="1em"
height="1em"
fill="currentColor"
className="inline-block w-auto text-2xl text-gray-400"
/>
)}
<span className="mt-1">チャット</span>
</Link>
</li>
<li className="table-cell text-center">
<Link
href="/topics"
className={cn(
"pb-1.5 pt-2 flex flex-col font-bold overflow-hidden whitespace-nowrap",
{
"text-gray-400": pathname !== "/topics",
"text-primary": pathname === "/topics",
}
)}
>
{pathname === "/topics" ? (
<SealCertificateIcon
width="1em"
height="1em"
fill="currentColor"
className="inline-block w-auto text-2xl text-primary"
/>
) : (
<SealCertificateOutlinedIcon
width="1em"
height="1em"
fill="currentColor"
className="inline-block w-auto text-2xl text-gray-400"
/>
)}
<span className="mt-1">トピック</span>
</Link>
</li>
<li className="table-cell text-center">
<button
onClick={() => alert("Coming soon!")}
className="inline-flex flex-col overflow-hidden whitespace-nowrap pb-1.5 pt-2 font-bold text-gray-400"
>
<SearchIcon
width="1em"
height="1em"
fill="currentColor"
className="inline-block w-auto text-2xl text-gray-400"
/>
<span className="mt-1">検索</span>
</button>
</li>
<ul className="fixed bottom-0 left-0 z-50 m-0 table w-full table-fixed border bg-white">
<LinkIconItem
path="/"
label="ホーム"
Icon={HouseIcon}
OutlinedIcon={HouseOutlinedIcon}
/>
<LinkIconItem
path="/face"
label="顔認識"
Icon={ChildIcon}
OutlinedIcon={ChildOutlinedIcon}
/>
<LinkIconItem
path="/chat"
label="チャット"
Icon={InboxIcon}
OutlinedIcon={InboxOutlinedIcon}
/>
<LinkIconItem
path="/topics"
label="トピック"
Icon={SealCertificateIcon}
OutlinedIcon={SealCertificateOutlinedIcon}
/>
<LinkIconItem
path="/search"
label="検索"
Icon={SearchIcon}
OutlinedIcon={SearchIcon}
/>
</ul>
</div>
);
Expand Down
Loading

0 comments on commit bf87bc2

Please sign in to comment.