responsive styling

This commit is contained in:
VividTruthKeeper 2023-02-16 15:52:05 +05:00
parent d43cc28698
commit a346e80e59
8 changed files with 128 additions and 48 deletions

View File

@ -17,20 +17,20 @@ interface Props {
const AsideNews = ({ title, date, img, category, link }: Props) => { const AsideNews = ({ title, date, img, category, link }: Props) => {
return ( return (
<div className="aside-news"> <Link to={link} className="aside-news">
<div className="aside-news-wrapper"> <div className="aside-news-wrapper">
<Link to={link} className="aside-news-image"> <div className="aside-news-image">
<LazyLoadImage <LazyLoadImage
src={img} src={img}
alt="image" alt="image"
useIntersectionObserver useIntersectionObserver
effect="blur" effect="blur"
/> />
</Link> </div>
<div className="aside-news-info"> <div className="aside-news-info">
<div className="aside-news-info-inner"> <div className="aside-news-info-inner">
<div className="aside-news-status"> <div className="aside-news-status">
<NewsCategory title={category} id={1} /> <NewsCategory title={category} />
<NewsDate date={date} /> <NewsDate date={date} />
</div> </div>
<Link to={link}> <Link to={link}>
@ -39,7 +39,7 @@ const AsideNews = ({ title, date, img, category, link }: Props) => {
</div> </div>
</div> </div>
</div> </div>
</div> </Link>
); );
}; };

View File

@ -3,15 +3,10 @@ import { Link } from "react-router-dom";
interface Props { interface Props {
title: string; title: string;
id: number;
} }
const NewsCategory = ({ title, id }: Props) => { const NewsCategory = ({ title }: Props) => {
return ( return <p className="news-category">{title}</p>;
<Link to={`/category/${id}`} className="news-category">
{title}
</Link>
);
}; };
export default NewsCategory; export default NewsCategory;

View File

@ -1,29 +1,34 @@
// Modules // Modules
import { Link } from 'react-router-dom'; import { Link } from "react-router-dom";
import { LazyLoadImage } from 'react-lazy-load-image-component'; import { LazyLoadImage } from "react-lazy-load-image-component";
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from "uuid";
// Components // Components
import NewsCategory from '../global/NewsCategory'; import NewsCategory from "../global/NewsCategory";
import NewsDate from '../global/NewsDate'; import NewsDate from "../global/NewsDate";
import { IPostsData } from '../../types/data.types'; import { IPostsData } from "../../types/data.types";
interface Props { interface Props {
id: IPostsData['id']; id: IPostsData["id"];
title: IPostsData['title']; title: IPostsData["title"];
text: IPostsData['content_html']; text: IPostsData["content_html"];
categories: IPostsData['categories']; categories: IPostsData["categories"];
date: IPostsData['published_at']; date: IPostsData["published_at"];
img: IPostsData['featured_images'][0]['path']; img: IPostsData["featured_images"][0]["path"];
} }
const News = ({ id, title, text, categories, date, img }: Props) => { const News = ({ id, title, text, categories, date, img }: Props) => {
return ( return (
<div className="news"> <Link to={`/news/${id}`}>
<div className="news-wrapper"> <div className="news-wrapper">
<Link to={`/news/${id}`} className="news-image"> <div className="news-image">
<LazyLoadImage src={img} alt="image" useIntersectionObserver effect="blur" /> <LazyLoadImage
</Link> src={img}
alt="image"
useIntersectionObserver
effect="blur"
/>
</div>
<div className="news-info"> <div className="news-info">
<div className="news-info-inner"> <div className="news-info-inner">
<Link to={`/news/${id}`}> <Link to={`/news/${id}`}>
@ -32,18 +37,21 @@ const News = ({ id, title, text, categories, date, img }: Props) => {
<div className="news-status"> <div className="news-status">
<div className="news-status-left"> <div className="news-status-left">
{categories.map((category) => { {categories.map((category) => {
return <NewsCategory key={uuidv4()} title={category.name} id={category.id} />; return <NewsCategory key={uuidv4()} title={category.name} />;
})} })}
</div> </div>
<div className="news-status-right"> <div className="news-status-right">
<NewsDate date={date} /> <NewsDate date={date} />
</div> </div>
</div> </div>
<div className="news-text" dangerouslySetInnerHTML={{ __html: text }}></div> <div
className="news-text"
dangerouslySetInnerHTML={{ __html: text }}
></div>
</div> </div>
</div> </div>
</div> </div>
</div> </Link>
); );
}; };

View File

@ -27,7 +27,6 @@
@media (max-width: 450px) { @media (max-width: 450px) {
.aside-wrapper { .aside-wrapper {
gap: 3.2rem;
padding: 2.4rem 0.8rem; padding: 2.4rem 0.8rem;
} }
} }
@ -37,11 +36,3 @@
gap: 0rem; gap: 0rem;
} }
} }
// @media (max-width: 1024px) {
// .aside {
// flex-direction: row;
// align-items: flex-start;
// gap: 2.4rem;
// }
// }

View File

@ -1,5 +1,7 @@
.aside-news-wrapper { .aside-news-wrapper {
display: flex; display: grid;
grid-template-columns: 40% auto;
grid-template-rows: 12.4rem;
gap: 1.6rem; gap: 1.6rem;
} }
@ -11,6 +13,7 @@
} }
.aside-news-info-inner { .aside-news-info-inner {
width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 1.2rem; gap: 1.2rem;
@ -45,3 +48,36 @@
font-weight: 400; font-weight: 400;
color: $body; color: $body;
} }
.aside-news-image {
display: block;
width: 100%;
height: 100%;
span {
width: 100%;
height: 100%;
img {
width: 100%;
height: 100%;
object-fit: cover;
}
}
}
@media screen and (max-width: 1024px) {
.aside-news-wrapper {
grid-template-columns: 25% 1fr;
}
}
@media screen and (max-width: 750px) {
.aside-news-wrapper {
display: flex;
flex-direction: column;
}
.aside-news-image {
height: 16rem;
}
}

View File

@ -96,8 +96,19 @@
} }
} }
// @media (max-width: 390px) { @media (max-width: 400px) {
// .footer-nav-list { .footer-wrapper {
// grid-template-columns: auto; gap: 2.4rem;
// } }
// } .footer-nav-list {
gap: 1.6rem;
}
.footer-nav-list-item {
a {
font-size: 1.6rem;
}
}
.footer-info-item-title {
font-size: 1.6rem;
}
}

View File

@ -59,6 +59,16 @@
} }
&__big { &__big {
min-height: 16rem;
span {
width: 100%;
height: 100%;
}
img {
width: 100%;
height: 100%;
object-fit: cover;
}
&-overlay { &-overlay {
padding: 2.4rem; padding: 2.4rem;
} }
@ -139,3 +149,11 @@
} }
} }
} }
@media screen and (max-width: 500px) {
.main-content-item__big {
h2 {
font-size: 1.4rem;
}
}
}

View File

@ -1,6 +1,6 @@
.news-wrapper { .news-wrapper {
display: flex; display: grid;
// align-items: center; grid-template-columns: 32rem 1fr;
gap: 1.6rem; gap: 1.6rem;
} }
@ -105,3 +105,24 @@
font-size: 2rem; font-size: 2rem;
} }
} }
@media (max-width: 900px) {
.news-wrapper {
grid-template-columns: 25rem 1fr;
}
}
@media (max-width: 750px) {
.news-title {
font-size: 1.8rem;
}
.news-wrapper {
display: flex;
flex-direction: column;
}
.news-image {
min-height: 16rem;
}
}
@media (max-width: 400px) {
}