generated from kir-dev/next-nest-template
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Calendar page #37
Open
S-Norii
wants to merge
10
commits into
master
Choose a base branch
from
calendar-page
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Calendar page #37
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7637930
calendar only frontend
S-Norii e1ee948
changed file location
S-Norii 251e6d3
removed the changed file
S-Norii f86a68f
working calendar (added useState)
S-Norii 99b4b25
some fixes on rendering and mobile view
S-Norii 668c784
conflicts solved
S-Norii 7aed2de
Revert "conflicts solved"
S-Norii 38aef79
accidentally deleated file is back
S-Norii a7bc8ae
accidentally deleted file is back
S-Norii 0189208
Merge remote-tracking branch 'origin/calendar-page' into calendar-page
S-Norii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
'use client'; | ||
|
||
import React, { useState } from 'react'; | ||
|
||
import { styles } from '@/components/calendarStyles'; | ||
|
||
// Segédfüggvények | ||
const daysInWeek = ['Hétfő', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek', 'Szombat', 'Vasárnap']; | ||
const monthNames = [ | ||
'Január', | ||
'Február', | ||
'Március', | ||
'Április', | ||
'Május', | ||
'Június', | ||
'Július', | ||
'Augusztus', | ||
'Szeptember', | ||
'Október', | ||
'November', | ||
'December', | ||
]; | ||
|
||
const getDaysInMonth = (month: number, year: number) => { | ||
return new Date(year, month + 1, 0).getDate(); | ||
}; | ||
|
||
const getFirstDayOfMonth = (month: number, year: number) => { | ||
return new Date(year, month, 1).getDay(); | ||
}; | ||
|
||
// Calendar komponens | ||
const Calendar: React.FC = () => { | ||
const [currentMonth, setCurrentMonth] = useState(7); // Augusztus | ||
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. This should be dynamic as well, we don't want to manually update the month and the year every time it changes :D |
||
const [currentYear, setCurrentYear] = useState(2024); // 2024 | ||
|
||
const daysInMonth = getDaysInMonth(currentMonth, currentYear); | ||
const firstDayOfMonth = getFirstDayOfMonth(currentMonth, currentYear); | ||
|
||
const handlePrevMonth = () => { | ||
if (currentMonth === 0) { | ||
// Ha január van, lépj vissza decemberre és csökkentsd az évet | ||
setCurrentMonth(11); | ||
setCurrentYear(currentYear - 1); | ||
} else { | ||
setCurrentMonth(currentMonth - 1); | ||
} | ||
}; | ||
|
||
const handleNextMonth = () => { | ||
if (currentMonth === 11) { | ||
// Ha december van, lépj előre januárra és növeld az évet | ||
setCurrentMonth(0); | ||
setCurrentYear(currentYear + 1); | ||
} else { | ||
setCurrentMonth(currentMonth + 1); | ||
} | ||
}; | ||
|
||
const renderDays = () => { | ||
const days = []; | ||
|
||
// Üres cellák a hónap első napja előtt | ||
for (let i = 1; i < firstDayOfMonth; i++) { | ||
days.push(<div style={styles.emptyDay} key={`empty-${i}`} />); | ||
} | ||
|
||
// A hónap napjai | ||
for (let i = 1; i <= daysInMonth; i++) { | ||
days.push( | ||
<div style={styles.day} key={i}> | ||
<div className='text-xs text-gray-700 font-bold'>{i}</div> | ||
</div> | ||
); | ||
} | ||
|
||
// Üres cellák a hónap utolsó napja után | ||
const totalDays = days.length; | ||
const remainingDays = (7 - (totalDays % 7)) % 7; | ||
for (let i = 0; i < remainingDays; i++) { | ||
days.push(<div style={styles.emptyDay} key={`empty-end-${i}`} />); | ||
} | ||
|
||
return days; | ||
}; | ||
|
||
return ( | ||
<div style={styles.calendarContainer}> | ||
<div style={styles.calendarHeader}> | ||
<button style={styles.button} onClick={handlePrevMonth}> | ||
{'<'} | ||
</button> | ||
<div style={styles.monthLabel}>{monthNames[currentMonth]}</div> | ||
<button style={styles.button} onClick={handleNextMonth}> | ||
{'>'} | ||
</button> | ||
</div> | ||
<div> | ||
<div style={styles.grid}> | ||
{daysInWeek.map((day) => ( | ||
<div style={styles.dayName} key={day}> | ||
{day} | ||
</div> | ||
))} | ||
</div> | ||
<div style={styles.grid}>{renderDays()}</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Calendar; |
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
File renamed without changes.
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,70 @@ | ||
export const styles = { | ||
calendarContainer: { | ||
marginTop: '1.25rem', | ||
width: '91.666667%', | ||
marginLeft: '4rem', | ||
fontFamily: 'sans-serif', | ||
}, | ||
calendarHeader: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'space-between', | ||
marginBottom: '0.625rem', | ||
borderRadius: '0.5rem', | ||
width: '12.5rem', | ||
padding: '0.25rem', | ||
backgroundColor: '#7eb397', | ||
borderColor: '#18633d', | ||
borderWidth: '2px', | ||
}, | ||
button: { | ||
paddingLeft: '0.5rem', | ||
paddingRight: '0.5rem', | ||
paddingTop: '0.25rem', | ||
paddingBottom: '0.25rem', | ||
fontSize: '1.125rem', | ||
fontWeight: 'bold', | ||
cursor: 'pointer', | ||
}, | ||
monthLabel: { | ||
fontSize: '1.25rem', | ||
fontWeight: 'bold', | ||
padding: '0.25rem', | ||
backgroundColor: '#e0e0e0', | ||
borderRadius: '0.5rem', | ||
}, | ||
dayName: { | ||
backgroundColor: '#18633d', | ||
color: '#fff', | ||
borderRadius: '0.5rem', | ||
height: '3rem', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
fontSize: '20px', | ||
}, | ||
day: { | ||
marginTop: '0.25rem', | ||
height: '6rem', | ||
backgroundColor: '#7eb397', | ||
borderColor: '#ccc', | ||
borderWidth: '1px', | ||
borderRadius: '0.5rem', | ||
display: 'flex', | ||
justifyContent: 'flex-end', | ||
alignItems: 'flex-start', | ||
padding: '0.5rem', | ||
}, | ||
emptyDay: { | ||
marginTop: '0.25rem', | ||
width: '100%', | ||
height: '6rem', | ||
backgroundColor: '#e0e0e0', | ||
borderRadius: '0.5rem', | ||
}, | ||
grid: { | ||
display: 'grid', | ||
gridTemplateColumns: 'repeat(7, minmax(0, 1fr))', | ||
gap: '0.25rem', | ||
}, | ||
}; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This comment is unnecessary