-
Notifications
You must be signed in to change notification settings - Fork 0
feat: チャージボタンコンポーネントを追加 #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| .chargeButton { | ||
| margin-bottom: 1.5rem; | ||
| width: 90%; | ||
| max-width: 88rem; | ||
| height: 10rem; | ||
| background-color: $blue-40; | ||
| color: $white; | ||
| font-size: 4.0625rem; | ||
| font-weight: bold; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [must] sysken-pay-front/src/pages/index.module.scssの方では |
||
| border: none; | ||
| border-radius: 1.5rem; | ||
| cursor: pointer; | ||
| box-shadow: 0 0.25rem 0.625rem $shadow-20; | ||
| transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease; | ||
|
|
||
| &:hover { | ||
| opacity: 0.85; | ||
| } | ||
|
|
||
| &:active { | ||
| transform: scale(0.97); | ||
| box-shadow: 0 0.125rem 0.25rem $shadow-20; | ||
| opacity: 0.9; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { useNavigate } from "react-router-dom"; | ||
| import styles from "./ChargeButton.module.scss"; | ||
|
|
||
| interface ChargeButtonProps { | ||
| onCharge?: () => void; | ||
| } | ||
|
|
||
| export function ChargeButton({ onCharge }: ChargeButtonProps) { | ||
| const navigate = useNavigate(); | ||
|
|
||
| return ( | ||
| <button | ||
| type="button" | ||
| className={styles.chargeButton} | ||
| onClick={onCharge ?? (() => navigate("/charge"))} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [FYI] ?? だと「onCharge が渡されていれば navigate しない」という排他になる。もし「onCharge があれば呼びつつ、デフォルトの遷移もしたい」みたいな要件が将来出てくるなら以下のように修正をした方が良いと思います const handleClick = () => {
if (onCharge) {
onCharge();
} else {
navigate("/charge");
}
}; |
||
| > | ||
| チャージ | ||
| </button> | ||
| ); | ||
| } | ||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,42 @@ | ||
| import type { JSX } from "react"; | ||
| import { useState, useEffect } from "react"; | ||
| import { useNavigate } from "react-router-dom"; | ||
| import Header from "../components/layouts/Header"; | ||
| import { HomeButtons } from "../components/features/home/HomeButtons"; | ||
| import { ChargeButton } from "../components/features/home/ChargeButton"; | ||
| import { BarcodeReader } from "../components/ui/BarcodeReader"; | ||
| import { useCartStore } from "../store/useCartStore"; | ||
| import { ItemRepositoryImpl } from "../adapter/repository/ItemRepositoryImpl"; | ||
| import styles from "./index.module.scss"; | ||
|
|
||
| export default function Home(): JSX.Element { | ||
| const navigate = useNavigate(); | ||
| const addItem = useCartStore((state) => state.addItem); | ||
| const [error, setError] = useState<string | null>(null); | ||
|
|
||
| useEffect(() => { | ||
|
Comment on lines
+12
to
+16
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 対応お願いします |
||
| if (!error) return; | ||
| const timer = setTimeout(() => setError(null), 5000); | ||
| return () => clearTimeout(timer); | ||
| }, [error]); | ||
|
|
||
| const handleScan = async (barcode: string) => { | ||
| try { | ||
| const data = await ItemRepositoryImpl.getItemByJanCode(barcode); | ||
| if (!data?.item_id) throw new Error("商品が見つかりませんでした。ご不明の際は担当者にご連絡ください。"); | ||
| addItem(data); | ||
| navigate("/buy/list"); | ||
|
Comment on lines
+22
to
+27
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 個人的には、無理に共通化しても破壊的変更になるかもなので慎重に考えてもらえると Goodです |
||
| } catch (e) { | ||
| setError(e instanceof Error ? e.message : "商品の取得に失敗しました"); | ||
| } | ||
| }; | ||
|
Comment on lines
+22
to
+31
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 対応お願いします |
||
|
|
||
| return ( | ||
| <div className={styles.container}> | ||
| <Header title="シス研Pay" right="setting" shadow={true} /> | ||
| <main className={styles.main}> | ||
| <HomeButtons /> | ||
| <BarcodeReader mode="product" onScan={handleScan} /> | ||
| {error && <p className={styles.error}>{error}</p>} | ||
| <ChargeButton /> | ||
| </main> | ||
| </div> | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[imo] font-sizeも固定にした方が良いと思います
大きい、中くらい、小さいでそれぞれ分けて(分け方はなんでも良い)固定値で使っていくと
文字の大きさも統一がされて綺麗になると思います