-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from FelipeZNascimento/newscard-component-fixe…
…s-on-sidenav-titlecontainer Newscard component fixes on sidenav titlecontainer
- Loading branch information
Showing
17 changed files
with
255 additions
and
9 deletions.
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
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
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,104 @@ | ||
@import "../../styling/alignments.scss"; | ||
@import "../../styling/colors.scss"; | ||
@import "../../styling/font-sizes.scss"; | ||
@import "../../styling/margins.scss"; | ||
@import "../../styling/paddings.scss"; | ||
|
||
.container { | ||
@include marged(all, s); | ||
@include shadowed($color-black, 0.4); | ||
|
||
border-radius: 16px; | ||
cursor: pointer; | ||
height: 240px; | ||
position: relative; | ||
transition: transform $transition-time; | ||
width: 160px; | ||
|
||
&:hover { | ||
transform: scale(1.2); | ||
transition: transform $transition-time; | ||
z-index: 99; | ||
} | ||
|
||
&:hover .resume { | ||
display: -webkit-box; | ||
opacity: 1; | ||
} | ||
|
||
&:hover .titleContainer { | ||
height: 80%; | ||
} | ||
|
||
&:hover .date { | ||
opacity: 1; | ||
} | ||
|
||
img { | ||
border-radius: 16px; | ||
height: 100%; | ||
left: 0; | ||
object-fit: cover; | ||
overflow: hidden; | ||
position: absolute; | ||
top: 0; | ||
width: 100%; | ||
z-index: -1; | ||
} | ||
|
||
.titleContainer { | ||
@include bg-rgba-colored($color-grey5, 0.8); | ||
@include padded(all, s2); | ||
@include flex-aligned(center, center); | ||
|
||
border-bottom-left-radius: 16px; | ||
border-bottom-right-radius: 16px; | ||
bottom: 0; | ||
flex-direction: column; | ||
height: 40%; | ||
left: 0; | ||
position: absolute; | ||
right: 0; | ||
transition: height $transition-time; | ||
} | ||
|
||
.title { | ||
@include flex-aligned(center, center); | ||
@include font-colored($color-grey1); | ||
@include font-sized(m); | ||
@include marged(all, none); | ||
|
||
display: -webkit-box; | ||
font-weight: bold; | ||
overflow: hidden; | ||
-webkit-line-clamp: 5; | ||
-webkit-box-orient: vertical; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.resume { | ||
@include flex-aligned(center, center); | ||
@include font-sized(s); | ||
@include font-colored($color-grey2); | ||
@include marged(all, none); | ||
@include padded(top, s); | ||
|
||
display: none; | ||
opacity: 0; | ||
overflow: hidden; | ||
-webkit-line-clamp: 5; | ||
-webkit-box-orient: vertical; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.date { | ||
@include aligned(center); | ||
@include font-sized(s); | ||
@include font-colored($color-grey2); | ||
|
||
opacity: 0; | ||
position: absolute; | ||
bottom: 0; | ||
width: 100%; | ||
} | ||
} |
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,36 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { NewsCard } from './NewsCard'; | ||
import { INewsCardProps } from './types'; | ||
|
||
describe('<NewsCard />', () => { | ||
const renderComponent = ({ | ||
title, | ||
resume, | ||
date, | ||
link, | ||
image | ||
}: INewsCardProps) => | ||
render( | ||
<NewsCard | ||
title={title} | ||
resume={resume} | ||
date={date} | ||
link={link} | ||
image={image} | ||
/> | ||
); | ||
|
||
it('should render', () => { | ||
const { container } = renderComponent({ | ||
title: 'title', | ||
resume: 'resume', | ||
date: 'date ago', | ||
link: '#', | ||
image: | ||
'https://s2.glbimg.com/8_XbuLD2d1XCpSP9pUOw4sc7CdY=/540x304/top/smart/filters:max_age(3600)/https://s01.video.glbimg.com/deo/vi/27/10/10971027' | ||
}); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
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,29 @@ | ||
import React from 'react'; | ||
|
||
import { INewsCardProps } from './types'; | ||
import styles from './NewsCard.module.scss'; | ||
|
||
export const NewsCard = ({ | ||
title, | ||
resume, | ||
date, | ||
link, | ||
image | ||
}: INewsCardProps) => { | ||
if (!image) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<a href={link} target="_blank" rel="noreferrer"> | ||
<div className={styles.container}> | ||
<img src={image} /> | ||
<div className={styles.titleContainer}> | ||
<p className={styles.title}>{title}</p> | ||
<p className={styles.resume}>{resume}</p> | ||
<div className={styles.date}>{date}</div> | ||
</div> | ||
</div> | ||
</a> | ||
); | ||
}; |
38 changes: 38 additions & 0 deletions
38
src/components/NewsCard/__snapshots__/NewsCard.test.tsx.snap
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,38 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<NewsCard /> should render 1`] = ` | ||
<div> | ||
<a | ||
href="#" | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
<div | ||
class="container" | ||
> | ||
<img | ||
src="https://s2.glbimg.com/8_XbuLD2d1XCpSP9pUOw4sc7CdY=/540x304/top/smart/filters:max_age(3600)/https://s01.video.glbimg.com/deo/vi/27/10/10971027" | ||
/> | ||
<div | ||
class="titleContainer" | ||
> | ||
<p | ||
class="title" | ||
> | ||
title | ||
</p> | ||
<p | ||
class="resume" | ||
> | ||
resume | ||
</p> | ||
<div | ||
class="date" | ||
> | ||
date ago | ||
</div> | ||
</div> | ||
</div> | ||
</a> | ||
</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,7 @@ | ||
export interface INewsCardProps { | ||
title: string; | ||
resume: string; | ||
link: string; | ||
image: string; | ||
date: 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
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
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
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
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,22 @@ | ||
import React from 'react'; | ||
import { Story } from '@storybook/react'; | ||
import { NewsCard as Component } from '../components/'; | ||
import { INewsCardProps } from '../components/types'; | ||
|
||
export default { | ||
props: '', | ||
component: Component | ||
}; | ||
|
||
const Template: Story<INewsCardProps> = (args) => <Component {...args} />; | ||
|
||
export const NewsCard = Template.bind({}); | ||
|
||
NewsCard.args = { | ||
title: 'title', | ||
resume: 'resume', | ||
date: 'date ago', | ||
link: '#', | ||
image: | ||
'https://s2.glbimg.com/8_XbuLD2d1XCpSP9pUOw4sc7CdY=/540x304/top/smart/filters:max_age(3600)/https://s01.video.glbimg.com/deo/vi/27/10/10971027' | ||
}; |