-
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.
* refactor(plate): change layout, change closer size * feat(alert): add component * chore: update screenshots * fix(alert): fixes * fix(alert): screenshots * feat(plate): add buttons * chore(alert): add buttons * fix(alert): change button margin, add tests * fix(plate): fix styles * feat(plate): styles * feat(plate): max content width * feat(alert): max content width * feat(plate): max content width * feat(plate): colorize icons, update docs * feat(plate): use badge, fix margin
- Loading branch information
Showing
22 changed files
with
468 additions
and
117 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,22 @@ | ||
{ | ||
"name": "@alfalab/core-components-alert", | ||
"version": "1.0.0", | ||
"description": "", | ||
"keywords": [], | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"module": "./dist/esm/index.js", | ||
"files": [ | ||
"dist" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.9.0 || ^17.0.1" | ||
}, | ||
"dependencies": { | ||
"@alfalab/core-components-plate": "^1.3.4", | ||
"classnames": "^2.2.6" | ||
} | ||
} |
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,56 @@ | ||
import { screenshotTesting, getComponentScreenshotTestCases } from '../../utils'; | ||
|
||
const clip = { x: 0, y: 0, width: 1920, height: 100 }; | ||
|
||
describe( | ||
'Alert | screenshots views', | ||
screenshotTesting({ | ||
cases: getComponentScreenshotTestCases({ | ||
componentName: 'alert', | ||
knobs: { | ||
view: ['common', 'negative', 'positive', 'attention'], | ||
}, | ||
}), | ||
it, | ||
beforeAll, | ||
afterAll, | ||
expect, | ||
screenshotOpts: { clip }, | ||
}), | ||
); | ||
|
||
describe( | ||
'Alert | screenshots with title and closer', | ||
screenshotTesting({ | ||
cases: getComponentScreenshotTestCases({ | ||
componentName: 'alert', | ||
knobs: { | ||
title: ['Title', ''], | ||
hasCloser: [true, false], | ||
}, | ||
}), | ||
it, | ||
beforeAll, | ||
afterAll, | ||
expect, | ||
screenshotOpts: { clip }, | ||
}), | ||
); | ||
|
||
describe( | ||
'Alert | screenshots with buttons', | ||
screenshotTesting({ | ||
cases: getComponentScreenshotTestCases({ | ||
componentName: 'alert', | ||
knobs: { | ||
buttons: [true], | ||
title: ['Title', ''], | ||
}, | ||
}), | ||
it, | ||
beforeAll, | ||
afterAll, | ||
expect, | ||
screenshotOpts: { clip: { ...clip, height: 140 } }, | ||
}), | ||
); |
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,55 @@ | ||
import { Meta, Story, Preview, Props } from '@storybook/addon-docs/blocks'; | ||
import { select, text, boolean } from '@storybook/addon-knobs'; | ||
import { Container, Row, Col } from 'storybook/blocks/grid'; | ||
import { ComponentHeader } from 'storybook/blocks/component-header'; | ||
|
||
import { Alert } from './Component'; | ||
import { Button } from '../../button/src'; | ||
|
||
import { name, version } from '../package.json'; | ||
|
||
<Meta | ||
title='Компоненты' | ||
component={Alert} | ||
/> | ||
|
||
|
||
<!-- Canvas --> | ||
|
||
<Story name='Alert'> | ||
<Alert | ||
view={select('view', ['common', 'negative', 'positive', 'attention'], 'common')} | ||
title={text('title', '')} | ||
hasCloser={boolean('hasCloser', false)} | ||
buttons={boolean('buttons', false) ? [ | ||
<Button>Хорошо</Button>, | ||
<Button>Подробнее</Button> | ||
] : null} | ||
> | ||
{text('children', 'Вам одобрено. Согласитесь на предложение')} | ||
</Alert> | ||
</Story> | ||
|
||
|
||
<!-- Docs --> | ||
|
||
<ComponentHeader | ||
name='Alert' | ||
version={version} | ||
package='@alfalab/core-components-alert' | ||
stage={1} | ||
/> | ||
|
||
```tsx | ||
import { Alert } from '@alfalab/core-components-alert'; | ||
``` | ||
|
||
## Alert | ||
|
||
Информирует пользователя о чем-либо. Может использоваться как сообщение, комментарий или предупреждение от системы. | ||
|
||
<Alert> | ||
Вам одобрено. Согласитесь на предложение | ||
</Alert> | ||
|
||
<Props of={Alert} /> |
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 cn from 'classnames'; | ||
|
||
import { Plate, PlateProps } from '@alfalab/core-components-plate'; | ||
|
||
import styles from './index.module.css'; | ||
|
||
export type AlertProps = Omit<PlateProps, 'foldable' | 'defaultFolded' | 'leftAddons'>; | ||
|
||
export const Alert: FC<AlertProps> = ({ className, title, ...restProps }) => ( | ||
<Plate | ||
className={cn(styles.component, className)} | ||
buttonsClassName={styles.buttons} | ||
contentClassName={styles.content} | ||
title={title ? <span className={styles.title}>{title}</span> : null} | ||
{...restProps} | ||
/> | ||
); |
3 changes: 3 additions & 0 deletions
3
packages/alert/src/__image_snapshots__/buttons-true-title-1-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/alert/src/__image_snapshots__/buttons-true-title-title-1-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/alert/src/__image_snapshots__/title-has-closer-false-1-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/alert/src/__image_snapshots__/title-has-closer-true-1-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/alert/src/__image_snapshots__/title-title-has-closer-false-1-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/alert/src/__image_snapshots__/title-title-has-closer-true-1-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/alert/src/__image_snapshots__/view-attention-1-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/alert/src/__image_snapshots__/view-common-1-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/alert/src/__image_snapshots__/view-negative-1-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/alert/src/__image_snapshots__/view-positive-1-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
@import '../../themes/src/default.css'; | ||
|
||
.component { | ||
border-radius: 2px 0 0 2px; | ||
border-top: 0; | ||
border-right: 0; | ||
border-bottom: 0; | ||
border-left-width: 2px; | ||
padding-top: var(--gap-s); | ||
padding-bottom: var(--gap-s); | ||
padding-right: var(--gap-s); | ||
min-height: 48px; | ||
} | ||
|
||
.buttons { | ||
margin-top: var(--gap-m); | ||
} | ||
|
||
.title { | ||
@mixin accent_primary_medium; | ||
} | ||
|
||
.content { | ||
max-width: none; | ||
} |
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 @@ | ||
{ | ||
"include": ["src", "../../typings"], | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDirs": ["src"], | ||
"baseUrl": ".", | ||
"paths": { | ||
"@alfalab/core-components-*": ["../*/src"] | ||
} | ||
}, | ||
"references": [{ "path": "../plate" }] | ||
} |
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
Oops, something went wrong.