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

feat(button): added mobile and responsive versions component #687

Merged
merged 30 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
26d28ba
feat(button): added mobile and responsive versions component
May 26, 2023
9c03388
feat: merge master
May 29, 2023
b5d5996
feat(button): change files css
May 30, 2023
ea28973
feat(button): fix conflicts input-autocomplete
May 30, 2023
35bc337
feat(button): fix import
May 30, 2023
861b9ab
fix build
v-gevak May 31, 2023
e4bb7d7
Merge branch 'master' into feat/button-mobile-component
Valeri8888 May 31, 2023
f7241f2
feat(button): fix build picker-button
May 31, 2023
b55dbd0
Merge branch 'master' into feat/button-mobile-component
Jun 2, 2023
b94ef77
feat(button): fix review
Jun 6, 2023
5c76a3c
feat(button): fix tests
Jun 7, 2023
a2053bd
chore: fix tests
v-gevak Jun 8, 2023
b4b4b7a
feat(button): fix screenshots tabs
Jun 8, 2023
ea9c4bd
feat(button): fix styles mobile
Jun 14, 2023
58f3883
feat(button): fix screenshot test confirmation
Jun 15, 2023
5c09be7
Merge branch 'master' into feat/button-mobile-component
Jun 19, 2023
b8da83f
feat(button): fix review design
Jun 20, 2023
a996810
feat(button): fix import
Jun 20, 2023
290964e
feat(button): fix button size in tooltip
Jun 21, 2023
924275f
feat(button): fix review
Jun 23, 2023
ddf6e3d
Merge branch 'master' into feat/button-mobile-component
Jun 23, 2023
8ee57f1
feat(button): fix comment
Jun 23, 2023
babf705
Create tame-apes-refuse.md
Valeri8888 Jul 3, 2023
e97996b
Create chilly-turtles-design.md
Valeri8888 Jul 3, 2023
5fe04fe
feat(button): fix bug
Jul 3, 2023
d1457c0
fix(button): fix bg/secondary
Jul 13, 2023
46487c0
feat(button): fix screenshots test
Jul 17, 2023
b1d4708
Merge branch 'master' into feat/button-mobile-component
Valeri8888 Aug 3, 2023
3267022
fix(button): fix bugs
Aug 4, 2023
35c7e65
chore: merge master
v-gevak Aug 7, 2023
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
10 changes: 10 additions & 0 deletions .changeset/chilly-turtles-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@alfalab/core-components-calendar": minor
"@alfalab/core-components-input-autocomplete": minor
"@alfalab/core-components-pass-code": minor
"@alfalab/core-components-pattern-lock": minor
"@alfalab/core-components-select": minor
"@alfalab/core-components-tooltip": minor
---

Компонент Button заменен на mobile/desktop версии для мобильных и десктопных версий компонентов
5 changes: 5 additions & 0 deletions .changeset/tame-apes-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alfalab/core-components-button": major
---

Для компонента Button добавлены мобильная и адаптивная версии компонента. Responsive компонент теперь экспортируется из индексного файла
3 changes: 2 additions & 1 deletion packages/alert/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"rootDirs": ["src"],
"baseUrl": ".",
"paths": {
"@alfalab/core-components-*": ["../*/src"]
"@alfalab/core-components-*": ["../*/src"],
"@alfalab/core-components-button/*": ["../button/src/*"]
}
},
"references": [{ "path": "../plate" }]
Expand Down
3 changes: 2 additions & 1 deletion packages/amount-input/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"rootDirs": ["src"],
"baseUrl": ".",
"paths": {
"@alfalab/core-components-*": ["../*/src"]
"@alfalab/core-components-*": ["../*/src"],
"@alfalab/core-components-button/*": ["../button/src/*"]
}
},
"references": [{ "path": "../input" }, { "path": "../with-suffix" }]
Expand Down
14 changes: 14 additions & 0 deletions packages/attach/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ import userEvent from '@testing-library/user-event';
import { Attach } from './index';

