Skip to content

Commit 10ca480

Browse files
committed
from flex to grid
1 parent 691beee commit 10ca480

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

src/pages/Calendar/Calendar.module.css

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,31 @@
99
}
1010

1111
.days {
12-
display: flex;
13-
flex-wrap: wrap;
12+
container: days / inline-size;
13+
display: grid;
1414
max-width: 51.5rem;
1515
margin: 0 auto;
1616
gap: 1rem;
17+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
1718
}
1819

19-
.hidden {
20-
position: relative;
21-
flex: 0 0 6.5rem;
22-
opacity: 0;
23-
visibility: hidden;
20+
.firstday {
21+
}
22+
23+
@media only screen and (min-width: 824px) {
24+
.firstday {
25+
grid-column-start: attr(data-column-start);
26+
}
2427
}
2528

2629
.day {
2730
position: relative;
28-
flex: 0 0 6.5rem;
2931
color: var(--white);
30-
background-color: var(--grey-2);
3132
height: 6.5rem;
3233
width: 6.5rem;
3334
padding: 1.5rem 0 0 0;
34-
background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' stroke='white' stroke-width='4' stroke-dasharray='6%2c 14' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e");
35+
background: var(--grey-2)
36+
url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' stroke='white' stroke-width='4' stroke-dasharray='6%2c 14' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e");
3537
font-size: 3rem;
3638
text-decoration: none;
3739
}

src/pages/Calendar/Calendar.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const Calendar: React.FC = () => {
3333

3434
const firstDayOfTheMonth =
3535
getDay(new Date(getYear(calendar.createdAt.toDate()), 11, 1)) === 0
36-
? 6
37-
: getDay(new Date(getYear(calendar.createdAt.toDate()), 11, 1)) - 1;
36+
? 7
37+
: getDay(new Date(getYear(calendar.createdAt.toDate()), 11, 1));
3838

3939
return (
4040
<div className={styles.calendar}>
@@ -51,9 +51,6 @@ const Calendar: React.FC = () => {
5151
Innstillinger
5252
</ReactTooltip>
5353
<div className={styles.days}>
54-
{Array.from(Array(firstDayOfTheMonth).keys()).map((day) => (
55-
<div className={styles.hidden}>{day}</div>
56-
))}
5754
{Array.from(Array(24).keys()).map((day) => {
5855
const open =
5956
hotkey ||
@@ -74,6 +71,7 @@ const Calendar: React.FC = () => {
7471
[styles.winner]: winner !== undefined,
7572
[styles.open]: open && !winner,
7673
[styles.ignore]: ignoreWeekend,
74+
[styles.firstday]: day === 0,
7775
});
7876

7977
if (open && !winner && !ignoreWeekend) {
@@ -89,7 +87,11 @@ const Calendar: React.FC = () => {
8987
}
9088

9189
return (
92-
<div key={day + 1} className={dayClass}>
90+
<div
91+
key={day + 1}
92+
className={dayClass}
93+
data-column-start={day === 0 ? firstDayOfTheMonth : undefined}
94+
>
9395
{winner && (
9496
<div className={styles.avatar}>
9597
<img

0 commit comments

Comments
 (0)