Skip to content

Commit

Permalink
enhancement_350_adaptive_main_page
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderMorugin committed May 22, 2024
1 parent 7c27885 commit 9b51623
Show file tree
Hide file tree
Showing 25 changed files with 446 additions and 288 deletions.
1 change: 0 additions & 1 deletion src/app/styles/base/_reset.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
body {
margin: 0 auto;
max-width: 100vw;
min-width: 375px;
font-family:
Roboto,
Arial,
Expand Down
22 changes: 5 additions & 17 deletions src/components/WrapperForMainContent/wrapper.module.scss
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
@use '../../shared/styles/utils/mixins' as media;

.wrapper {
max-width: 1470px;
width: 100%;
margin: 0 auto;
padding: 25px;
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;

@include media.respond-to('middle') {
max-width: 768px;
width: 100%;
}

@include media.respond-to('small') {
width: 390px;
gap: 20px;
}
gap: 48px;
width: 100%;
max-width: 1470px;
margin: 0 auto;
padding: 25px;
}
2 changes: 2 additions & 0 deletions src/entities/HeadingBlock/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import HeadingBlock from './ui/HeadingBlock'
export default HeadingBlock
40 changes: 40 additions & 0 deletions src/entities/HeadingBlock/ui/HeadingBlock.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@use '@/shared/styles/utils/variables' as var;
@use '@/shared/styles/utils/mixins' as media;

.headingBlock {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;

&__heading {
display: flex;
gap: 15px;
align-items: flex-end;
}

&__link {
display: flex;
justify-content: space-between;
align-items: center;
gap: 10px;
font-size: 15px;
color: var.$link-color;
fill: var.$link-color;
cursor: pointer;
opacity: 1;
transition: 0.25s;

&:hover {
opacity: 0.7;
}

@include media.respond-to('middle') {
display: none;
}
}

&__arrow {
transform: rotate(270deg);
}
}
42 changes: 42 additions & 0 deletions src/entities/HeadingBlock/ui/HeadingBlock.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { Meta, StoryObj } from '@storybook/react'

import IconHand from '@/assets/images/img-hand.png.png'

import HeadingBlock from './HeadingBlock'

const meta = {
title: 'entities/HeadingBlock',
component: HeadingBlock,
parameters: {
layout: 'centered'
},
tags: ['autodocs']
} satisfies Meta<typeof HeadingBlock>

export default meta
type Story = StoryObj<typeof meta>

export const Default: Story = () => {
const title = 'Новости'
const subtitle = 'Все новости'
const link = '#'

return (
<div style={{ width: '700px' }}>
<HeadingBlock
title={title}
isIcon={true}
image={IconHand}
isLink={true}
subtitle={subtitle}
link={link}
/>
</div>
)
}

Default.args = {
title: 'Новости',
subtitle: 'Все новости',
link: '#'
}
55 changes: 55 additions & 0 deletions src/entities/HeadingBlock/ui/HeadingBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { FC } from 'react'

import ArrowIcon from '@/assets/images/sideBarMenu/IconArrowDown.svg'
import Heading, { HeadingType } from '@/shared/ui/Heading/Heading'
import Link from '@/shared/ui/Link/Link'

import styles from './HeadingBlock.module.scss'

interface IHeadingBlock {
title: string
isIcon?: boolean
image?: string
alt?: string
isLink?: boolean
subtitle?: string
link?: string
}

/**
* Компонент HeadingBlock - это заголовок с отдельным линком. Отрисовывается на главной странице MainPage в блоках новостей, отзывов и т.п.
* @param {string} title - заголовок блока
* @param {boolean} isIcon - булево значение показывающее линк
* @param {string} image - картинка в заголовке блока
* @param {string} alt - alt картинки в заголовке блока
* @param {boolean} isLink - булево значение показывающее линк
* @param {string} subtitle - название линка
* @param {string} link - ссылка
*/

const HeadingBlock: FC<IHeadingBlock> = ({
title,
isIcon = false,
image,
alt,
isLink = false,
subtitle,
link
}) => {
return (
<article className={styles.headingBlock}>
<Heading type={HeadingType.NORMAL} className={styles.headingBlock__heading}>
{title}
{isIcon && <img src={image} alt={alt} />}
</Heading>
{isLink && (
<Link to={link} className={styles.headingBlock__link}>
{subtitle}
<ArrowIcon className={styles.headingBlock__arrow} />
</Link>
)}
</article>
)
}

export default HeadingBlock
8 changes: 5 additions & 3 deletions src/pages/MainPage/MainPage.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { FC } from 'react'

import WrapperForMainContent from '@/components/WrapperForMainContent/WrapperForMainContent'
import { Routes } from '@/shared/config/routerConfig/routes'
import { TEXT_CUSTOMERS_ABOUT_US, LINK_REVIEWS_ALL } from '@/shared/constants/constants'
import Advantages from '@/widgets/Advantages/ui/Advantages/Advantages'
import ArticleBlock from '@/widgets/ArticleBlock/ArticleBlock'
import ArticleBlock from '@/widgets/ArticleBlock'
import BannerBlock from '@/widgets/BannerBlock/ui/BannerBlock'
import BlogBlock from '@/widgets/BlogBlock/ui/BlogBlock'
import BrandsBlock from '@/widgets/BrandBlock/ui/BrandBlock/BrandBlock'
import CategoryGrid from '@/widgets/CategoryGrid/CategoryGrid'
import CategoryGrid from '@/widgets/CategoryGrid'
import HeroBlock from '@/widgets/HeroBlock/ui/HeroBlock/HeroBlock'
import NewsBlock from '@/widgets/NewsBlock/ui/NewsBlock'
import ReviewsBlock from '@/widgets/ReviewsBlock/ui/ReviewsBlock/ReviewsBlock'
import StoriesBlock from '@/widgets/StoriesBlock/ui/StoriesBlock'
import Subscribe from '@/widgets/Subscribe/Subscribe'
import { ViewedProducts } from '@/widgets/ViewedProducts/ViewedProducts'

const MainPage = () => {
const MainPage: FC = () => {
return (
<>
<HeroBlock />
Expand Down
4 changes: 2 additions & 2 deletions src/pages/RootPage/RootPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import styles from './root.module.scss'

const RootPage = () => {
return (
<div className={styles.rootPageWrapper}>
<>
<Header />
<main className={styles.main}>
<Outlet />
</main>
<Footer />
<Contact messenger={messengerArray} />
</div>
</>
)
}

Expand Down
11 changes: 3 additions & 8 deletions src/pages/RootPage/root.module.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
.rootPageWrapper {
display: grid;
grid-template-rows: auto 1fr auto;
min-height: 100vh;
margin: 0;
}

.main {
display: flex;
flex-direction: column;
gap: 60px;
align-items: center;
gap: 23px;
width: 100%;
}
20 changes: 16 additions & 4 deletions src/shared/ui/CategoryCard/ui/CategoryCard.module.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
@use '../../../styles/utils/variables' as var;
@use '@/shared/styles/utils/variables' as var;
@use '@/shared/styles/utils/mixins' as media;

.div {
.categoryCard {
display: block;
padding: 20px 0 0 20px;
width: 100%;
min-width: 420px;
height: 300px;
min-width: 450px;
min-height: 300px;
border-radius: 10px;
background-position: right;
background-size: contain;
background-repeat: no-repeat;
transition: opacity 0.3s ease-in-out;
user-select: none;

@include media.respond-to('large') {
min-width: 340px;
min-height: 260px;
}

@include media.respond-to('middle') {
min-width: 260px;
min-height: 260px;
}

&:hover {
opacity: 0.8;
Expand Down
23 changes: 11 additions & 12 deletions src/shared/ui/CategoryCard/ui/CategoryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@ interface CategoryCardProps {
* @param {object} card - объект категории для отображения названия и фотографии;
* @param {number} index - индекс элемента массива категорий для выбора цвета;
*/

const CategoryCard: FC<CategoryCardProps> = ({ card, index }) => {
const dispatch = useDispatch<AppDispatch>()
return (
<li>
<Link
to={`${Routes.CATEGORIES}/${card.slug}`}
onClick={() => {
dispatch(setCategoryId(card.id))
dispatch(setCategorySlug(card.slug))
}}
className={styles.div}
style={{ backgroundColor: COLORS[index], backgroundImage: `url(${card.image})` }}>
<Subheading className={styles.subheading}>{card.name}</Subheading>
</Link>
</li>
<Link
to={`${Routes.CATEGORIES}/${card.slug}`}
onClick={() => {
dispatch(setCategoryId(card.id))
dispatch(setCategorySlug(card.slug))
}}
className={styles.categoryCard}
style={{ backgroundColor: COLORS[index], backgroundImage: `url(${card.image})` }}>
<Subheading className={styles.subheading}>{card.name}</Subheading>
</Link>
)
}

Expand Down
30 changes: 23 additions & 7 deletions src/shared/ui/Scroll/Scroll.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use '@/app/styles/index' as var;
@use '@/shared/styles/utils/variables' as var;
@use '@/shared/styles/utils/mixins' as media;

.extra {
background-color: orange;
Expand All @@ -13,21 +14,36 @@
.scroll {
display: flex;
gap: 20px;
padding: 0 10px 20px;
padding-bottom: 20px;
overflow: auto hidden;
cursor: grab;

@include media.respond-to('middle') {
gap: 10px;
}

&::-webkit-scrollbar {
height: 3px;

@include media.respond-to('middle') {
height: 2px;
}
}

&::-webkit-scrollbar-thumb {
background: var.$theme-primary-color;
cursor: grab;
background: var.$footer-form-color;
visibility: hidden;
}

&:hover {
&::-webkit-scrollbar-thumb {
visibility: visible;
}
}

&::-webkit-scrollbar-track {
margin-left: 10px;
margin-right: 10px;
&:active {
&::-webkit-scrollbar-thumb {
visibility: visible;
}
}
}
2 changes: 1 addition & 1 deletion src/shared/ui/Scroll/Scroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Scroll: FC<TProps> = ({ withManualGrip = false, className, children }) =>
{children}
</div>
) : (
<div className={`${styles.scroll} ${className}`}>{children}</div>
<ul className={`${styles.scroll} ${className}`}>{children}</ul>
)
}

Expand Down
Loading

0 comments on commit 9b51623

Please sign in to comment.