describe('Attach', () => {
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: true,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated
removeListener: jest.fn(), // Deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});

describe('Snapshots tests', () => {
it('should match snapshot', () => {
const { container } = render(<Attach />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`Attach Snapshots tests should match snapshot 1`] = `
class="component s"
>
<button
class="component secondary s component secondary withLeftAddons"
class="component secondary s s component secondary component secondary withLeftAddons"
type="button"
>
<span
Expand Down
5 changes: 4 additions & 1 deletion packages/attach/src/component.screenshots.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ describe('Attach', () =>
noFileText: ' ',
},
},
'paddingLeft:3px;transform: scale(2.1)',
'width:800px;paddingLeft:3px;transform: scale(2.1)',
{
viewport: { width: 1024, height: 600 },
},
));

describe(
Expand Down
1 change: 1 addition & 0 deletions packages/attach/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"rootDirs": ["src"],
"baseUrl": ".",
"paths": {
"@alfalab/core-components-button/*": ["../button/src/*"],
"@alfalab/core-components-*": ["../*/src"]
}
},
Expand Down
9 changes: 7 additions & 2 deletions packages/bank-card/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
"rootDirs": ["src"],
"baseUrl": ".",
"paths": {
"@alfalab/core-components-*": ["../*/src"]
"@alfalab/core-components-*": ["../*/src"],
"@alfalab/core-components-button/*": ["../button/src/*"]
}
},
"references": [{ "path": "../form-control" }, { "path": "../input" }, { "path": "../masked-input" }]
"references": [
{ "path": "../form-control" },
{ "path": "../input" },
{ "path": "../masked-input" }
]
}
32 changes: 16 additions & 16 deletions packages/bottom-sheet/src/docs/description.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ render(() => {

return (
<Container>
<Button type='button' size='s' onClick={handleOpen} block={true}>
<ButtonMobile type='button' size='s' onClick={handleOpen} block={true}>
Показать анатомию
</Button>
</ButtonMobile>
<BottomSheet
trimTitle={false}
open={open}
Expand Down Expand Up @@ -228,9 +228,9 @@ render(() => {

return (
<Container>
<Button size='s' onClick={handleOpen} block={true}>
<ButtonMobile size='s' onClick={handleOpen} block={true}>
Показать шторку
</Button>
</ButtonMobile>

<Gap size='2xl' />

Expand Down Expand Up @@ -371,14 +371,14 @@ render(() => {
}}
>
{footerSettings.hasSecondaryButton && (
<Button
<ButtonMobile
view='secondary'
size='s'
size='m'
onClick={handleClose}
block={true}
>
Secondary
</Button>
</ButtonMobile>
)}

{footerSettings.hasPrimaryButton &&
Expand All @@ -387,9 +387,9 @@ render(() => {
) : null}

{footerSettings.hasPrimaryButton && (
<Button view='primary' size='s' onClick={handleClose} block={true}>
<ButtonMobile view='primary' size='m' onClick={handleClose} block={true}>
Primary
</Button>
</ButtonMobile>
)}
</div>
) : undefined
Expand Down Expand Up @@ -464,9 +464,9 @@ render(() => {

return (
<Container>
<Button size='s' onClick={handleOpen} block={true}>
<ButtonMobile size='s' onClick={handleOpen} block={true}>
Показать шторку
</Button>
</ButtonMobile>

<BottomSheet
open={open}
Expand All @@ -479,15 +479,15 @@ render(() => {
title={item.title}
onBack={() => setStep(step - 1)}
actionButton={
<Button
size='xs'
<ButtonMobile
size='m'
view='primary'
onClick={
item.btnText === DATA[1].btnText ? () => setStep(step + 1) : handleClose
}
>
{item.btnText}
</Button>
</ButtonMobile>
}
>
<div style={{ ...commonStyles, height: '100%' }}>
Expand Down Expand Up @@ -593,14 +593,14 @@ render(() => {
: 'var(--color-light-bg-primary)',
}}
>
<Button
<ButtonMobile
view={isNotLastAreaWithExtTrigger ? 'accent' : 'secondary'}
size='s'
onClick={openWithExternalTrigger ? magnetizeToLastArea : handleOpen}
block={true}
>
{isExternalTrigger ? 'Открыть полностью' : 'Показать шторку'}
</Button>
</ButtonMobile>

<Gap size='2xl' />

Expand Down
3 changes: 2 additions & 1 deletion packages/bottom-sheet/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"rootDirs": ["src"],
"baseUrl": ".",
"paths": {
"@alfalab/core-components-*": ["../*/src"]
"@alfalab/core-components-*": ["../*/src"],
"@alfalab/core-components-button/*": ["../button/src/*"]
}
},
"references": [
Expand Down
21 changes: 21 additions & 0 deletions packages/button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@
"license": "MIT",
"main": "index.js",
"module": "./esm/index.js",
"exports": {
".": {
"import": "./esm/index.js",
"require": "./index.js"
},
"./mobile": {
"import": "./esm/mobile.js",
"require": "./mobile.js"
},
"./desktop": {
"import": "./esm/desktop.js",
"require": "./desktop.js"
},
"./esm": "./esm/index.js",
"./cssm": "./cssm/index.js",
"./modern": "./modern/index.js",
"./esm/*": "./esm/*",
"./cssm/*": "./cssm/*",
"./modern/*": "./modern/*"
},
"publishConfig": {
"access": "public",
"directory": "dist"
Expand All @@ -15,6 +35,7 @@
"react": "^16.9.0 || ^17.0.1 || ^18.0.0"
},
"dependencies": {
"@alfalab/core-components-mq": "^4.1.4",
"@alfalab/core-components-spinner": "^3.0.7",
"@alfalab/core-components-shared": "^0.0.0",
"@alfalab/hooks": "^1.13.0",
Expand Down
21 changes: 21 additions & 0 deletions packages/button/src/Component.desktop.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { forwardRef } from 'react';

import { BaseButton } from './components/base-button';
import { AnchorButtonProps, NativeButtonProps } from './typings';

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

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

export type ButtonDesktopProps = Partial<AnchorButtonProps | NativeButtonProps>;

export const ButtonDesktop = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonDesktopProps>(
(restProps, ref) => (
<BaseButton {...restProps} ref={ref} styles={styles} colorStylesMap={colorStyles} />
),
);
21 changes: 21 additions & 0 deletions packages/button/src/Component.mobile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { forwardRef } from 'react';

import { BaseButton } from './components/base-button';
import { AnchorButtonProps, NativeButtonProps } from './typings';

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

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

export type ButtonMobileProps = Partial<AnchorButtonProps | NativeButtonProps>;

export const ButtonMobile = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonMobileProps>(
(restProps, ref) => (
<BaseButton {...restProps} ref={ref} colorStylesMap={colorStyles} styles={styles} />
),
);
23 changes: 23 additions & 0 deletions packages/button/src/Component.responsive.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { forwardRef } from 'react';

import { useMatchMedia } from '@alfalab/core-components-mq';

import { ButtonDesktop } from './Component.desktop';
import { ButtonMobile } from './Component.mobile';
import { ButtonProps } from './typings';

export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonProps>(
({ children, breakpoint = 1024, ...restProps }, ref) => {
const query = `(min-width: ${breakpoint}px)`;

const [isDesktop] = useMatchMedia(query);

const Component = isDesktop ? ButtonDesktop : ButtonMobile;

return (
<Component ref={ref} {...restProps}>
{children}
</Component>
);
},
);
3 changes: 2 additions & 1 deletion packages/button/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
waitForElementToBeRemoved,
} from '@testing-library/react';

import { Button, ButtonProps, LOADER_MIN_DISPLAY_INTERVAL } from './index';
import { LOADER_MIN_DISPLAY_INTERVAL } from './components/base-button';
import { ButtonDesktop as Button, ButtonDesktopProps as ButtonProps } from './desktop';

const dataTestId = 'test-id';

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading