-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
iLya Raylyan
authored and
iLya Raylyan
committed
Feb 26, 2020
1 parent
9143938
commit 0e4199c
Showing
7 changed files
with
131 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "@alfalab/core-components-divider", | ||
"version": "0.0.1-alpha.0", | ||
"description": "", | ||
"keywords": [], | ||
"license": "ISC", | ||
"main": "index.js", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.9.0" | ||
} | ||
} |
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 '../../vars/colors.css'; | ||
|
||
:root { | ||
--divider-primary-color: var(--color-dark-indigo-15); | ||
--divider-accent-color: var(--color-red-brand); | ||
} | ||
|
||
.component { | ||
background-color: var(--divider-primary-color); | ||
border-style: unset; | ||
height: 1px; | ||
} |
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 @@ | ||
/** | ||
* Vendor | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { withDesign } from 'storybook-addon-designs'; | ||
import { withKnobs } from '@storybook/addon-knobs'; | ||
|
||
/** | ||
* Components | ||
*/ | ||
|
||
import { Divider } from './Component'; | ||
|
||
export default { | ||
title: 'Common|Divider', | ||
component: Divider, | ||
decorators: [withDesign, withKnobs], | ||
}; | ||
|
||
export const Basic = () => ( | ||
<div> | ||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit.</p> | ||
<Divider /> | ||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit.</p> | ||
</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,35 @@ | ||
/** | ||
* Vendor | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
/** | ||
* Component | ||
*/ | ||
|
||
import { Divider } from './index'; | ||
import styles from './Component.module.css'; | ||
|
||
describe('Divider', () => { | ||
it('should have a default test identifier', () => { | ||
const { container } = render(<Divider />); | ||
|
||
expect(container.firstElementChild).toHaveAttribute('data-testid'); | ||
}); | ||
|
||
it('should use a dataTestId prop', () => { | ||
const testId = 'header-divider'; | ||
const { getByTestId } = render(<Divider dataTestId={testId} />); | ||
|
||
expect(getByTestId(testId)).toBeTruthy; | ||
}); | ||
|
||
it('should use a className prop', () => { | ||
const className = 'short'; | ||
const { container } = render(<Divider className={className} />); | ||
|
||
expect(container.firstElementChild?.classList).toContain(className); | ||
}); | ||
}); |
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 @@ | ||
/** | ||
* Vendor | ||
*/ | ||
|
||
import React from 'react'; | ||
import cn from 'classnames'; | ||
|
||
/** | ||
* Styles | ||
*/ | ||
|
||
import styles from './Component.module.css'; | ||
|
||
/** | ||
* Expo | ||
*/ | ||
|
||
export type DividerProps = { | ||
/** Кастомный класс */ | ||
className?: string; | ||
/** Id компонента для тестов */ | ||
dataTestId?: string; | ||
}; | ||
|
||
/** Разделитель */ | ||
export const Divider: React.FC<DividerProps> = ({ className, dataTestId }) => ( | ||
<hr className={cn(styles.component, className)} data-testid={dataTestId} /> | ||
); |
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 @@ | ||
export * from './Component'; |
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,13 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"noEmit": false, | ||
"composite": false, | ||
"emitDeclarationOnly": true, | ||
"declaration": true, | ||
"declarationDir": "dist", | ||
"types": ["../../typings/module"] | ||
}, | ||
"exclude": ["src/Component.stories.tsx", "src/Component.test.tsx"], | ||
"include": ["src"] | ||
} |