-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
192 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
frontend/src/components/layout/durationInput/DurationInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const DurationInputWrapper = styled.div` | ||
display: flex; | ||
align-items: center; | ||
`; | ||
|
||
const Input = styled.input` | ||
width: 50px; | ||
margin: 0 5px; | ||
text-align: center; | ||
`; | ||
|
||
interface DurationInputProps { | ||
onDurationChange: (duration: { days: number; hours: number; minutes: number; seconds: number }) => void; | ||
} | ||
|
||
const DurationInput: React.FC<DurationInputProps> = ({ onDurationChange }) => { | ||
const [days, setDays] = useState(0); | ||
const [hours, setHours] = useState(0); | ||
const [minutes, setMinutes] = useState(0); | ||
const [seconds, setSeconds] = useState(0); | ||
|
||
const handleDurationChange = () => { | ||
onDurationChange({ days, hours, minutes, seconds }); | ||
}; | ||
|
||
return ( | ||
<DurationInputWrapper> | ||
<Input | ||
type="number" | ||
value={days} | ||
onChange={(e) => setDays(parseInt(e.target.value))} | ||
placeholder="Days" | ||
onBlur={handleDurationChange} | ||
/> | ||
<span>days</span> | ||
<Input | ||
type="number" | ||
value={hours} | ||
onChange={(e) => setHours(parseInt(e.target.value))} | ||
placeholder="Hours" | ||
onBlur={handleDurationChange} | ||
/> | ||
<span>hours</span> | ||
<Input | ||
type="number" | ||
value={minutes} | ||
onChange={(e) => setMinutes(parseInt(e.target.value))} | ||
placeholder="Minutes" | ||
onBlur={handleDurationChange} | ||
/> | ||
<span>minutes</span> | ||
<Input | ||
type="number" | ||
value={seconds} | ||
onChange={(e) => setSeconds(parseInt(e.target.value))} | ||
placeholder="Seconds" | ||
onBlur={handleDurationChange} | ||
/> | ||
<span>seconds</span> | ||
</DurationInputWrapper> | ||
); | ||
}; | ||
|
||
export default DurationInput; |
41 changes: 41 additions & 0 deletions
41
frontend/src/components/layout/durationInput/DurationInputWithFloatingBox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// DurationInputWithFloatingBox.tsx | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import DurationInput from './DurationInput'; | ||
|
||
const FloatingBoxWrapper = styled.div` | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
padding: 20px; | ||
background: #555555; | ||
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1); | ||
border-radius: 8px; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: stretch; | ||
`; | ||
|
||
const CloseButton = styled.button` | ||
margin-top: 10px; | ||
cursor: pointer; | ||
flex: 1; | ||
`; | ||
|
||
interface DurationInputWithFloatingBoxProps { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
onDurationChange: (duration: { days: number; hours: number; minutes: number; seconds: number }) => void; | ||
} | ||
|
||
const DurationInputWithFloatingBox: React.FC<DurationInputWithFloatingBoxProps> = ({ isOpen, onClose, onDurationChange }) => { | ||
return ( | ||
<FloatingBoxWrapper style={{ display: isOpen ? 'flex' : 'none' }}> | ||
<DurationInput onDurationChange={onDurationChange} /> | ||
<CloseButton onClick={onClose}>Close</CloseButton> | ||
</FloatingBoxWrapper> | ||
); | ||
}; | ||
|
||
export default DurationInputWithFloatingBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters