Skip to content

Commit

Permalink
♻️ マージ前のリファクタリング
Browse files Browse the repository at this point in the history
  • Loading branch information
wappon28dev committed Nov 2, 2024
1 parent b9ad689 commit 2c35e78
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 34 deletions.
37 changes: 16 additions & 21 deletions src/components/project/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Icon } from "@iconify/react";
import { Link } from "@tanstack/react-router";
import { ResultAsync } from "neverthrow";
import { css } from "panda/css";
import { styled as p, HStack, Grid } from "panda/jsx";
import { type ReactElement } from "react";
import useSWRImmutable from "swr/immutable";
Expand Down Expand Up @@ -83,23 +82,14 @@ export function ProjectCard({ project }: { project: Project }): ReactElement {
src={key_visual ?? ""}
w="100%"
/>
<p.div
className={css({
"& > div": {
gap: "0",
"& > svg": {
height: "1.2em",
width: "1.2em",
},
},
})}
minH="1lh"
pt="2"
w="100%"
>
<p.div minH="1lh" pt="2" w="100%">
{match(swrAddr)
.with(S.Loading, () => (
<IconText icon="svg-spinners:ring-resize">
<IconText
containerProps={{ gap: "1" }}
icon="svg-spinners:ring-resize"
iconProps={{ height: "1.2em" }}
>
<p.p>住所を取得中...</p.p>
</IconText>
))
Expand All @@ -109,7 +99,11 @@ export function ProjectCard({ project }: { project: Project }): ReactElement {
if (addr == null || referenced == null) return null;

return (
<IconText icon="mdi:map-marker-outline">
<IconText
containerProps={{ gap: "1" }}
icon="mdi:map-marker-outline"
iconProps={{ height: "1.2em" }}
>
<p.p>{addr2str(addr, Project.calcStatus(referenced))}</p.p>
</IconText>
);
Expand All @@ -124,11 +118,12 @@ export function ProjectCard({ project }: { project: Project }): ReactElement {
<p.p fontSize="2xl" fontWeight="bold" lineClamp="2" minH="1lh">
{name}
</p.p>
<p.p fontSize="md">
現在金額 ¥
<p.p fontSize="md" minH="1lh">
{match(swrProjectAbout)
.with(S.Success, ({ data: { referenced } }) =>
Pledge.calcTotalAmountOfMoney(referenced.pledges),
.with(
S.Success,
({ data: { referenced } }) =>
`現在金額 ¥ ${Pledge.calcTotalAmountOfMoney(referenced.pledges).toLocaleString()}`,
)
.otherwise(() => "---")}
</p.p>
Expand Down
3 changes: 0 additions & 3 deletions src/components/sva/hover-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ export const svaHoverCard = sva({
className: "hover-card",
slots: hoverCardAnatomy.keys(),
base: {
trigger: {
// display: "contents",
},
content: {
p: "2",
bg: "wkb.bg",
Expand Down
8 changes: 0 additions & 8 deletions src/components/sva/tabs.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { tabsAnatomy } from "@ark-ui/react";
import { sva } from "panda/css";

/**
* Ark UI の [Popover コンポーネント](https://ark-ui.com/react/docs/components/popover) の基底スタイル
*
* 書き方 refs:
* - https://panda-css.com/docs/concepts/slot-recipes
* - https://ark-ui.com/react/docs/guides/styling#styling-with-panda-css
* - https://speakerdeck.com/ikumatadokoro/panda-css-to-ark-ui-dehazimeruge-ren-kai-fa?slide=31
*/
export const svaTabs = sva({
className: "tabs",
slots: tabsAnatomy.keys(),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/classes/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class Project extends Table<
}));
}

static toBeDistinct(
static getUniqueMap(
projects: Project[],
): Map<TableBrandedId<Project>, Project> {
const uniqueProjectMap = new Map<TableBrandedId<Project>, Project>();
Expand Down
2 changes: 1 addition & 1 deletion src/routes/_auth/seeds/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function fetchProjectSeedsMap(

// p(t) と, s_n とのペア (1-N)
return seedsTerritoriesProjects.map((sTsPs) => {
const uniqueProjects = Project.toBeDistinct(
const uniqueProjects = Project.getUniqueMap(
Array.from(sTsPs).flatMap(([, { projects }]) => projects),
);

Expand Down

0 comments on commit 2c35e78

Please sign in to comment.