Skip to content

Commit

Permalink
Merge pull request #5 from ananastasiap/05_responsive
Browse files Browse the repository at this point in the history
05_Responsiveness
  • Loading branch information
ananastasiap authored Dec 27, 2023
2 parents 1958407 + d31471e commit 05d1f31
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 11 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<h1 class="title stroke">Поздравьте близкого человека с праздником!</h1>
<p class="about__text">Выберите открытку и получатель получит ее на свой телефон</p>
</section>
<section class="congratulation u-wrapper-larger">
<section class="congratulation u-wrapper">
<section class="cards">
<div class="swiper congratulation__swiper congratulation__swiper--card">
<div class="swiper-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion nested/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
</header>
<main>
<section class="congrats-final">
<section class="congrats-final u-wrapper">
<h1 class="title">Вам открытка!</h1>
<p class="congrats-final__text">Нажмите на нее, чтобы узнать от кого она и прочитать поздравление</p>
<div class="card">
Expand Down
29 changes: 29 additions & 0 deletions src/scss/base/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,32 @@ body {
.about__text {
font-size: 1.7rem;
}

/* MEDIA */
@media screen and (max-width: 1039px) {
.title {
font-size: 3rem;
font-weight: 700;
line-height: 1.2;
}

.about__text {
font-size: 1.5rem;
}
}

@media screen and (max-width: 551px) {
.title {
font-size: 2rem;
font-weight: 700;
line-height: 1;

&__card {
font-size: 1.7rem;
}
}

.about__text {
font-size: 1.2rem;
}
}
19 changes: 14 additions & 5 deletions src/scss/base/_utilities.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
.u-wrapper {
padding: 2.5rem 8.12rem 0 15rem;
}

.u-wrapper-larger {
padding: 2.5rem 35rem 0 15rem;
padding: 3.5rem 8.12rem 0 14rem;
}

.stroke {
-webkit-text-stroke: 0.04rem #94b7fc;
}

/* MEDIA */
@media screen and (max-width: 1194px) and (min-width: 1040px) {
.u-wrapper {
padding: 2.5rem 3.12rem 0 5rem;
}
}

@media screen and (max-width: 1039px) {
.u-wrapper {
padding: 2rem 3rem 0 3rem;
}
}
7 changes: 7 additions & 0 deletions src/scss/layout/_about.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@
margin-bottom: 2.96rem;
}
}

/* MEDIA */
@media screen and (max-width: 551px) {
.title {
margin-top: none;
}
}
53 changes: 53 additions & 0 deletions src/scss/layout/_congrats-final.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,56 @@
margin-bottom: 2.96rem;
}
}

/* MEDIA */
@media screen and (max-width: 625px) {
.congrats-final {
margin-bottom: 5rem;
}

.congrats-final__text {
text-align: center;
}

.congrats-final .card {
width: 380px;
height: auto;
}

.congrats-final .card__message {
font-size: 1.5rem;
}
}

@media screen and (max-width: 580px) {
.congrats-final .card__contacts {
margin-bottom: 0;
margin-top: 2rem;
}

.congrats-final .card__message {
font-size: 1rem;
}
}

@media screen and (max-width: 545px) {
.congrats-final .card {
width: 360px;
height: auto;
}

.congrats-final__text {
font-size: 1.2rem;
}
}

@media screen and (max-width: 387px) {
.congrats-final .card {
width: 300px;
height: auto;
}

.congrats-final .card__back {
padding: 3rem 3rem 5rem 3rem;
}
}
56 changes: 54 additions & 2 deletions src/scss/layout/_congratulation.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.congratulation {
display: flex;
justify-content: space-between;
align-items: start;
gap: 6rem;
gap: 15rem;

.cards {
max-width: 50rem;
Expand Down Expand Up @@ -105,3 +104,56 @@
}
}
}

/* MEDIA */
@media screen and (max-width: 1194px) and (min-width: 1040px) {
.congratulation {
gap: 7rem;
}
}

@media screen and (max-width: 1039px) {
.congratulation {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 5rem;
}

.form {
margin-bottom: 3rem;
}
}

@media screen and (max-width: 550px) {
.cards {
width: 46rem;
}

.congratulation .gift__form .form__label-text {
font-size: 1.2rem;
}
}

@media screen and (max-width: 479px) and (min-width: 320px) {
.cards {
width: 35rem;
}
}

@media screen and (max-width: 368px) {
.cards {
width: 30rem;
}
}

@media screen and (max-width: 334px) {
.congratulation {
gap: 2.5rem;
}

.congratulation .gift__form .form {
grid-template-columns: repeat(1, 1fr);
}
}
7 changes: 7 additions & 0 deletions src/scss/layout/_header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* MEDIA */
@media screen and (max-width: 550px) {
.logo__icon {
width: 14rem;
height: auto;
}
}
1 change: 1 addition & 0 deletions src/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@import "./base/utilities";
@import "./base/typography";

@import "./layout/header";
@import "./layout/about";
@import "./layout/congratulation";
@import "./layout/_congrats-final";
6 changes: 4 additions & 2 deletions src/ts/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import "../scss/style.scss";
import "swiper/css";
import { swiperMain } from "./modules";
import { swiperMain, rearrangeElement } from "./modules";

window.addEventListener("DOMContentLoaded", () => {
// swiperThumb(".congratulation__swiper--thumb");
swiperMain(".congratulation__swiper--card");
window.addEventListener("resize", () => {
rearrangeElement(".card", ".card__title", ".card__contacts");
});
});
1 change: 1 addition & 0 deletions src/ts/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { swiperThumb, swiperMain } from "./swiper.ts";
export { rearrangeElement } from "./sciptForCard.ts";
17 changes: 17 additions & 0 deletions src/ts/modules/sciptForCard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const rearrangeElement = (
cardSelector: string,
cardTitleSelector: string,
cardContactsSelector: string
) => {
const screenWidth = window.innerWidth;

const card = document.querySelector(cardSelector);
const cardTitle = document.querySelector(cardTitleSelector);
const cardContacts = document.querySelector(cardContactsSelector);

if (screenWidth <= 580 && card && cardContacts) {
card?.after(cardContacts);
} else if (cardTitle && cardContacts) {
cardTitle?.after(cardContacts);
}
};

0 comments on commit 05d1f31

Please sign in to comment.