Skip to content

Commit

Permalink
feat: slider input mobile theme (PDS-242) (#738)
Browse files Browse the repository at this point in the history
* feat: add mobile theme for form-contro & input

* chore(input): screenshots

* chore: update mobile button screenshots

* feat: add mobile theme for slider & slider-input

* fix(slider): mobile theme bg

* fix(slider-input): font-weight normal for mobile

Co-authored-by: dmitrsavk <dmitrsavk@yandex.ru>
  • Loading branch information
reme3d2y and dmitrsavk committed Jul 23, 2021
1 parent 88f6f7c commit 6e924aa
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 48 deletions.
1 change: 1 addition & 0 deletions packages/slider-input/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const SliderInput = forwardRef<HTMLInputElement, SliderInputProps>(
readOnly={readOnly}
className={cn(inputClassName, styles.input)}
focusedClassName={styles.focused}
fieldClassName={styles.field}
inputMode='numeric'
pattern='[0-9]*'
error={error}
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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`SliderInput should match snapshot 1`] = `
class="component input s block"
>
<div
class="inner"
class="field inner"
>
<div
class="inputWrapper"
Expand Down
81 changes: 42 additions & 39 deletions packages/slider-input/src/component.screenshots.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,46 @@ const screenshotTesting = setupScreenshotTesting({
expect,
});

describe(
'SliderInput | sprite',
screenshotTesting({
cases: [
[
'main props',
createSpriteStorybookUrl({
componentName: 'SliderInput',
knobs: {
label: 'Оставшийся срок по кредиту',
value: [0, 50, 100],
size: ['s', 'm', 'l', 'xl'],
},
size: { width: 260, height: 120 },
}),
describe('SliderInput | sprite', () => {
const testCase = (theme: string) =>
screenshotTesting({
cases: [
[
'main props',
createSpriteStorybookUrl({
componentName: 'SliderInput',
knobs: {
label: 'Оставшийся срок по кредиту',
value: [0, 50, 100],
size: ['s', 'm', 'l', 'xl'],
},
size: { width: 260, height: 120 },
}),
],
[
'additional props',
createSpriteStorybookUrl({
componentName: 'SliderInput',
knobs: {
value: 50,
info: 'Р',
label: ['', 'Оставшийся срок по кредиту'],
error: ['', 'Ошибка'],
steps: [['36 мес', '180 мес', '360 мес']],
},
size: { width: 260, height: 120 },
}),
],
],
[
'additional props',
createSpriteStorybookUrl({
componentName: 'SliderInput',
knobs: {
value: 50,
info: 'Р',
label: ['', 'Оставшийся срок по кредиту'],
error: ['', 'Ошибка'],
steps: [['36 мес', '180 мес', '360 мес']],
},
size: { width: 260, height: 120 },
}),
],
],
screenshotOpts: {
fullPage: true,
},
viewport: {
width: 1100,
height: 500,
},
}),
);
screenshotOpts: {
fullPage: true,
},
viewport: {
width: 1100,
height: 500,
},
theme,
})();

['default', 'click', 'mobile'].map(testCase);
});
2 changes: 1 addition & 1 deletion packages/slider-input/src/docs/Component.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import styles from '!!raw-loader!../index.module.css';
<Meta
title='Компоненты/SliderInput'
component={SliderInput}
parameters={{ 'theme-switcher': { themes: ['click'] } }}
parameters={{ 'theme-switcher': { themes: ['click', 'mobile'] } }}
/>


Expand Down
8 changes: 7 additions & 1 deletion packages/slider-input/src/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
:root {
--slider-input-steps-color: var(--color-light-text-secondary);
--slider-input-info-color: var(--color-light-text-secondary);
--slider-input-font-weight: 700;
}

.component {
Expand All @@ -24,10 +25,15 @@
}
}

.field {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}

.input {
& input,
& input + div {
font-weight: 700;
font-weight: var(--slider-input-font-weight);
font-variant-numeric: tabular-nums;
}

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.
2 changes: 1 addition & 1 deletion packages/slider/src/component.screenshots.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ describe('Slider | main props', () => {
theme,
})();

['default', 'click'].map(testCase);
['default', 'click', 'mobile'].map(testCase);
});
2 changes: 1 addition & 1 deletion packages/slider/src/docs/Component.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import styles from '!!raw-loader!../index.module.css';
<Meta
title='Компоненты/Slider'
component={Slider}
parameters={{ 'theme-switcher': { themes: ['click'] } }}
parameters={{ 'theme-switcher': { themes: ['click', 'mobile'] } }}
/>


Expand Down
5 changes: 3 additions & 2 deletions packages/slider/src/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
--slider-progress-background: transparent;
--slider-progress-hover-background: transparent;
--slider-progress-border-radius: 0;
--slider-range-offest: calc(var(--slider-thumb-size) / 2 * -1);
}

/* Не работают префиксные селекторы через запятую - пришлось вынести в миксины */
Expand Down Expand Up @@ -96,8 +97,8 @@
position: absolute;
z-index: 1;
top: 0;
right: calc(var(--slider-thumb-size) / 2 * -1);
left: calc(var(--slider-thumb-size) / 2 * -1);
right: var(--slider-range-offest);
left: var(--slider-range-offest);
}

.range,
Expand Down
6 changes: 6 additions & 0 deletions packages/themes/src/mixins/mobile.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
@import './checkbox/mobile.css';
@import './radio/mobile.css';
@import './confirmation/mobile.css';
@import './form-control/mobile.css';
@import './input/mobile.css';
@import './slider/mobile.css';
@import './slider-input/mobile.css';

@define-mixin theme-mobile {
@mixin button-mobile;
Expand All @@ -14,4 +18,6 @@
@mixin confirmation-mobile;
@mixin form-control-mobile;
@mixin input-mobile;
@mixin slider-mobile;
@mixin slider-input-mobile;
}
5 changes: 5 additions & 0 deletions packages/themes/src/mixins/slider-input/mobile.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import '../../../../themes/src/default.css';

@define-mixin slider-input-mobile {
--slider-input-font-weight: normal;
}
7 changes: 7 additions & 0 deletions packages/themes/src/mixins/slider/mobile.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import '../../../../themes/src/default.css';

@define-mixin slider-mobile {
--slider-progress-background: var(--color-light-graphic-neutral);
--slider-progress-hover-background: var(--color-light-graphic-neutral);
--slider-range-offest: 0;
}

0 comments on commit 6e924aa

Please sign in to comment.