Skip to content

Commit

Permalink
added-css
Browse files Browse the repository at this point in the history
  • Loading branch information
pryge committed Dec 17, 2024
1 parent f12c803 commit 5068560
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,44 @@
rel="stylesheet"
href="styles/index.scss"
/>
<link
rel="stylesheet"
href="styles/main.css"
/>
</head>
<body>
<h1>Calendar</h1>
<div class="calendar calendar--month-length-31 calendar--start-sun">
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
<div class="calendar__day"></div>
</div>
</body>
</html>
238 changes: 238 additions & 0 deletions src/styles/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
* {
box-sizing: border-box;
}

body {
display: flex;
justify-content: center;
align-items: center;
margin: 0;
height: 100vh;
}

.calendar {
display: flex;
flex-wrap: wrap;
gap: 1px;
width: 707px;
}

.calendar__day {
display: flex;
justify-content: center;
align-items: center;
position: relative;
background-color: #eee;
height: 100px;
width: 100px;
border: 1px solid black;
transition-property: background-color, transform;
transition-duration: 0.5s;
}

.calendar__day::before {
font-family: Arial, Helvetica, sans-serif;
font-size: 30px;
color: black;
}

.calendar--start-day-sun .calendar__day:first-child {
margin-left: 101px;
}

.calendar--start-day-mon .calendar__day:first-child {
margin-left: 202px;
}

.calendar--start-day-tue .calendar__day:first-child {
margin-left: 303px;
}

.calendar--start-day-wed .calendar__day:first-child {
margin-left: 404px;
}

.calendar--start-day-thu .calendar__day:first-child {
margin-left: 505px;
}

.calendar--start-day-fri .calendar__day:first-child {
margin-left: 606px;
}

.calendar--start-day-sat .calendar__day:first-child {
margin-left: 707px;
}

.calendar .calendar--start-day-sun .calendar__day:first-of-type {
margin-left: 0;
}

.calendar .calendar--start-day-mon .calendar__day:first-of-type {
margin-left: 101px;
}

.calendar .calendar--start-day-tue .calendar__day:first-of-type {
margin-left: 202px;
}

.calendar .calendar--start-day-wed .calendar__day:first-of-type {
margin-left: 303px;
}

.calendar .calendar--start-day-thu .calendar__day:first-of-type {
margin-left: 404px;
}

.calendar .calendar--start-day-fri .calendar__day:first-of-type {
margin-left: 505px;
}

.calendar .calendar--start-day-sat .calendar__day:first-of-type {
margin-left: 606px;
}

.calendar .calendar--month-length-28 .calendar__day:nth-child(n+29) {
display: none;
}

.calendar .calendar--month-length-29 .calendar__day:nth-child(n+30) {
display: none;
}

.calendar .calendar--month-length-30 .calendar__day:nth-child(n+31) {
display: none;
}

.calendar .calendar--month-length-31 .calendar__day:nth-child(n+32) {
display: none;
}

.calendar__day:nth-child(n+1)::before {
content: "1";
}

.calendar__day:nth-child(n+2)::before {
content: "2";
}

.calendar__day:nth-child(n+3)::before {
content: "3";
}

.calendar__day:nth-child(n+4)::before {
content: "4";
}

.calendar__day:nth-child(n+5)::before {
content: "5";
}

.calendar__day:nth-child(n+6)::before {
content: "6";
}

.calendar__day:nth-child(n+7)::before {
content: "7";
}

.calendar__day:nth-child(n+8)::before {
content: "8";
}

.calendar__day:nth-child(n+9)::before {
content: "9";
}

.calendar__day:nth-child(n+10)::before {
content: "10";
}

.calendar__day:nth-child(n+11)::before {
content: "11";
}

.calendar__day:nth-child(n+12)::before {
content: "12";
}

.calendar__day:nth-child(n+13)::before {
content: "13";
}

.calendar__day:nth-child(n+14)::before {
content: "14";
}

.calendar__day:nth-child(n+15)::before {
content: "15";
}

.calendar__day:nth-child(n+16)::before {
content: "16";
}

.calendar__day:nth-child(n+17)::before {
content: "17";
}

.calendar__day:nth-child(n+18)::before {
content: "18";
}

.calendar__day:nth-child(n+19)::before {
content: "19";
}

.calendar__day:nth-child(n+20)::before {
content: "20";
}

.calendar__day:nth-child(n+21)::before {
content: "21";
}

.calendar__day:nth-child(n+22)::before {
content: "22";
}

.calendar__day:nth-child(n+23)::before {
content: "23";
}

.calendar__day:nth-child(n+24)::before {
content: "24";
}

.calendar__day:nth-child(n+25)::before {
content: "25";
}

.calendar__day:nth-child(n+26)::before {
content: "26";
}

.calendar__day:nth-child(n+27)::before {
content: "27";
}

.calendar__day:nth-child(n+28)::before {
content: "28";
}

.calendar__day:nth-child(n+29)::before {
content: "29";
}

.calendar__day:nth-child(n+30)::before {
content: "30";
}

.calendar__day:nth-child(n+31)::before {
content: "31";
}

.calendar:hover {
background-color: #ffbfcb;
transform: translate(0, -20px);
}
1 change: 1 addition & 0 deletions src/styles/index.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 103 additions & 0 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,106 @@
$day-size: 100px;
$day-border: 1px;
$day-gap: $day-border;
$day-bg: #eee;
$font-size: 30px;
$month-length: 31;
$calendar: (
sun: 0,
mon: 1,
tue: 2,
wed: 3,
thu: 4,
fri: 5,
sat: 6,
);

* {
box-sizing: border-box;
}

body {
display: flex;
justify-content: center;
align-items: center;
margin: 0;
height: 100vh;
}

.calendar {
display: flex;
flex-wrap: wrap;
gap: $day-gap;
width: calc(($day-size + $day-gap) * 7);

@each $day, $i in $calendar {
.calendar--start-day-#{$day} .calendar__day:first-of-type {
margin-left: ($day-size + $day-gap) * $i;
}
}

@for $i from 28 through $month-length {
.calendar--month-length-#{$i} .calendar__day:nth-child(n + #{$i + 1}) {
display: none;
}
}

&__day {
display: flex;
justify-content: center;
align-items: center;

position: relative;
background-color: $day-bg;
height: $day-size;
width: $day-size;
border: $day-border solid black;

transition-property: background-color, transform;
transition-duration: 0.5s;

@for $i from 1 through $month-length {
&:nth-child(n + #{$i})::before {
content: '#{$i}';
}
}

&::before {
font-family: Arial, Helvetica, sans-serif;
font-size: $font-size;
color: black;
}
}

&:hover {
background-color: #ffbfcb;
transform: translate(0, -20px);
}
}

.calendar--start-day-sun .calendar__day:first-child {
margin-left: calc($day-size + $day-gap);
}

.calendar--start-day-mon .calendar__day:first-child {
margin-left: calc(($day-size + $day-gap) * 2);
}

.calendar--start-day-tue .calendar__day:first-child {
margin-left: calc(($day-size + $day-gap) * 3);
}

.calendar--start-day-wed .calendar__day:first-child {
margin-left: calc(($day-size + $day-gap) * 4);
}

.calendar--start-day-thu .calendar__day:first-child {
margin-left: calc(($day-size + $day-gap) * 5);
}

.calendar--start-day-fri .calendar__day:first-child {
margin-left: calc(($day-size + $day-gap) * 6);
}

.calendar--start-day-sat .calendar__day:first-child {
margin-left: calc(($day-size + $day-gap) * 7);
}

0 comments on commit 5068560

Please sign in to comment.