Skip to content

Commit

Permalink
feat(NumberPicker): add small size, close #1147
Browse files Browse the repository at this point in the history
  • Loading branch information
youluna committed Nov 14, 2019
1 parent 56181c9 commit 1a81522
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/number-picker/demo/size.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,19 @@ import { NumberPicker } from '@alifd/next';

ReactDOM.render(
<div>
<NumberPicker defaultValue={0} size="small" />
<NumberPicker defaultValue={0} />
<NumberPicker defaultValue={0} size="large" />
<br/><br/>
<NumberPicker defaultValue={0} size="small" type="inline" />
<NumberPicker defaultValue={0} type="inline" />
<NumberPicker defaultValue={0} size="large" type="inline" />
</div>,
mountNode
);
````
````css
.next-number-picker {
margin-right: 10px;
}
````
67 changes: 67 additions & 0 deletions src/number-picker/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@
opacity: 0;
}

&.#{$css-prefix}small {
width: 68px;
.#{$css-prefix}btn {
width: $number-picker-normal-s-button-width;

&:first-child {
border-top-right-radius: $form-element-small-corner;
}

&:last-child {
border-bottom-right-radius: $form-element-small-corner;
}
}

.#{$css-prefix}icon {
@include icon-size($number-picker-normal-s-button-icon-size);
}
}

&.#{$css-prefix}medium {
.#{$css-prefix}btn {
width: $number-picker-normal-m-button-width;
Expand Down Expand Up @@ -118,6 +137,30 @@
padding: 0;
}

&.#{$css-prefix}small {
width: 68px;

.#{$css-prefix}icon {
@include icon-size($number-picker-inline-s-button-icon-size);
}

.#{$css-prefix}btn {
height: $form-element-small-height;
}

.#{$css-prefix}before .#{$css-prefix}btn {
margin-right: $number-picker-inline-s-button-margin;
border-top-left-radius: $number-picker-inline-s-button-corner;
border-bottom-left-radius: $number-picker-inline-s-button-corner;
}

.#{$css-prefix}after .#{$css-prefix}btn {
margin-left: $number-picker-inline-s-button-margin;
border-top-right-radius: $number-picker-inline-s-button-corner;
border-bottom-right-radius: $number-picker-inline-s-button-corner;
}
}

&.#{$css-prefix}medium {
width: 100px;

Expand Down Expand Up @@ -167,6 +210,10 @@
}

.#{$css-prefix}btn {
&.#{$css-prefix}small {
width: $form-element-small-height;
}

&.#{$css-prefix}medium {
width: $form-element-medium-height;
}
Expand All @@ -185,6 +232,10 @@
border-left: 0;
border-top-right-radius: 0;

&.#{$css-prefix}small {
border-top-left-radius: $form-element-small-corner;
}

&.#{$css-prefix}medium {
border-top-left-radius: $form-element-medium-corner;
}
Expand All @@ -199,6 +250,10 @@
border-left: 0;
border-bottom-right-radius: 0;

&.#{$css-prefix}small {
border-bottom-left-radius: $form-element-small-corner;
}

&.#{$css-prefix}medium {
border-bottom-left-radius: $form-element-medium-corner;
}
Expand All @@ -218,6 +273,12 @@
.#{$css-prefix}before .#{$css-prefix}btn {
margin-right: 0;

&.#{$css-prefix}small {
margin-left: $number-picker-inline-s-button-margin;
border-top-right-radius: $number-picker-inline-s-button-corner !important;
border-bottom-right-radius: $number-picker-inline-s-button-corner !important;
}

&.#{$css-prefix}medium {
margin-left: $number-picker-inline-m-button-margin;
border-top-right-radius: $number-picker-inline-m-button-corner !important;
Expand All @@ -234,6 +295,12 @@
.#{$css-prefix}after .#{$css-prefix}btn {
margin-left: 0;

&.#{$css-prefix}small {
margin-right: $number-picker-inline-s-button-margin;
border-top-left-radius: $number-picker-inline-s-button-corner !important;
border-bottom-left-radius: $number-picker-inline-s-button-corner !important;
}

&.#{$css-prefix}medium {
margin-right: $number-picker-inline-m-button-margin;
border-top-left-radius: $number-picker-inline-m-button-corner !important;
Expand Down
2 changes: 1 addition & 1 deletion src/number-picker/number-picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class NumberPicker extends React.Component {
innerAfter,
} = this.props;

let type = device === 'phone' ? 'inline' : this.props.type;
const type = device === 'phone' ? 'inline' : this.props.type;

const prefixCls = `${prefix}number-picker`;

Expand Down
17 changes: 17 additions & 0 deletions src/number-picker/scss/variable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@ $number-picker-prefix: '.#{$css-prefix}number-picker';
// Normal
// --------------------------------------------------

/// width
/// @namespace size/button
$number-picker-normal-s-button-width: $s-5 !default;
/// width
/// @namespace size/button
$number-picker-normal-m-button-width: $s-5 !default;
/// width
/// @namespace size/button
$number-picker-normal-l-button-width: $s-5 !default;

/// icon
/// @namespace size/button
$number-picker-normal-s-button-icon-size: $icon-xxs !default;

/// icon
/// @namespace size/button
$number-picker-normal-m-button-icon-size: $icon-xxs !default;
Expand All @@ -33,6 +40,16 @@ $number-picker-normal-l-button-icon-size: $icon-xxs !default;
// inline
// --------------------------------------------------

/// icon
/// @namespace size/button
$number-picker-inline-s-button-icon-size: $icon-xs !default;
/// margin
/// @type number
/// @namespace size/button
$number-picker-inline-s-button-margin: 2px !default;
/// corner
/// @namespace size/button
$number-picker-inline-s-button-corner: $corner-1 !default;
/// icon
/// @namespace size/button
$number-picker-inline-m-button-icon-size: $icon-xs !default;
Expand Down

0 comments on commit 1a81522

Please sign in to comment.