-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:skbkontur/retail-ui into react-17
- Loading branch information
Showing
11 changed files
with
125 additions
and
2 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
50 changes: 50 additions & 0 deletions
50
packages/react-ui-validations/stories/Switcher.stories.tsx
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,50 @@ | ||
import { storiesOf } from '@storybook/react'; | ||
import React from 'react'; | ||
import { Button } from '@skbkontur/react-ui/components/Button'; | ||
import { Switcher } from '@skbkontur/react-ui/components/Switcher/Switcher'; | ||
|
||
import { ValidationContainer, ValidationInfo, ValidationWrapper } from '../src'; | ||
import { Nullable } from '../typings/Types'; | ||
|
||
storiesOf('Switcher', module).add('required', () => <SwitcherStory />); | ||
|
||
interface SwitcherStoryState { | ||
value: string; | ||
} | ||
|
||
class SwitcherStory extends React.Component<{}, SwitcherStoryState> { | ||
public state: SwitcherStoryState = { | ||
value: '', | ||
}; | ||
|
||
private container: ValidationContainer | null = null; | ||
|
||
public validateValue(): Nullable<ValidationInfo> { | ||
const { value } = this.state; | ||
if (!value) { | ||
return { message: 'Поле обязательно', type: 'submit' }; | ||
} | ||
return null; | ||
} | ||
|
||
public render() { | ||
return ( | ||
<div style={{ padding: '20px 20px' }}> | ||
<ValidationContainer ref={this.refContainer}> | ||
<ValidationWrapper validationInfo={this.state.value === '' ? this.validateValue() : undefined}> | ||
<Switcher | ||
value={this.state.value} | ||
items={['string1', 'string2']} | ||
onValueChange={value => this.setState({ value })} | ||
/> | ||
</ValidationWrapper> | ||
<div style={{ padding: '20px 0' }}> | ||
<Button onClick={() => this.container && this.container.validate()}>Check</Button> | ||
</div> | ||
</ValidationContainer> | ||
</div> | ||
); | ||
} | ||
|
||
private refContainer = (el: ValidationContainer | null) => (this.container = el); | ||
} |
3 changes: 3 additions & 0 deletions
3
.../react-ui/.creevey/images/SidePage/Left SidePage With Right SidePage/chrome.png
Loading
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
...act-ui/.creevey/images/SidePage/Left SidePage With Right SidePage/chrome8px.png
Loading
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
...react-ui/.creevey/images/SidePage/Left SidePage With Right SidePage/firefox.png
Loading
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
...ct-ui/.creevey/images/SidePage/Left SidePage With Right SidePage/firefox8px.png
Loading
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
...es/react-ui/.creevey/images/SidePage/Left SidePage With Right SidePage/ie11.png
Loading
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
...react-ui/.creevey/images/SidePage/Left SidePage With Right SidePage/ie118px.png
Loading
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
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