-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(project): add card component and first test
- Loading branch information
1 parent
31fc7ff
commit e82f950
Showing
5 changed files
with
87 additions
and
1 deletion.
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 @@ | ||
import '@testing-library/jest-dom' |
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,43 @@ | ||
.root { | ||
position: relative; | ||
overflow: hidden; | ||
width: 100%; | ||
} | ||
|
||
.oneOne { | ||
padding-bottom: 100%; | ||
} | ||
|
||
.twoOne { | ||
padding-bottom: 50%; | ||
} | ||
|
||
.twoThree { | ||
padding-bottom: (3 / 2) * 100%; | ||
} | ||
|
||
.fiveThree { | ||
padding-bottom: 60%; | ||
} | ||
|
||
.fourThree { | ||
padding-bottom: 75%; | ||
} | ||
|
||
.sixteenNine { | ||
padding-bottom: (9 / 16) * 100%; | ||
} | ||
|
||
.container { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: var(--card-slider-loading-card-bg); | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
border-radius: 4px; | ||
} | ||
|
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,12 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import Card from './Card'; | ||
|
||
describe('<Card>', () => { | ||
it('renders card', () => { | ||
const { getByText } = render(<Card title="aa" duration={120} />); | ||
const card = getByText(/card/i); | ||
expect(card).toBeTruthy(); | ||
}); | ||
}); |
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,30 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
import { ASPECT_RATIO } from '../../enum/Card.js' | ||
|
||
import styles from './Card.module.scss'; | ||
|
||
type CardProps = { | ||
title: string; | ||
duration: number; | ||
imageSource?: string; | ||
aspectRatio?: string; | ||
}; | ||
|
||
function Card({ | ||
title, | ||
duration, | ||
imageSource, | ||
aspectRatio = ASPECT_RATIO[16_9], | ||
}: CardProps): JSX.Element { | ||
return ( | ||
<div className={classNames(styles.root, styles[aspectRatio])}> | ||
<div className={styles.container} style={{ backgroundImage: `url(${imageSource})` }}> | ||
<span>Card</span> | ||
</div> | ||
</div > | ||
); | ||
} | ||
|
||
export default Card; |
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