Skip to content

Commit

Permalink
feat(attach): add progress bar (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
sklyanchuk authored and SiebenSieben committed Nov 5, 2019
1 parent 7391c9b commit fe15c5d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/attach/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,22 @@ function handleChange(value) {
</div>
</div>
```

С отображением прогресса загрузки файла
```jsx
function handleChange(value) {
setState({ value });
}

<div>
<div className='row'>
<Attach
progressBarPercent={ 50 }
buttonContent='Выберите файл'
size='s'
onChange={ handleChange }
value={ state.value }
/>
</div>
</div>
```
5 changes: 5 additions & 0 deletions src/attach/attach.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
&__no-file {
display: inline;
margin-left: 0.5em;
text-align: center;
}

&__clear {
Expand All @@ -85,6 +86,10 @@
}
}

&__progress-bar {
margin-top: var(--gap-2xs);
}

&_disabled &__control {
cursor: default;
}
Expand Down
11 changes: 10 additions & 1 deletion src/attach/attach.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Type from 'prop-types';

import Button from '../button/button';
import IconAttachment from '../icon/action/attachment';
import ProgressBar from '../progress-bar';

import cn from '../cn';
import performance from '../performance';
Expand Down Expand Up @@ -119,8 +120,10 @@ class Attach extends React.Component {
accept: Type.string,
/** Управление возможностью изменения значения компонента */
disabled: Type.bool,
/** Управляет возможностью выбора нескольких файлов */
/** Управление возможностью выбора нескольких файлов */
multiple: Type.bool,
/** Процент выполнения загрузки файла */
progressBarPercent: Type.number,
/** Размер компонента */
size: Type.oneOf(['s', 'm', 'l', 'xl']),
/** Тема компонента */
Expand Down Expand Up @@ -280,6 +283,12 @@ class Attach extends React.Component {
className={ cn('clear') }
onClick={ this.handleClearClick }
/>
{ typeof this.props.progressBarPercent !== 'undefined' && (
<ProgressBar
percent={ this.props.progressBarPercent }
className={ cn('progress-bar') }
/>
) }
</span>
);
}
Expand Down

0 comments on commit fe15c5d

Please sign in to comment.