@gravity-ui/page-constructor 2.18.0 → 2.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.19.0](https://github.com/gravity-ui/page-constructor/compare/v2.18.0...v2.19.0) (2023-05-23)
4
+
5
+
6
+ ### Features
7
+
8
+ * **Button:** add prop width ([#346](https://github.com/gravity-ui/page-constructor/issues/346)) ([f4b1ba8](https://github.com/gravity-ui/page-constructor/commit/f4b1ba85f56ef2de435bd91ae1fc35fbea0a177b))
9
+
3
10
  ## [2.18.0](https://github.com/gravity-ui/page-constructor/compare/v2.18.0...v2.18.0) (2023-05-15)
4
11
 
5
12
 
@@ -45,4 +45,7 @@ unpredictable css rules order in build */
45
45
  }
46
46
  .pc-button-block_size_xl {
47
47
  --btn-image-margin: 25px;
48
+ }
49
+ .pc-button-block_width_max .pc-button-block__text {
50
+ width: 100%;
48
51
  }
@@ -15,7 +15,7 @@ const b = (0, utils_1.block)('button-block');
15
15
  const Button = (props) => {
16
16
  const handleMetrika = (0, useMetrika_1.useMetrika)();
17
17
  const { lang, tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
18
- const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = tslib_1.__rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
18
+ const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text, width } = props, rest = tslib_1.__rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text", "width"]);
19
19
  const defaultImgPosition = 'left';
20
20
  const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.Button, url);
21
21
  const onClick = (0, react_1.useCallback)((e) => {
@@ -25,12 +25,13 @@ const Button = (props) => {
25
25
  onClickOrigin(e);
26
26
  }
27
27
  }, [handleMetrika, metrikaGoals, pixelEvents, handleAnalytics, analyticsEvents, onClickOrigin]);
28
+ const buttonModifiers = { size, theme, width };
28
29
  const buttonImg = img instanceof Object
29
30
  ? { url: img.url, position: img.position || defaultImgPosition, alt: img.alt }
30
31
  : { url: img, position: defaultImgPosition };
31
32
  const buttonClass = img
32
- ? b({ position: buttonImg.position, size, theme }, className)
33
- : b({ size, theme }, className);
33
+ ? b(Object.assign({ position: buttonImg.position }, buttonModifiers), className)
34
+ : b(Object.assign({}, buttonModifiers), className);
34
35
  const buttonProps = Object.assign(Object.assign({}, rest), { onClick });
35
36
  if (theme === 'app-store' || theme === 'google-play') {
36
37
  const platform = theme === 'app-store' ? uikit_1.Platform.IOS : uikit_1.Platform.ANDROID;
@@ -43,7 +44,7 @@ const Button = (props) => {
43
44
  image = undefined;
44
45
  }
45
46
  const buttonTheme = theme === 'scale' ? 'accent' : theme;
46
- return (react_1.default.createElement(uikit_1.Button, Object.assign({ className: buttonClass, view: (0, utils_2.toCommonView)(buttonTheme), size: (0, utils_2.toCommonSize)(size), href: url ? (0, utils_1.setUrlTld)(url, tld) : undefined }, buttonProps),
47
+ return (react_1.default.createElement(uikit_1.Button, Object.assign({ className: buttonClass, view: (0, utils_2.toCommonView)(buttonTheme), size: (0, utils_2.toCommonSize)(size), href: url ? (0, utils_1.setUrlTld)(url, tld) : undefined, width: width }, buttonProps),
47
48
  icon && buttonImg.position === 'left' ? icon : null,
48
49
  react_1.default.createElement("span", { className: b('content') },
49
50
  image && buttonImg.position === 'left' ? image : null,
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
- import { ButtonSize, ButtonView } from '@gravity-ui/uikit';
2
+ import { ButtonView, ButtonProps as UikitButtonProps } from '@gravity-ui/uikit';
3
3
  import { ThemeSupporting } from '../../utils/theme';
4
4
  import { AnalyticsEventsBase, ClassNameProps, PixelEventType } from '../common';
5
5
  export declare enum AuthorType {
@@ -131,11 +131,10 @@ export interface FileLinkProps extends ClassNameProps {
131
131
  onClick?: () => void;
132
132
  }
133
133
  export type ButtonTheme = ButtonView | 'github' | 'app-store' | 'google-play' | 'scale' | 'monochrome';
134
- export interface ButtonProps extends AnalyticsEventsBase {
134
+ export interface ButtonProps extends AnalyticsEventsBase, Pick<UikitButtonProps, 'size' | 'width'> {
135
135
  text: string;
136
136
  url: string;
137
137
  primary?: boolean;
138
- size?: ButtonSize;
139
138
  theme?: ButtonTheme;
140
139
  img?: ButtonImageProps | string;
141
140
  metrikaGoals?: MetrikaGoal;
@@ -45,4 +45,7 @@ unpredictable css rules order in build */
45
45
  }
46
46
  .pc-button-block_size_xl {
47
47
  --btn-image-margin: 25px;
48
+ }
49
+ .pc-button-block_width_max .pc-button-block__text {
50
+ width: 100%;
48
51
  }
@@ -14,7 +14,7 @@ const b = block('button-block');
14
14
  const Button = (props) => {
15
15
  const handleMetrika = useMetrika();
16
16
  const { lang, tld } = useContext(LocaleContext);
17
- const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
17
+ const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text, width } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text", "width"]);
18
18
  const defaultImgPosition = 'left';
19
19
  const handleAnalytics = useAnalytics(DefaultEventNames.Button, url);
20
20
  const onClick = useCallback((e) => {
@@ -24,12 +24,13 @@ const Button = (props) => {
24
24
  onClickOrigin(e);
25
25
  }
26
26
  }, [handleMetrika, metrikaGoals, pixelEvents, handleAnalytics, analyticsEvents, onClickOrigin]);
27
+ const buttonModifiers = { size, theme, width };
27
28
  const buttonImg = img instanceof Object
28
29
  ? { url: img.url, position: img.position || defaultImgPosition, alt: img.alt }
29
30
  : { url: img, position: defaultImgPosition };
30
31
  const buttonClass = img
31
- ? b({ position: buttonImg.position, size, theme }, className)
32
- : b({ size, theme }, className);
32
+ ? b(Object.assign({ position: buttonImg.position }, buttonModifiers), className)
33
+ : b(Object.assign({}, buttonModifiers), className);
33
34
  const buttonProps = Object.assign(Object.assign({}, rest), { onClick });
34
35
  if (theme === 'app-store' || theme === 'google-play') {
35
36
  const platform = theme === 'app-store' ? Platform.IOS : Platform.ANDROID;
@@ -42,7 +43,7 @@ const Button = (props) => {
42
43
  image = undefined;
43
44
  }
44
45
  const buttonTheme = theme === 'scale' ? 'accent' : theme;
45
- return (React.createElement(CommonButton, Object.assign({ className: buttonClass, view: toCommonView(buttonTheme), size: toCommonSize(size), href: url ? setUrlTld(url, tld) : undefined }, buttonProps),
46
+ return (React.createElement(CommonButton, Object.assign({ className: buttonClass, view: toCommonView(buttonTheme), size: toCommonSize(size), href: url ? setUrlTld(url, tld) : undefined, width: width }, buttonProps),
46
47
  icon && buttonImg.position === 'left' ? icon : null,
47
48
  React.createElement("span", { className: b('content') },
48
49
  image && buttonImg.position === 'left' ? image : null,
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
- import { ButtonSize, ButtonView } from '@gravity-ui/uikit';
2
+ import { ButtonView, ButtonProps as UikitButtonProps } from '@gravity-ui/uikit';
3
3
  import { ThemeSupporting } from '../../utils/theme';
4
4
  import { AnalyticsEventsBase, ClassNameProps, PixelEventType } from '../common';
5
5
  export declare enum AuthorType {
@@ -131,11 +131,10 @@ export interface FileLinkProps extends ClassNameProps {
131
131
  onClick?: () => void;
132
132
  }
133
133
  export type ButtonTheme = ButtonView | 'github' | 'app-store' | 'google-play' | 'scale' | 'monochrome';
134
- export interface ButtonProps extends AnalyticsEventsBase {
134
+ export interface ButtonProps extends AnalyticsEventsBase, Pick<UikitButtonProps, 'size' | 'width'> {
135
135
  text: string;
136
136
  url: string;
137
137
  primary?: boolean;
138
- size?: ButtonSize;
139
138
  theme?: ButtonTheme;
140
139
  img?: ButtonImageProps | string;
141
140
  metrikaGoals?: MetrikaGoal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "2.18.0",
3
+ "version": "2.19.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
- import { ButtonSize, ButtonView } from '@gravity-ui/uikit';
2
+ import { ButtonView, ButtonProps as UikitButtonProps } from '@gravity-ui/uikit';
3
3
  import { ThemeSupporting } from '../../utils/theme';
4
4
  import { AnalyticsEventsBase, ClassNameProps, PixelEventType } from '../common';
5
5
  export declare enum AuthorType {
@@ -131,11 +131,10 @@ export interface FileLinkProps extends ClassNameProps {
131
131
  onClick?: () => void;
132
132
  }
133
133
  export type ButtonTheme = ButtonView | 'github' | 'app-store' | 'google-play' | 'scale' | 'monochrome';
134
- export interface ButtonProps extends AnalyticsEventsBase {
134
+ export interface ButtonProps extends AnalyticsEventsBase, Pick<UikitButtonProps, 'size' | 'width'> {
135
135
  text: string;
136
136
  url: string;
137
137
  primary?: boolean;
138
- size?: ButtonSize;
139
138
  theme?: ButtonTheme;
140
139
  img?: ButtonImageProps | string;
141
140
  metrikaGoals?: MetrikaGoal;