Skip to content

Commit

Permalink
時間指定用のコンポーネントを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
takusea committed Oct 19, 2024
1 parent e2b4dde commit ae284cb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
24 changes: 24 additions & 0 deletions src/components/TimeField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { ChangeEventHandler, FocusEventHandler } from "react";

type Props = {
value: string;
id?: string;
placeholder?: string;
onChange?: ChangeEventHandler<HTMLInputElement>;
onBlur?: FocusEventHandler<HTMLInputElement>;
};

export function TimeField(props: Props) {
return (
<input
className="border border-black/20 h-10 rounded flex-grow px-2 shadow-inner"
type="time"
step={1000}
placeholder={props.placeholder}
id={props.id}
value={props.value}
onChange={props.onChange}
onBlur={props.onBlur}
/>
);
}
7 changes: 4 additions & 3 deletions src/features/video-player/VideoPlayerEditForm.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { type ChangeEvent, useState } from "react";
import { type ChangeEvent, useEffect, useState } from "react";

Check failure on line 1 in src/features/video-player/VideoPlayerEditForm.tsx

View workflow job for this annotation

GitHub Actions / deploy

'useEffect' is declared but its value is never read.
import { IconCheck, IconTrash } from "@tabler/icons-react";
import { Button } from "../../components/Button";
import { TextField } from "../../components/TextField";
import type { VideoMetadata } from "../video-metadata/type";
import { TimeField } from "../../components/TimeField";

type Props = {
metadata: VideoMetadata;
Expand Down Expand Up @@ -36,7 +37,7 @@ export function VideoPlayerEditForm(props: Props) {

const isContainNaN =
Number.isNaN(hours) || Number.isNaN(minutes) || Number.isNaN(seconds);
const isOvered = minutes > 60 || seconds > 60;
const isOvered = minutes >= 60 || seconds >= 60;
if (isContainNaN || isOvered) {
return;
}
Expand All @@ -58,7 +59,7 @@ export function VideoPlayerEditForm(props: Props) {
htmlFor={`seconds-${id}`}
>
開始位置
<TextField
<TimeField
id={`seconds-${id}`}
value={toDisplayTime(seconds ?? 0)}
onChange={handleTimeChange}
Expand Down

0 comments on commit ae284cb

Please sign in to comment.