Skip to content

Commit

Permalink
File: add disabled prop
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorov-xyz committed Oct 16, 2019
1 parent 268e13d commit 0cbbe1f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
18 changes: 11 additions & 7 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import React, { FunctionComponent, HTMLAttributes, ReactNode, ComponentType } from 'react';
import getClassName from '../../helpers/getClassName';
import classNames from '../../lib/classNames';
import Tappable from '../Tappable/Tappable';
import CellButton from '../CellButton/CellButton';
import { HasChildren, HasRootRef } from '../../types/props';
import usePlatform from '../../hooks/usePlatform';

export interface ButtonProps extends React.HTMLAttributes<HTMLElement>, HasChildren, HasRootRef<HTMLElement> {
export interface ButtonProps extends HTMLAttributes<HTMLElement>, HasChildren, HasRootRef<HTMLElement> {
/**
* Значения `1`, `2`, `3`, `sell`, `buy` устарели. Маппинг на новые значения находится в
* статическом методе `Button.mapOldLevel(level)`. Старые значения будут удалены в 3.0.0
Expand All @@ -20,10 +20,14 @@ export interface ButtonProps extends React.HTMLAttributes<HTMLElement>, HasChild
type?: 'default' | 'cell',
align?: 'left' | 'center' | 'right',
stretched?: boolean,
before?: React.ReactNode,
after?: React.ReactNode,
component?: string | React.ComponentType,
stopPropagation?: boolean
before?: ReactNode;
after?: ReactNode;
component?: string | ComponentType;
stopPropagation?: boolean;
/**
* @ignore
*/
disabled?: boolean;
}

const mapOldLevel = level => {
Expand All @@ -43,7 +47,7 @@ const mapOldLevel = level => {
}
};

const Button: React.FunctionComponent<ButtonProps> = (props: ButtonProps) => {
const Button: FunctionComponent<ButtonProps> = (props: ButtonProps) => {
const platform = usePlatform();
if (props.type === 'cell') {
return <CellButton {...props} level={props.level === 'destructive' ? 'danger' : 'primary'}/>;
Expand Down
9 changes: 7 additions & 2 deletions src/components/File/File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ export interface FileProps extends ButtonProps, HasRef<HTMLInputElement> {
/**
* @deprecated Используйте `children`. Свойство `label` будет удалено в 3.0.0
*/
label: ButtonProps['children']
label: ButtonProps['children'];
/**
* @deprecated Используйте `align`. Свойство `alignment` будет удалено в 3.0.0
*/
alignment: ButtonProps['align']
alignment: ButtonProps['align'];
/**
* @ignore
*/
disabled?: boolean;
}

const File: FunctionComponent<FileProps> = (props: FileProps) => {
Expand All @@ -34,6 +38,7 @@ const File: FunctionComponent<FileProps> = (props: FileProps) => {
before={before}
style={style}
getRootRef={getRootRef}
disabled={restProps.disabled}
>
<input {...restProps} className="File__input" type="file" ref={getRef}/>
{children || label}
Expand Down

0 comments on commit 0cbbe1f

Please sign in to comment.