Skip to content

Commit

Permalink
Merge pull request #74 from FelipeZNascimento/newscard-component-fixe…
Browse files Browse the repository at this point in the history
…s-on-sidenav-titlecontainer

Newscard component fixes on sidenav titlecontainer
  • Loading branch information
FelipeZNascimento authored Oct 11, 2022
2 parents c6c9e80 + 630e47c commit 8c19119
Show file tree
Hide file tree
Showing 17 changed files with 255 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@omegafox/components",
"version": "2.14.3",
"version": "2.15.0",
"description": "Omegafox component library using Rollup, TypeScript, Sass and Storybook",
"main": "dist/index.js",
"typings": "dist/src/index",
Expand Down
1 change: 1 addition & 0 deletions src/components/Match/Match.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const Match = ({
return (
<Team
align={team.align}
abbreviationEn={team.abbreviationEn}
key={team.id}
bet={bet === undefined ? null : bet}
betValue={betValue}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Match/mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FOOTBALL_MATCH_STATUS } from '../Clock/constants';
const matchId = 0;
export const teamLeft: ITeamProps = {
id: 0,
abbreviationEn: 'Bra',
align: 'left',
bet: 3,
colors: ['#FFDC02', '#19AE47'],
Expand All @@ -16,6 +17,7 @@ export const teamLeft: ITeamProps = {

export const teamRight: ITeamProps = {
id: 1,
abbreviationEn: 'Arg',
align: 'right',
bet: 0,
colors: ['#FFFFFF', '#43A1D5'],
Expand Down
104 changes: 104 additions & 0 deletions src/components/NewsCard/NewsCard.module.scss
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%;
}
}
36 changes: 36 additions & 0 deletions src/components/NewsCard/NewsCard.test.tsx
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();
});
});
29 changes: 29 additions & 0 deletions src/components/NewsCard/NewsCard.tsx
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 src/components/NewsCard/__snapshots__/NewsCard.test.tsx.snap
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>
`;
7 changes: 7 additions & 0 deletions src/components/NewsCard/types.ts
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;
}
7 changes: 4 additions & 3 deletions src/components/Sidenav/Sidenav.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
@include font-sized(l2);
@include flex-aligned(center, center);

flex: 1 0 auto;
flex-direction: column;
height: 100%;
position: fixed;
height: 100vh;
left: 0;
position: sticky;
top: 0;
max-width: 60vw;
z-index: $always-on-top + 1;

&Open {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Team/Team.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@
z-index: $absolute-visible;

&Clickable {
text-decoration: underline dotted transparent;
text-decoration: underline transparent;
cursor: pointer;
transition: text-decoration $transition-time;

&:hover {
text-decoration: underline dotted;
text-decoration: underline;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Team/Team.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jest.mock('components/Tooltip/Tooltip');
describe('TeamComponent', () => {
const renderComponent = ({
align,
abbreviationEn,
colors,
id,
isEditable,
Expand All @@ -20,6 +21,7 @@ describe('TeamComponent', () => {
render(
<Team
align={align}
abbreviationEn={abbreviationEn}
colors={colors}
id={id}
isEditable={isEditable}
Expand All @@ -33,6 +35,7 @@ describe('TeamComponent', () => {
it('should render', () => {
const { container } = renderComponent({
align: teamLeft.align,
abbreviationEn: teamLeft.abbreviationEn,
colors: teamLeft.colors,
id: teamLeft.id,
isEditable: false,
Expand Down
1 change: 1 addition & 0 deletions src/components/Team/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BET_VALUES } from '../Match/constants';
export interface ITeamProps {
id: number;
align: 'right' | 'left';
abbreviationEn: string;
bet?: number | null;
betValue?: typeof BET_VALUES[keyof typeof BET_VALUES] | null;
colors: string[];
Expand Down
2 changes: 1 addition & 1 deletion src/components/TitleContainer/TitleContainer.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@include flex-aligned(center, center);
@include font-sized(l3);
@include padded(all, l);
@include bg-rgba-colored($color-grey1, 0.7);
@include bg-colored($color-grey1);
@include font-colored($color-qatar-red);

-webkit-box-shadow: inset 0px 0px 0px 2px $color-qatar-red;
Expand Down
2 changes: 2 additions & 0 deletions src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export { Loading } from './Loading/Loading';
export { Modal } from './Modal/Modal';
export { Match } from './Match/Match';
export { Navbar } from './Navbar/Navbar';
export { NewsCard } from './NewsCard/NewsCard';
export { Ranking } from './Ranking/Ranking';
export { Selector } from './Selector/Selector';
export { Sidenav } from './Sidenav/Sidenav';
Expand Down Expand Up @@ -40,6 +41,7 @@ export type {
IBetId
} from './Match/types';
export type { INavbarProps, TNavbarButton } from './Navbar/types';
export type { INewsCardProps } from './NewsCard/types';
export type {
IRankingProps,
TRankingColumn,
Expand Down
1 change: 1 addition & 0 deletions src/components/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type {
} from './Match/types';
export type { IModalProps } from './Modal/types';
export type { INavbarProps, TNavbarButton } from './Navbar/types';
export type { INewsCardProps } from './NewsCard/types';
export type {
IRankingProps,
TRankingColumn,
Expand Down
3 changes: 1 addition & 2 deletions src/stories/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ Card.args = {
isHoverable={false}
isBig={false}
colors={teamLeft.colors}
logo={`https://assets.omegafox.me/img/countries_crests/${teamLeft.nameShort.toLowerCase()}.png`}
logo={`https://assets.omegafox.me/img/countries_crests/${teamLeft.abbreviationEn.toLowerCase()}.png`}
name={teamLeft.name}
nameShort={teamLeft.nameShort}
/>
</>
)
Expand Down
22 changes: 22 additions & 0 deletions src/stories/NewsCard.stories.tsx
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'
};

0 comments on commit 8c19119

Please sign in to comment.