-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#141-enhancement-changed-component-NewsBlock-to-fsd #203
Merged
JuliaAvramenko
merged 1 commit into
master
from
enhancement-141-change-component-News-to-fsd
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
@use '@/app/styles/index' as var; | ||
|
||
.card { | ||
min-width: 340px; | ||
position: relative; | ||
transition: transform 0.3s ease-in-out; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
gap: 15px; | ||
|
||
&:hover { | ||
transform: scale(1.1, 1.05); | ||
transition: transform 0.3s ease-in-out; | ||
} | ||
|
||
img { | ||
border-radius: 6px; | ||
transition: transform 0.3s ease-in-out; | ||
scroll-snap-align: start; | ||
} | ||
|
||
h3 { | ||
width: 95%; | ||
font-size: #{'min(max(14px, 1.2vw), 16px)'}; | ||
line-height: 150%; | ||
font-weight: 500; | ||
} | ||
|
||
&:hover h3 { | ||
color: var.$link-color; | ||
} | ||
|
||
span { | ||
color: var.$body-color-light-grey; | ||
} | ||
|
||
.promo { | ||
display: inline-block; | ||
position: absolute; | ||
top: 15px; | ||
left: 15px; | ||
background: var.$promo-color; | ||
border-radius: 5px; | ||
padding: 5px 10px; | ||
color: var.$white; | ||
font-size: 15px; | ||
line-height: 120%; | ||
font-weight: 500; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import NewsCard from './NewsCard' | ||
import Img1 from '@/assets/images/news/img-news-01.png' | ||
|
||
const meta = { | ||
title: 'entities/NewsCard', | ||
component: NewsCard, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
tags: ['autodocs'] | ||
} satisfies Meta<typeof NewsCard> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = { | ||
args: { | ||
card: { | ||
id: 1, | ||
src: Img1, | ||
alt: 'Покупай и не жди. До -50% на весь электротранспорт!', | ||
title: 'Покупай и не жди. До -50% на весь электротранспорт!', | ||
date: '15 Мая, 2022', | ||
promo: true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { FC } from 'react' | ||
import { TCard } from '@/models/CardModel' | ||
import { TEXT_PROMO } from '@/shared/constants/constants' | ||
import styles from './NewsCard.module.scss' | ||
import Link from '@/shared/ui/Link/Link' | ||
|
||
export type Props = { | ||
card: TCard | ||
} | ||
|
||
/** | ||
* Карточка из блока группы новостей | ||
* @param {TCard} card - параметры карточки из группы новостей | ||
*/ | ||
|
||
const NewsCard: FC<Props> = ({ card }) => { | ||
return ( | ||
<Link to={''} className={styles.card}> | ||
<img src={card.src} alt={card.alt} draggable="false" /> | ||
<h3>{card.title}</h3> | ||
<span>{card.date}</span> | ||
{card.promo ? <span className={styles.promo}>{TEXT_PROMO}</span> : null} | ||
</Link> | ||
) | ||
} | ||
|
||
export default NewsCard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export type TProps = { | ||
styles?: Array<string> | string | ||
className?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@use '@/app/styles/index' as var; | ||
|
||
.extra { | ||
background-color: orange; | ||
min-width: 200px; | ||
} | ||
|
||
.additional { | ||
width: 1000px; | ||
height: 100px; | ||
} | ||
|
||
.scroll { | ||
display: flex; | ||
gap: 20px; | ||
padding: 0 10px 20px; | ||
overflow: auto hidden; | ||
cursor: grab; | ||
|
||
&::-webkit-scrollbar { | ||
height: 3px; | ||
} | ||
|
||
&::-webkit-scrollbar-thumb { | ||
background: var.$theme-primary-color; | ||
cursor: grab; | ||
} | ||
|
||
&::-webkit-scrollbar-track { | ||
margin-left: 10px; | ||
margin-right: 10px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { FC } from 'react' | ||
import Scroll from './Scroll' | ||
import styles from './Scroll.module.scss' | ||
|
||
const StorybookWrapper: FC = () => { | ||
return ( | ||
<Scroll className={styles.additional}> | ||
<div className={styles.extra}></div> | ||
<div className={styles.extra}></div> | ||
<div className={styles.extra}></div> | ||
<div className={styles.extra}></div> | ||
<div className={styles.extra}></div> | ||
</Scroll> | ||
) | ||
} | ||
|
||
const meta = { | ||
title: 'shared/Scroll', | ||
component: StorybookWrapper, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
tags: ['autodocs'] | ||
} satisfies Meta<typeof StorybookWrapper> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: <div></div> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { FC } from 'react' | ||
import styles from './Scroll.module.scss' | ||
|
||
export type TProps = { | ||
className?: string | ||
children: React.ReactNode | ||
} | ||
|
||
/** | ||
* Scrollbar | ||
* @param {string} className - для дополнительных свойств | ||
* @param {React.ReactNode} children - элементы внутри компонента | ||
*/ | ||
const Scroll: FC<TProps> = ({ className, children }) => { | ||
return <div className={`${styles.scroll} ${className}`}>{children}</div> | ||
} | ||
|
||
export default Scroll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
@use '@/app/styles/index' as var; | ||
|
||
.storybook { | ||
width: 1080px; | ||
} | ||
|
||
.wrapper { | ||
width: 100%; | ||
margin: 0 auto; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 18px; | ||
|
||
h2 { | ||
font-size: #{'min(max(18px, 1.6vw), 20px)'}; | ||
line-height: 115%; | ||
font-weight: 500; | ||
} | ||
|
||
article { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: flex-end; | ||
padding: 0 10px; | ||
} | ||
|
||
.link { | ||
font-size: 15px; | ||
line-height: 120%; | ||
font-weight: 500; | ||
|
||
&:hover { | ||
opacity: 0.7; | ||
} | ||
} | ||
|
||
.svg { | ||
width: 1.25rem; | ||
height: 0.5625rem; | ||
margin-left: 0.5rem; | ||
vertical-align: middle; | ||
} | ||
|
||
ul { | ||
display: flex; | ||
gap: 20px; | ||
padding: 0 10px 20px; | ||
overflow: auto hidden; | ||
cursor: grab; | ||
|
||
&::-webkit-scrollbar { | ||
height: 3px; | ||
} | ||
|
||
&::-webkit-scrollbar-thumb { | ||
background: var.$theme-primary-color; | ||
cursor: grab; | ||
} | ||
|
||
&::-webkit-scrollbar-track { | ||
margin-left: 10px; | ||
margin-right: 10px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import styles from './NewsBlock.module.scss' | ||
import { FC } from 'react' | ||
import NewsBlock from './NewsBlock' | ||
|
||
const StorybookWrapper: FC = () => { | ||
return ( | ||
<div className={styles.storybook}> | ||
<NewsBlock /> | ||
</div> | ||
) | ||
} | ||
|
||
const meta = { | ||
title: 'widgets/NewsBlock', | ||
component: StorybookWrapper, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
tags: ['autodocs'] | ||
} satisfies Meta<typeof StorybookWrapper> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { FC } from 'react' | ||
import IconLink from '@/assets/icons/IconLink' | ||
import Heading, { HeadingType } from '@/shared/ui/Heading/Heading' | ||
import Link from '@/shared/ui/Link/Link' | ||
import styles from './NewsBlock.module.scss' | ||
import NewsCard from '@/entities/NewsCard/NewsCard' | ||
import { newsData } from '@/mockData/newsData' | ||
import Scroll from '@/shared/ui/Scroll/Scroll' | ||
|
||
/** | ||
* Блок группы новостей | ||
*/ | ||
const NewsBlock: FC = () => { | ||
return ( | ||
<section className={styles.wrapper}> | ||
<article> | ||
<Heading type={HeadingType.NORMAL}>Новости</Heading> | ||
<Link to={'#'} className={styles.link}> | ||
Все новости | ||
<IconLink styles={styles.svg}></IconLink> | ||
</Link> | ||
</article> | ||
<Scroll> | ||
{newsData.map(item => ( | ||
<NewsCard key={item.id} card={item} /> | ||
))} | ||
</Scroll> | ||
</section> | ||
) | ||
} | ||
|
||
export default NewsBlock |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h3 в типографике нет?