diff --git a/src/features/creators/data.ts b/src/features/creators/data.ts index f077820..8d5a802 100644 --- a/src/features/creators/data.ts +++ b/src/features/creators/data.ts @@ -1,7 +1,7 @@ import { SocialNetworkEnum, type CreatorInfo } from './types'; import nhr_1 from '../../shared/assets/img/nhr_1.webp'; import nhr_2 from '../../shared/assets/img/nhr_2.webp'; -import vpm from '../../shared/assets/img/vpm.jpg' +import vpm from '../../shared/assets/img/vpm.jpg'; import mkm_1 from '../../shared/assets/img/mkm_1.webp'; export const creators: CreatorInfo[] = [ @@ -60,5 +60,5 @@ export const creators: CreatorInfo[] = [ icon: SocialNetworkEnum.TELEGRAM, }, ], - } + }, ]; diff --git a/src/features/home/components/CategoryItem/CategoryItem.scss b/src/features/home/components/CategoryItem/CategoryItem.scss index 1494e6a..00ce2dc 100644 --- a/src/features/home/components/CategoryItem/CategoryItem.scss +++ b/src/features/home/components/CategoryItem/CategoryItem.scss @@ -2,22 +2,56 @@ @use '../../../../shared/styles/vars' as *; @use '../../../../shared/styles/mixins' as *; +$animation-duration: 0.4s; + .category-item { cursor: pointer; display: flex; flex-direction: column; width: 100%; - transition: transform $base-transition ease-in-out; - - &:hover { - transform: translateY(-#{map.get($spacing, 'sm')}); + &__media-wrapper { + padding-bottom: 100%; + height: 0; + position: relative; + overflow: hidden; + margin-bottom: map.get($spacing, 'xl'); } - &__img { + &__media { + position: absolute; + top: 0; + left: 0; width: 100%; + height: 100%; object-fit: cover; - margin-bottom: map.get($spacing, 'xl'); + + transition: + transform $animation-duration ease-out, + opacity $animation-duration ease-out; + } + + &__media--img { + transform: scale(1); + opacity: 1; + z-index: 2; + } + + .hidden-on-hover { + transform: scale(0.95); + opacity: 0; + } + + &__media--video { + transform: scale(0.9); + opacity: 0; + z-index: 1; + } + + .visible-on-hover { + transform: scale(1); + opacity: 1; + z-index: 3; } &__title { @@ -26,6 +60,6 @@ } &__count { - color: #89939a; + color: map.get($colors, 'gray-light');; } -} +} \ No newline at end of file diff --git a/src/features/home/components/CategoryItem/CategoryItem.tsx b/src/features/home/components/CategoryItem/CategoryItem.tsx index 48ce512..c7f9d29 100644 --- a/src/features/home/components/CategoryItem/CategoryItem.tsx +++ b/src/features/home/components/CategoryItem/CategoryItem.tsx @@ -1,35 +1,58 @@ -import React from 'react'; +import React, { useState } from 'react'; import './CategoryItem.scss'; import { useTranslation } from 'react-i18next'; type Props = { categoryImg: string; + categoryVideo: string; categoryQuantity: number; categoryName: string; }; const CategoryItem: React.FC = ({ categoryImg, + categoryVideo, categoryQuantity, categoryName, }) => { const { t } = useTranslation('homePage'); + const [isHovered, setIsHovered] = useState(false); return ( -
-
+
setIsHovered(true)} + onMouseLeave={() => setIsHovered(false)} + > +
+ {categoryName} + + {categoryVideo && ( +

{t(categoryName)}

-

{categoryQuantity} models

); }; -export default CategoryItem; +export default CategoryItem; \ No newline at end of file diff --git a/src/features/home/components/CategoryList/CategoryList.tsx b/src/features/home/components/CategoryList/CategoryList.tsx index cc7a8bd..fe04510 100644 --- a/src/features/home/components/CategoryList/CategoryList.tsx +++ b/src/features/home/components/CategoryList/CategoryList.tsx @@ -7,6 +7,10 @@ import { CategoryLabels } from '../../../catalog/types'; import categoryPhones from '../../../../shared/assets/img/category-phones.webp'; import categoryTablets from '../../../../shared/assets/img/category-tablets.webp'; import categoryAccessories from '../../../../shared/assets/img/category-accessories.webp'; +import categoryPhonesVideo from '../../../../shared/assets/video/video-1.webm'; +import categoryTabletsVideo from '../../../../shared/assets/video/video-2.webm'; +import categoryAccessoriesVideo from '../../../../shared/assets/video/video-3.webm'; + import type { Category } from '../../../../services/product'; import { Link } from 'react-router-dom'; import { useLanguage } from '../../../../shared/context/language'; @@ -35,16 +39,25 @@ const CategoryList: React.FC = ({ sectionTitle }) => { fetchCategoryStats(); }, []); - const getCategoryImage = (category: string) => { + const getCategoryMedia = (category: string) => { switch (category.toLowerCase()) { case 'phones': - return categoryPhones; + return { + img: categoryPhones, + video: categoryPhonesVideo, + }; case 'tablets': - return categoryTablets; + return { + img: categoryTablets, + video: categoryTabletsVideo, + }; case 'accessories': - return categoryAccessories; + return { + img: categoryAccessories, + video: categoryAccessoriesVideo, + }; default: - return ''; + return { img: '', video: '' }; } }; @@ -52,17 +65,22 @@ const CategoryList: React.FC = ({ sectionTitle }) => {

{sectionTitle}

    - {categories.map((category) => ( -
  • - - - -
  • - ))} + {categories.map((category) => { + const media = getCategoryMedia(category.category); + + return ( +
  • + + + +
  • + ); + })}
); diff --git a/src/shared/assets/video/video-1.webm b/src/shared/assets/video/video-1.webm new file mode 100644 index 0000000..d1add46 Binary files /dev/null and b/src/shared/assets/video/video-1.webm differ diff --git a/src/shared/assets/video/video-2.webm b/src/shared/assets/video/video-2.webm new file mode 100644 index 0000000..27fa57e Binary files /dev/null and b/src/shared/assets/video/video-2.webm differ diff --git a/src/shared/assets/video/video-3.webm b/src/shared/assets/video/video-3.webm new file mode 100644 index 0000000..b9ca183 Binary files /dev/null and b/src/shared/assets/video/video-3.webm differ