Skip to content

Commit

Permalink
feat(slider-input): design updates (#673)
Browse files Browse the repository at this point in the history
* test(keyboard-focusable): update screenshot

* feat(form-control): change focused state bg-color

* feat(input): swap right addons and error/success icon

* feat(slider-input): update design

* feat(input): change default error icon

* feat(themes): add error icon to site theme

* feat(input): update default error icon

* docs(slider-input): add site theme to demo

* feat(slider-input): add right slots margins

* feat(themes): fix click form control
  • Loading branch information
dmitrsavk committed Jun 22, 2021
1 parent cbc6bd3 commit 794e3cc
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 27 deletions.
5 changes: 5 additions & 0 deletions packages/form-control/src/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

/* focus */
--form-control-focus-border-bottom: 1px solid var(--color-light-border-key);
--form-control-focus-bg-color: color-mod(var(--color-light-bg-primary-inverted) alpha(15%));

/* hover */
--form-control-hover-bg-color: color-mod(var(--color-light-bg-primary-inverted) alpha(15%));
Expand Down Expand Up @@ -282,6 +283,10 @@
transform: translateY(-100%) scale(0.875);
}

.focused.inner {
background-color: var(--form-control-focus-bg-color);
}

/* HOVER STATE */

.inner:not(.disabled):hover {
Expand Down
2 changes: 1 addition & 1 deletion packages/input/src/Component.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { name, version } from '../package.json';
<Meta
title='Компоненты'
component={Input}
parameters={{ 'theme-switcher': { themes: ['click'] } }}
parameters={{ 'theme-switcher': { themes: ['click', 'site'] } }}
/>


Expand Down
2 changes: 1 addition & 1 deletion packages/input/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
<span className={styles.clearIcon} />
</Button>
)}
{rightAddons}
{error && <span className={styles.errorIcon} />}
{success && !error && <span className={styles.successIcon} />}
{rightAddons}
</Fragment>
)
);
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions packages/input/src/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
--input-with-label-placeholder-color: var(--color-light-text-tertiary);
--input-error-icon-display: flex;
--input-success-icon-display: flex;
--input-error-icon: url('https://alfabank.st/icons/icon_error_s_color.svg');
--input-error-icon: url('https://alfabank.st/icons/glyph_alert-circle_m_negative.svg');
--input-success-icon: url('https://alfabank.st/icons/icon_ok_s_color.svg');

/* disabled */
Expand Down Expand Up @@ -78,14 +78,14 @@
@mixin _input-icon;

display: var(--input-error-icon-display);
background-image: url('https://alfabank.st/icons/icon_error_s_color.svg');
background-image: var(--input-error-icon);
}

.successIcon {
@mixin _input-icon;

display: var(--input-success-icon-display);
background-image: url('https://alfabank.st/icons/icon_ok_s_color.svg');
background-image: var(--input-success-icon);
}

/* DISABLED STATE */
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/slider-input/src/Component.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { name, version } from '../package.json';
<Meta
title='Компоненты'
component={SliderInput}
parameters={{ 'theme-switcher': { themes: ['click'] } }}
parameters={{ 'theme-switcher': { themes: ['click', 'site'] } }}
/>


Expand All @@ -41,7 +41,7 @@ import { name, version } from '../package.json';
hint={text('hint', '')}
info={text('info', '')}
error={text('error', '')}
rightAddons={boolean('rightAddons', false) && !text('error') && <Icon />}
rightAddons={boolean('rightAddons', false) && <Icon />}
leftAddons={boolean('leftAddons', false) && <Icon />}
readOnly={boolean('readOnly', false)}
/>
Expand Down
31 changes: 19 additions & 12 deletions packages/slider-input/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const SliderInput = forwardRef<HTMLInputElement, SliderInputProps>(
Input = DefaultInput,
customInputProps = {},
dataTestId,
error,
...restProps
},
ref,
Expand Down Expand Up @@ -159,6 +160,7 @@ export const SliderInput = forwardRef<HTMLInputElement, SliderInputProps>(
[styles.block]: block,
[styles.filled]: Boolean(value),
[styles.hasLabel]: label,
[styles.hasError]: Boolean(error),
},
styles[size],
className,
Expand All @@ -180,29 +182,34 @@ export const SliderInput = forwardRef<HTMLInputElement, SliderInputProps>(
focusedClassName={styles.focused}
inputMode='numeric'
pattern='[0-9]*'
error={error}
bottomAddons={
<Slider
min={min}
max={max}
step={step}
onChange={handleSliderChange}
ref={ref}
value={Number.isNaN(sliderValue) ? 0 : sliderValue}
disabled={disabled || readOnly}
className={cn(styles.slider, sliderClassName)}
/>
!disabled && (
<Slider
min={min}
max={max}
step={step}
onChange={handleSliderChange}
ref={ref}
value={Number.isNaN(sliderValue) ? 0 : sliderValue}
disabled={disabled || readOnly}
className={cn(styles.slider, sliderClassName)}
/>
)
}
rightAddons={
(info || rightAddons) && (
<Fragment>
{info && <span className={styles.info}>{info}</span>}
{rightAddons}
{rightAddons && (
<span className={styles.rightAddons}>{rightAddons}</span>
)}
</Fragment>
)
}
/>

{steps.length > 0 && (
{steps.length > 0 && !error && (
<div className={cn(styles.steps, stepsClassName)}>
{steps.map((stepLabel, i) =>
isValidElement(stepLabel) ? (
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions packages/slider-input/src/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
font-weight: 700;
font-variant-numeric: tabular-nums;
}

& input::placeholder {
font-weight: 400;
}
}

.steps {
Expand All @@ -44,13 +48,22 @@
.info {
@mixin system_16-20_regular;

margin-right: var(--gap-s);
color: var(--slider-input-info-color);
box-sizing: border-box;
opacity: 0;
transition: 0.2s ease;
visibility: hidden;
}

.info:only-child {
margin-right: 0;
}

.hasError .rightAddons {
margin-right: var(--gap-2xs);
}

.s.hasLabel .info:first-child {
padding: var(--form-control-labeled-s-paddings);
padding-left: 0;
Expand Down
1 change: 1 addition & 0 deletions packages/themes/src/mixins/form-control/click.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/* focus */
--form-control-focus-shadow: none;
--form-control-focus-border-bottom: 0;
--form-control-focus-bg-color: var(--color-light-bg-tertiary);
--form-control-hover-bg-color: var(--color-light-bg-tertiary);

/* error */
Expand Down
3 changes: 3 additions & 0 deletions packages/themes/src/mixins/input/site.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@define-mixin input-site {
--input-error-icon: url('https://alfabank.st/icons/glyph_cross-circle_m_negative.svg');
}
2 changes: 2 additions & 0 deletions packages/themes/src/mixins/site.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
@import './button/site.css';
@import './tabs/site.css';
@import './form-control/site.css';
@import './input/site.css';

@define-mixin theme-site {
@mixin button-site;
@mixin form-control-site;
@mixin tabs-site;
@mixin input-site;
}

0 comments on commit 794e3cc

Please sign in to comment.