-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(textarea): add value counter (#695)
* feat(textarea): add value counter * feat(textarea): remove pluralize from counter text
- Loading branch information
Showing
10 changed files
with
240 additions
and
63 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
3 changes: 3 additions & 0 deletions
3
packages/textarea/src/__image_snapshots__/textarea-sprite-click-counter-snap.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
packages/textarea/src/__image_snapshots__/textarea-sprite-default-counter-snap.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
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,66 @@ | ||
import { Meta, Story, Props, Preview } from '@storybook/addon-docs/blocks'; | ||
import { text, select, boolean, number } from '@storybook/addon-knobs'; | ||
import { CssVars, ComponentHeader, Tabs } from 'storybook/blocks'; | ||
import Icon from '@alfalab/icons-glyph/StarMIcon'; | ||
|
||
import { Textarea } from '..'; | ||
import { name, version } from '../../package.json'; | ||
|
||
import styles from '!!raw-loader!../index.module.css'; | ||
import Description from './description.mdx'; | ||
|
||
<Meta | ||
title='Компоненты' | ||
component={Textarea} | ||
parameters={{ 'theme-switcher': { themes: ['click'] } }} | ||
/> | ||
|
||
<!-- Canvas --> | ||
|
||
<Story name='Textarea'> | ||
{React.createElement(() => { | ||
const showCounter = boolean('showCounter', false); | ||
return ( | ||
<Textarea | ||
autosize={boolean('autosize', true)} | ||
block={boolean('block', false)} | ||
size={select('size', ['s', 'm', 'l', 'xl'], 's')} | ||
disabled={boolean('disabled', false)} | ||
placeholder={text('placeholder', '')} | ||
resize={select('resize', ['none', 'vertical'], 'none')} | ||
minRows={number('minRows', undefined)} | ||
maxRows={number('maxRows', undefined)} | ||
maxHeight={number('maxHeight', undefined)} | ||
label={text('label', '')} | ||
hint={text('hint', '')} | ||
error={text('error', '')} | ||
rightAddons={boolean('rightAddons', false) && !text('error') && <Icon />} | ||
leftAddons={boolean('leftAddons', false) && <Icon />} | ||
bottomAddons={boolean('bottomAddons', false) && <span>bottom text</span>} | ||
readOnly={boolean('readOnly', false)} | ||
showCounter={showCounter} | ||
maxLength={showCounter && 500} | ||
/> | ||
); | ||
})} | ||
</Story> | ||
|
||
<!-- Docs --> | ||
|
||
<ComponentHeader | ||
name='Textarea' | ||
version={version} | ||
package='@alfalab/core-components-textarea' | ||
stage={2} | ||
design='https://www.figma.com/file/hqSP3L6qu8UcL3sf18Su1M/Web-Components?node-id=49%3A0' | ||
/> | ||
|
||
```tsx | ||
import { Textarea } from '@alfalab/core-components/textarea'; | ||
``` | ||
|
||
<Tabs | ||
description={<Description />} | ||
prpos={<Props of={Textarea} />} | ||
cssVars={<CssVars css={styles} />} | ||
/> |
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 @@ | ||
import { Textarea } from '..'; | ||
|
||
Компонент текстового поля ввода. | ||
|
||
```tsx live | ||
<Textarea /> | ||
``` | ||
|
||
Со счетчиком: | ||
|
||
```tsx live | ||
<Textarea showCounter={true} maxLength={500} /> | ||
``` |
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