Skip to content

Commit

Permalink
fix(input): smart error icon (#746)
Browse files Browse the repository at this point in the history
* fix(input): smart error icon

* fix(slider-input): remove margins

* fix(intl-phone-input): deps

* chore: update screenshots

* Update package.json

* feat: input inverted colors (PDS-265) (#782)

* feat: add inverted colors to inputs

* fix(password-input): addons paddings

* fix(form-control): error border 2px
  • Loading branch information
reme3d2y committed Aug 23, 2021
1 parent 36f6a5e commit f1950d6
Show file tree
Hide file tree
Showing 87 changed files with 948 additions and 377 deletions.
11 changes: 10 additions & 1 deletion packages/amount-input/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import { withSuffix } from '@alfalab/core-components-with-suffix';
import { getFormattedValue, getAmountValueFromStr } from './utils';

import styles from './index.module.css';
import defaultColors from './default.module.css';
import invertedColors from './inverted.module.css';

const colorStyles = {
default: defaultColors,
inverted: invertedColors,
};

export type AmountInputProps = Omit<InputProps, 'value' | 'onChange' | 'type'> & {
/**
Expand Down Expand Up @@ -85,6 +92,7 @@ export const AmountInput = forwardRef<HTMLInputElement, AmountInputProps>(
}`,
integersOnly = false,
bold = true,
colors = 'default',
className,
focusedClassName,
dataTestId,
Expand Down Expand Up @@ -216,7 +224,7 @@ export const AmountInput = forwardRef<HTMLInputElement, AmountInputProps>(
<Fragment>
{majorPart}

<span className={styles.minorPartAndCurrency}>
<span className={colorStyles[colors].minorPartAndCurrency}>
{minorPart !== undefined && `,${minorPart}`}
{THINSP}
{suffix === currency ? currencySymbol : suffix}
Expand All @@ -227,6 +235,7 @@ export const AmountInput = forwardRef<HTMLInputElement, AmountInputProps>(
clear={clear}
placeholder={placeholder}
value={inputValue}
colors={colors}
className={cn(styles.component, className)}
focusedClassName={focusedClassName}
inputClassName={styles.input}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 15 additions & 15 deletions packages/amount-input/src/__snapshots__/Component.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Object {
class="container bold"
>
<div
class="component component hasSuffix s"
class="component component component hasSuffix s"
>
<div
class="inner"
class="inner inner"
>
<div
class="inputWrapper"
Expand All @@ -21,7 +21,7 @@ Object {
class="input"
>
<input
class="input input"
class="input input input"
placeholder="0 ₽"
type="text"
value=""
Expand Down Expand Up @@ -57,10 +57,10 @@ Object {
class="container bold"
>
<div
class="component component hasSuffix s"
class="component component component hasSuffix s"
>
<div
class="inner"
class="inner inner"
>
<div
class="inputWrapper"
Expand All @@ -69,7 +69,7 @@ Object {
class="input"
>
<input
class="input input"
class="input input input"
placeholder="0 ₽"
type="text"
value=""
Expand Down Expand Up @@ -162,10 +162,10 @@ Object {
class="container bold"
>
<div
class="component component hasSuffix s"
class="component component component hasSuffix s"
>
<div
class="inner"
class="inner inner"
>
<div
class="inputWrapper"
Expand All @@ -174,7 +174,7 @@ Object {
class="input"
>
<input
class="input input"
class="input input input"
placeholder="0 ₽"
type="text"
value=""
Expand Down Expand Up @@ -209,10 +209,10 @@ Object {
class="container bold filled"
>
<div
class="component component suffixVisible hasSuffix s"
class="component component component suffixVisible hasSuffix s"
>
<div
class="inner filled"
class="inner inner filled"
>
<div
class="inputWrapper"
Expand All @@ -221,7 +221,7 @@ Object {
class="input"
>
<input
class="input input"
class="input input input"
placeholder="0 $"
type="text"
value="12 345,67"
Expand Down Expand Up @@ -260,10 +260,10 @@ Object {
class="container bold filled"
>
<div
class="component component suffixVisible hasSuffix s"
class="component component component suffixVisible hasSuffix s"
>
<div
class="inner filled"
class="inner inner filled"
>
<div
class="inputWrapper"
Expand All @@ -272,7 +272,7 @@ Object {
class="input"
>
<input
class="input input"
class="input input input"
placeholder="0 $"
type="text"
value="12 345,67"
Expand Down
13 changes: 12 additions & 1 deletion packages/amount-input/src/component.screenshots.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setupScreenshotTesting, createSpriteStorybookUrl } from '../../screenshot-utils';
import { setupScreenshotTesting, createSpriteStorybookUrl, createStorybookUrl } from '../../screenshot-utils';

const screenshotTesting = setupScreenshotTesting({
it,
Expand All @@ -24,6 +24,17 @@ describe(
size: { width: 300, height: 70 },
}),
],
[
'inverted',
createStorybookUrl({
componentName: 'AmountInput',
knobs: {
value: 12300,
minority: 100,
colors: 'inverted',
},
}),
],
],
}),
);
9 changes: 9 additions & 0 deletions packages/amount-input/src/default.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@import '../../themes/src/default.css';

:root {
--amount-input-minor-part-and-currency-color: var(--color-light-text-secondary);
}

.minorPartAndCurrency {
color: var(--amount-input-minor-part-and-currency-color);
}
8 changes: 0 additions & 8 deletions packages/amount-input/src/index.module.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
@import '../../themes/src/default.css';

:root {
--amount-input-minor-part-and-currency-color: var(--color-light-text-secondary);
}

/*
* Задача:
* 1) Отобразить символ валюты сразу за последним введенным символом
Expand All @@ -21,10 +17,6 @@
position: relative;
}

.minorPartAndCurrency {
color: var(--amount-input-minor-part-and-currency-color);
}

.bold .input,
.bold .suffixContainer {
font-weight: bold;
Expand Down
11 changes: 11 additions & 0 deletions packages/amount-input/src/inverted.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@import '../../themes/src/default.css';

:root {
--amount-input-inverted-minor-part-and-currency-color: var(
--color-light-text-secondary-inverted
);
}

.minorPartAndCurrency {
color: var(--amount-input-inverted-minor-part-and-currency-color);
}
32 changes: 16 additions & 16 deletions packages/bank-card/src/__snapshots__/Component.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ exports[`BankCard Snapshots tests should match snapshots 1`] = `
</svg>
</div>
<div
class="component filled s block hasRightAddons"
class="component component filled s block hasRightAddons"
>
<div
class="inner filled hasLabel"
class="inner inner filled hasLabel"
>
<div
class="inputWrapper"
Expand All @@ -47,7 +47,7 @@ exports[`BankCard Snapshots tests should match snapshots 1`] = `
Номер карты или счёта
</span>
<div
class="label label"
class="label label label"
>
<span
class="labelInner"
Expand All @@ -60,7 +60,7 @@ exports[`BankCard Snapshots tests should match snapshots 1`] = `
>
<input
aria-label="Номер карты или счёта"
class="input hasLabel input"
class="input input hasLabel input"
inputmode="numeric"
pattern="[0-9]*"
type="text"
Expand Down Expand Up @@ -150,10 +150,10 @@ exports[`BankCard Snapshots tests should match snapshots 2`] = `
</svg>
</div>
<div
class="component filled s block hasRightAddons"
class="component component filled s block hasRightAddons"
>
<div
class="inner filled hasLabel"
class="inner inner filled hasLabel"
>
<div
class="inputWrapper"
Expand All @@ -165,7 +165,7 @@ exports[`BankCard Snapshots tests should match snapshots 2`] = `
Номер карты или счёта
</span>
<div
class="label label"
class="label label label"
>
<span
class="labelInner"
Expand All @@ -178,7 +178,7 @@ exports[`BankCard Snapshots tests should match snapshots 2`] = `
>
<input
aria-label="Номер карты или счёта"
class="input hasLabel input"
class="input input hasLabel input"
inputmode="numeric"
pattern="[0-9]*"
type="text"
Expand Down Expand Up @@ -266,10 +266,10 @@ exports[`BankCard Snapshots tests should match snapshots 3`] = `
</svg>
</div>
<div
class="component filled s block hasRightAddons"
class="component component filled s block hasRightAddons"
>
<div
class="inner filled hasLabel"
class="inner inner filled hasLabel"
>
<div
class="inputWrapper"
Expand All @@ -281,7 +281,7 @@ exports[`BankCard Snapshots tests should match snapshots 3`] = `
Номер карты или счёта
</span>
<div
class="label label"
class="label label label"
>
<span
class="labelInner"
Expand All @@ -294,7 +294,7 @@ exports[`BankCard Snapshots tests should match snapshots 3`] = `
>
<input
aria-label="Номер карты или счёта"
class="input hasLabel input"
class="input input hasLabel input"
inputmode="numeric"
pattern="[0-9]*"
type="text"
Expand Down Expand Up @@ -382,10 +382,10 @@ exports[`BankCard Snapshots tests should match snapshots 4`] = `
</svg>
</div>
<div
class="component filled s block hasRightAddons"
class="component component filled s block hasRightAddons"
>
<div
class="inner filled hasLabel"
class="inner inner filled hasLabel"
>
<div
class="inputWrapper"
Expand All @@ -397,7 +397,7 @@ exports[`BankCard Snapshots tests should match snapshots 4`] = `
Номер карты или счёта
</span>
<div
class="label label"
class="label label label"
>
<span
class="labelInner"
Expand All @@ -410,7 +410,7 @@ exports[`BankCard Snapshots tests should match snapshots 4`] = `
>
<input
aria-label="Номер карты или счёта"
class="input hasLabel input"
class="input input hasLabel input"
inputmode="numeric"
pattern="[0-9]*"
type="text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ exports[`CalendarInput Display tests should match snapshot 1`] = `
tabindex="-1"
>
<div
class="component s block hasRightAddons"
class="component component s block hasRightAddons"
>
<div
class="inner"
class="inner inner"
>
<div
class="inputWrapper"
Expand All @@ -19,7 +19,7 @@ exports[`CalendarInput Display tests should match snapshot 1`] = `
class="input"
>
<input
class="input"
class="input input"
type="text"
value=""
/>
Expand Down

0 comments on commit f1950d6

Please sign in to comment.