Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: Stepper use self Input and Button Component #3984

Merged
merged 2 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/components/stepper/stepper.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
position: relative;
width: @stepper-width;

input {
.@{class-prefix-stepper}-input {
position: relative;
flex: 1;
height: @stepper-height;
width: 100%;
border: 0;
outline: none;
appearance: none;
text-align: center;
background: transparent;
border-top: @stepper-border solid @stepper-border-color;
border-bottom: @stepper-border solid @stepper-border-color;

&:disabled {
zqran marked this conversation as resolved.
Show resolved Hide resolved
cursor: not-allowed;
color: var(--adm-color-weak);
}

input {
font-size: var(--adm-font-size-main);
text-align: center;
}
}

button {
.@{class-prefix-stepper}-minus,
.@{class-prefix-stepper}-plus {
zqran marked this conversation as resolved.
Show resolved Hide resolved
position: relative;
// flex: 1;
box-sizing: border-box;
Expand All @@ -51,6 +51,8 @@
&::before {
width: 46%;
height: 1px;
border: none;
opacity: initial;
}

&::after {
Expand Down
15 changes: 8 additions & 7 deletions src/components/stepper/stepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { NativeProps, withNativeProps } from '../../utils/native-props'
import { useNewControllableValue } from '../../utils/use-controllable-value'
import { withDefaultProps } from '../../utils/with-default-props'
import { bound } from '../../utils/bound'
import Input from '../input'
import Button from '../button'

const classPrefix = `adm-stepper`

Expand Down Expand Up @@ -85,27 +87,26 @@ export const Stepper = withDefaultProps(defaultProps)<StepperProps>(props => {
[`${classPrefix}-disabled`]: disabled,
})}
>
<button
type='button'
<Button
className={`${classPrefix}-minus`}
onClick={handleMinus}
disabled={minusDisabled()}
/>
<input
<Input
className={`${classPrefix}-input`}
onFocus={() => {
setHasFocus(true)
}}
value={inputValue}
onChange={e => {
disabled || handleInputChange(e.target.value)
onChange={val => {
disabled || handleInputChange(val)
}}
disabled={disabled}
onBlur={() => {
setHasFocus(false)
}}
/>
<button
type='button'
<Button
className={`${classPrefix}-plus`}
onClick={handlePlus}
disabled={plusDisabled()}
Expand Down