Skip to content

Commit

Permalink
feat: 오늘 날짜에 강조 표시 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcjy committed Jul 3, 2024
1 parent 0107d55 commit a607b2d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions components/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import Link from "next/link";

export const Calendar = () => {
const header = ['일', '월', '화', '수', '목', '금', '토']
const july = Array.from(Array(5), () => Array(7).fill(0))
const july: number[][] = Array.from(Array(5), () => Array(7).fill(0))
const julyStartIdx = 1;
const julyDays = 31;
for (let i = julyStartIdx, day = 1; day <= julyDays; i++, day++) july[Math.floor(i / 7)][i % 7] = day

const exodus = [null, '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23-24', '25-26', '27-28', '29-30', '31-32', '33-34', '35-36', '37-38', '39-40']
const today = new Date();

const setDayColor = (idx: number) => `${idx === 0 ? 'text-red-500' : ''} ${idx === 6 ? 'text-blue-600' : ''}`

Expand All @@ -21,10 +22,10 @@ export const Calendar = () => {
</div>
</div>
<div className="table-row-group h-[75vh]">
{july.map((row, i) => (
{july.map((row: number[], i) => (
<div key={i} className="table-row">
{row.map((day, i) => (
<Link key={i} href={day ? `/${day}` : '#'} className="table-cell border">
{row.map((day: number, i) => (
<Link key={i} href={day ? `/${day}` : '#'} className={`table-cell border ${day === today.getDay() ? 'border-2 border-red-400 bg-red-100/50' : null}`}>
{day ?
<div>
<div className={`p-1.5 sm:p-2 font-bold sm:text-xl ${setDayColor(i)}`}>{day}</div>
Expand Down

0 comments on commit a607b2d

Please sign in to comment.