@vkontakte/vkui 4.27.1 → 4.27.2

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.
Files changed (159) hide show
  1. package/.cache/.eslintcache +1 -1
  2. package/.cache/.stylelintcache +1 -1
  3. package/.cache/.tsbuildinfo +47 -27
  4. package/.cache/ts/src/components/ConfigProvider/ConfigProviderContext.d.ts +0 -7
  5. package/.cache/ts/src/components/Typography/Subhead/Subhead.d.ts +4 -1
  6. package/.cache/ts/src/tokenized/index.d.ts +4 -0
  7. package/CSS_GUIDE.md +145 -0
  8. package/dist/cjs/components/ActionSheetItem/ActionSheetItem.js +0 -1
  9. package/dist/cjs/components/ActionSheetItem/ActionSheetItem.js.map +1 -1
  10. package/dist/cjs/components/Banner/Banner.js +1 -3
  11. package/dist/cjs/components/Banner/Banner.js.map +1 -1
  12. package/dist/cjs/components/Button/Button.js +3 -3
  13. package/dist/cjs/components/Button/Button.js.map +1 -1
  14. package/dist/cjs/components/ConfigProvider/ConfigProvider.js +33 -20
  15. package/dist/cjs/components/ConfigProvider/ConfigProvider.js.map +1 -1
  16. package/dist/cjs/components/ConfigProvider/ConfigProviderContext.d.ts +0 -7
  17. package/dist/cjs/components/ConfigProvider/ConfigProviderContext.js +3 -5
  18. package/dist/cjs/components/ConfigProvider/ConfigProviderContext.js.map +1 -1
  19. package/dist/cjs/components/FormItem/FormItem.js +0 -1
  20. package/dist/cjs/components/FormItem/FormItem.js.map +1 -1
  21. package/dist/cjs/components/Header/Header.js +2 -6
  22. package/dist/cjs/components/Header/Header.js.map +1 -1
  23. package/dist/cjs/components/HorizontalCell/HorizontalCell.js +1 -3
  24. package/dist/cjs/components/HorizontalCell/HorizontalCell.js.map +1 -1
  25. package/dist/cjs/components/InfoRow/InfoRow.js +1 -2
  26. package/dist/cjs/components/InfoRow/InfoRow.js.map +1 -1
  27. package/dist/cjs/components/Removable/Removable.js +8 -4
  28. package/dist/cjs/components/Removable/Removable.js.map +1 -1
  29. package/dist/cjs/components/RichCell/RichCell.js +0 -1
  30. package/dist/cjs/components/RichCell/RichCell.js.map +1 -1
  31. package/dist/cjs/components/SimpleCell/SimpleCell.js +0 -1
  32. package/dist/cjs/components/SimpleCell/SimpleCell.js.map +1 -1
  33. package/dist/cjs/components/SubnavigationButton/SubnavigationButton.js +1 -3
  34. package/dist/cjs/components/SubnavigationButton/SubnavigationButton.js.map +1 -1
  35. package/dist/cjs/components/TextTooltip/TextTooltip.js +1 -2
  36. package/dist/cjs/components/TextTooltip/TextTooltip.js.map +1 -1
  37. package/dist/cjs/components/Tooltip/Tooltip.js +1 -2
  38. package/dist/cjs/components/Tooltip/Tooltip.js.map +1 -1
  39. package/dist/cjs/components/Typography/Subhead/Subhead.d.ts +4 -1
  40. package/dist/cjs/components/Typography/Subhead/Subhead.js +15 -8
  41. package/dist/cjs/components/Typography/Subhead/Subhead.js.map +1 -1
  42. package/dist/cjs/components/Typography/Title/Title.js +1 -1
  43. package/dist/cjs/components/Typography/Title/Title.js.map +1 -1
  44. package/dist/cjs/components/UsersStack/UsersStack.js +0 -1
  45. package/dist/cjs/components/UsersStack/UsersStack.js.map +1 -1
  46. package/dist/cjs/tokenized/index.d.ts +4 -0
  47. package/dist/cjs/tokenized/index.js +16 -0
  48. package/dist/cjs/tokenized/index.js.map +1 -1
  49. package/dist/components/ActionSheetItem/ActionSheetItem.js +0 -1
  50. package/dist/components/ActionSheetItem/ActionSheetItem.js.map +1 -1
  51. package/dist/components/Banner/Banner.js +1 -3
  52. package/dist/components/Banner/Banner.js.map +1 -1
  53. package/dist/components/Button/Button.js +3 -3
  54. package/dist/components/Button/Button.js.map +1 -1
  55. package/dist/components/ConfigProvider/ConfigProvider.js +30 -19
  56. package/dist/components/ConfigProvider/ConfigProvider.js.map +1 -1
  57. package/dist/components/ConfigProvider/ConfigProviderContext.d.ts +0 -7
  58. package/dist/components/ConfigProvider/ConfigProviderContext.js +2 -3
  59. package/dist/components/ConfigProvider/ConfigProviderContext.js.map +1 -1
  60. package/dist/components/FormItem/FormItem.js +0 -1
  61. package/dist/components/FormItem/FormItem.js.map +1 -1
  62. package/dist/components/Header/Header.js +2 -6
  63. package/dist/components/Header/Header.js.map +1 -1
  64. package/dist/components/HorizontalCell/HorizontalCell.js +1 -3
  65. package/dist/components/HorizontalCell/HorizontalCell.js.map +1 -1
  66. package/dist/components/InfoRow/InfoRow.js +1 -2
  67. package/dist/components/InfoRow/InfoRow.js.map +1 -1
  68. package/dist/components/Removable/Removable.js +8 -4
  69. package/dist/components/Removable/Removable.js.map +1 -1
  70. package/dist/components/RichCell/RichCell.js +0 -1
  71. package/dist/components/RichCell/RichCell.js.map +1 -1
  72. package/dist/components/SimpleCell/SimpleCell.js +0 -1
  73. package/dist/components/SimpleCell/SimpleCell.js.map +1 -1
  74. package/dist/components/SubnavigationButton/SubnavigationButton.js +1 -3
  75. package/dist/components/SubnavigationButton/SubnavigationButton.js.map +1 -1
  76. package/dist/components/TextTooltip/TextTooltip.js +1 -2
  77. package/dist/components/TextTooltip/TextTooltip.js.map +1 -1
  78. package/dist/components/Tooltip/Tooltip.js +1 -2
  79. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  80. package/dist/components/Typography/Subhead/Subhead.d.ts +4 -1
  81. package/dist/components/Typography/Subhead/Subhead.js +13 -7
  82. package/dist/components/Typography/Subhead/Subhead.js.map +1 -1
  83. package/dist/components/Typography/Title/Title.js +1 -1
  84. package/dist/components/Typography/Title/Title.js.map +1 -1
  85. package/dist/components/UsersStack/UsersStack.js +0 -1
  86. package/dist/components/UsersStack/UsersStack.js.map +1 -1
  87. package/dist/components.css +1 -1
  88. package/dist/components.css.map +1 -1
  89. package/dist/cssm/components/ActionSheetItem/ActionSheetItem.js +0 -1
  90. package/dist/cssm/components/ActionSheetItem/ActionSheetItem.js.map +1 -1
  91. package/dist/cssm/components/Banner/Banner.js +1 -3
  92. package/dist/cssm/components/Banner/Banner.js.map +1 -1
  93. package/dist/cssm/components/Button/Button.js +3 -3
  94. package/dist/cssm/components/Button/Button.js.map +1 -1
  95. package/dist/cssm/components/ConfigProvider/ConfigProvider.js +30 -19
  96. package/dist/cssm/components/ConfigProvider/ConfigProvider.js.map +1 -1
  97. package/dist/cssm/components/ConfigProvider/ConfigProviderContext.d.ts +0 -7
  98. package/dist/cssm/components/ConfigProvider/ConfigProviderContext.js +2 -3
  99. package/dist/cssm/components/ConfigProvider/ConfigProviderContext.js.map +1 -1
  100. package/dist/cssm/components/FormItem/FormItem.js +0 -1
  101. package/dist/cssm/components/FormItem/FormItem.js.map +1 -1
  102. package/dist/cssm/components/Header/Header.js +2 -6
  103. package/dist/cssm/components/Header/Header.js.map +1 -1
  104. package/dist/cssm/components/HorizontalCell/HorizontalCell.js +1 -3
  105. package/dist/cssm/components/HorizontalCell/HorizontalCell.js.map +1 -1
  106. package/dist/cssm/components/InfoRow/InfoRow.js +1 -2
  107. package/dist/cssm/components/InfoRow/InfoRow.js.map +1 -1
  108. package/dist/cssm/components/Removable/Removable.js +8 -4
  109. package/dist/cssm/components/Removable/Removable.js.map +1 -1
  110. package/dist/cssm/components/RichCell/RichCell.js +0 -1
  111. package/dist/cssm/components/RichCell/RichCell.js.map +1 -1
  112. package/dist/cssm/components/SimpleCell/SimpleCell.js +0 -1
  113. package/dist/cssm/components/SimpleCell/SimpleCell.js.map +1 -1
  114. package/dist/cssm/components/SubnavigationButton/SubnavigationButton.js +1 -3
  115. package/dist/cssm/components/SubnavigationButton/SubnavigationButton.js.map +1 -1
  116. package/dist/cssm/components/TextTooltip/TextTooltip.js +1 -2
  117. package/dist/cssm/components/TextTooltip/TextTooltip.js.map +1 -1
  118. package/dist/cssm/components/Tooltip/Tooltip.js +1 -2
  119. package/dist/cssm/components/Tooltip/Tooltip.js.map +1 -1
  120. package/dist/cssm/components/Typography/Subhead/Subhead.css +1 -1
  121. package/dist/cssm/components/Typography/Subhead/Subhead.d.ts +4 -1
  122. package/dist/cssm/components/Typography/Subhead/Subhead.js +13 -7
  123. package/dist/cssm/components/Typography/Subhead/Subhead.js.map +1 -1
  124. package/dist/cssm/components/Typography/Title/Title.js +1 -1
  125. package/dist/cssm/components/Typography/Title/Title.js.map +1 -1
  126. package/dist/cssm/components/UsersStack/UsersStack.js +0 -1
  127. package/dist/cssm/components/UsersStack/UsersStack.js.map +1 -1
  128. package/dist/cssm/styles/components.css +1 -1
  129. package/dist/cssm/tokenized/index.d.ts +4 -0
  130. package/dist/cssm/tokenized/index.js +2 -0
  131. package/dist/cssm/tokenized/index.js.map +1 -1
  132. package/dist/tokenized/index.d.ts +4 -0
  133. package/dist/tokenized/index.js +2 -0
  134. package/dist/tokenized/index.js.map +1 -1
  135. package/dist/vkui.css +1 -1
  136. package/dist/vkui.css.map +1 -1
  137. package/package.json +1 -1
  138. package/src/components/ActionSheetItem/ActionSheetItem.tsx +1 -3
  139. package/src/components/Banner/Banner.tsx +1 -1
  140. package/src/components/Button/Button.tsx +3 -6
  141. package/src/components/ConfigProvider/ConfigProvider.tsx +25 -15
  142. package/src/components/ConfigProvider/ConfigProviderContext.tsx +9 -13
  143. package/src/components/FormItem/FormItem.tsx +1 -5
  144. package/src/components/Header/Header.tsx +2 -2
  145. package/src/components/HorizontalCell/HorizontalCell.tsx +1 -3
  146. package/src/components/InfoRow/InfoRow.tsx +1 -1
  147. package/src/components/Removable/Removable.tsx +9 -7
  148. package/src/components/RichCell/RichCell.tsx +1 -5
  149. package/src/components/SimpleCell/SimpleCell.tsx +1 -5
  150. package/src/components/SubnavigationButton/SubnavigationButton.tsx +1 -1
  151. package/src/components/TextTooltip/TextTooltip.tsx +2 -6
  152. package/src/components/Tooltip/Tooltip.tsx +2 -6
  153. package/src/components/Typography/Subhead/Readme.md +18 -24
  154. package/src/components/Typography/Subhead/Subhead.css +22 -7
  155. package/src/components/Typography/Subhead/Subhead.tsx +23 -7
  156. package/src/components/Typography/Title/Title.tsx +1 -1
  157. package/src/components/UsersStack/Readme.md +1 -1
  158. package/src/components/UsersStack/UsersStack.tsx +1 -1
  159. package/src/tokenized/index.ts +6 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/vkui",
3
- "version": "4.27.1",
3
+ "version": "4.27.2",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -158,9 +158,7 @@ const ActionSheetItemComponent: React.FC<ActionSheetItemProps> = ({
158
158
  {subtitle}
159
159
  </Caption>
160
160
  ) : (
161
- <Subhead weight="regular" vkuiClass="ActionSheetItem__subtitle">
162
- {subtitle}
163
- </Subhead>
161
+ <Subhead vkuiClass="ActionSheetItem__subtitle">{subtitle}</Subhead>
164
162
  ))}
165
163
  </div>
166
164
  {selectable && (
@@ -101,7 +101,7 @@ const BannerSubheader: React.FC<BannerTypographyProps> = ({
101
101
  return size === "m" ? (
102
102
  <Text weight="regular" {...restProps} />
103
103
  ) : (
104
- <Subhead weight="regular" {...restProps} />
104
+ <Subhead {...restProps} />
105
105
  );
106
106
  };
107
107
 
@@ -69,10 +69,7 @@ const ButtonTypography: React.FC<ButtonTypographyProps> = (
69
69
  case "m":
70
70
  if (isCompact) {
71
71
  return (
72
- <Subhead
73
- weight={platform === VKCOM ? "regular" : "medium"}
74
- {...restProps}
75
- />
72
+ <Subhead weight={platform === VKCOM ? "3" : "2"} {...restProps} />
76
73
  );
77
74
  }
78
75
 
@@ -80,7 +77,7 @@ const ButtonTypography: React.FC<ButtonTypographyProps> = (
80
77
  case "s":
81
78
  default:
82
79
  if (platform === IOS) {
83
- return <Subhead weight="medium" {...restProps} />;
80
+ return <Subhead weight="2" {...restProps} />;
84
81
  }
85
82
 
86
83
  if (platform === VKCOM) {
@@ -91,7 +88,7 @@ const ButtonTypography: React.FC<ButtonTypographyProps> = (
91
88
  return <Caption level="1" weight="medium" {...restProps} />;
92
89
  }
93
90
 
94
- return <Subhead weight="medium" {...restProps} />;
91
+ return <Subhead weight="2" {...restProps} />;
95
92
  }
96
93
  };
97
94
 
@@ -1,10 +1,10 @@
1
1
  import * as React from "react";
2
- import { AppearanceType } from "@vkontakte/vk-bridge";
2
+ import vkBridge, { AppearanceType } from "@vkontakte/vk-bridge";
3
3
  import { canUseDOM, useDOM } from "../../lib/dom";
4
4
  import {
5
5
  ConfigProviderContext,
6
6
  ConfigProviderContextInterface,
7
- defaultConfigProviderProps,
7
+ WebviewType,
8
8
  } from "./ConfigProviderContext";
9
9
  import { useIsomorphicLayoutEffect } from "../../lib/useIsomorphicLayoutEffect";
10
10
  import { useObjectMemo } from "../../hooks/useObjectMemo";
@@ -19,6 +19,7 @@ import {
19
19
  AppearanceProvider,
20
20
  generateVKUITokensClassName,
21
21
  } from "../AppearanceProvider/AppearanceProvider";
22
+ import { platform as resolvePlatform } from "../../lib/platform";
22
23
 
23
24
  export interface ConfigProviderProps
24
25
  extends Partial<ConfigProviderContextInterface> {
@@ -64,20 +65,24 @@ const deriveAppearance = (scheme: Scheme | undefined): AppearanceType =>
64
65
 
65
66
  const ConfigProvider: React.FC<ConfigProviderProps> = ({
66
67
  children,
67
- ...props
68
+ webviewType = WebviewType.VKAPPS,
69
+ isWebView = vkBridge.isWebView(),
70
+ transitionMotionEnabled = true,
71
+ platform = resolvePlatform(),
72
+ hasNewTokens = false,
73
+ appearance,
74
+ scheme,
68
75
  }) => {
69
- const config = { ...defaultConfigProviderProps, ...props };
70
- const { platform, appearance } = config;
71
- const scheme = normalizeScheme({
72
- scheme: config.scheme,
73
- platform: platform,
74
- appearance: appearance,
76
+ const normalizedScheme = normalizeScheme({
77
+ scheme,
78
+ platform,
79
+ appearance,
75
80
  });
76
81
  const { document } = useDOM();
77
82
  const target = document?.body;
78
83
 
79
84
  useIsomorphicLayoutEffect(() => {
80
- if (scheme === "inherit") {
85
+ if (normalizedScheme === "inherit") {
81
86
  return noop;
82
87
  }
83
88
  if (
@@ -88,11 +93,11 @@ const ConfigProvider: React.FC<ConfigProviderProps> = ({
88
93
  '<body scheme> was set before VKUI mount - did you forget scheme="inherit"?'
89
94
  );
90
95
  }
91
- target?.setAttribute("scheme", scheme);
96
+ target?.setAttribute("scheme", normalizedScheme);
92
97
  return () => target?.removeAttribute("scheme");
93
- }, [scheme]);
98
+ }, [normalizedScheme]);
94
99
 
95
- const realScheme = useSchemeDetector(target, scheme);
100
+ const realScheme = useSchemeDetector(target, normalizedScheme);
96
101
  const derivedAppearance = deriveAppearance(realScheme);
97
102
 
98
103
  useIsomorphicLayoutEffect(() => {
@@ -109,8 +114,13 @@ const ConfigProvider: React.FC<ConfigProviderProps> = ({
109
114
  }, [platform, derivedAppearance]);
110
115
 
111
116
  const configContext = useObjectMemo({
112
- appearance: derivedAppearance,
113
- ...config,
117
+ webviewType,
118
+ isWebView,
119
+ transitionMotionEnabled,
120
+ hasNewTokens,
121
+ platform,
122
+ scheme,
123
+ appearance: appearance || derivedAppearance,
114
124
  });
115
125
 
116
126
  return (
@@ -36,17 +36,13 @@ export interface ConfigProviderContextInterface {
36
36
  hasNewTokens: boolean;
37
37
  }
38
38
 
39
- export const defaultConfigProviderProps = {
40
- webviewType: WebviewType.VKAPPS,
41
- isWebView: vkBridge.isWebView(),
42
- transitionMotionEnabled: true,
43
- platform: platform(),
44
- hasNewTokens: false,
45
- // appearance is auto-detected by default
46
- // appearance: Appearance.LIGHT,
47
- };
48
-
49
39
  export const ConfigProviderContext =
50
- React.createContext<ConfigProviderContextInterface>(
51
- defaultConfigProviderProps
52
- );
40
+ React.createContext<ConfigProviderContextInterface>({
41
+ webviewType: WebviewType.VKAPPS,
42
+ isWebView: vkBridge.isWebView(),
43
+ transitionMotionEnabled: true,
44
+ platform: platform(),
45
+ hasNewTokens: false,
46
+ // appearance is auto-detected by default
47
+ // appearance: Appearance.LIGHT,
48
+ });
@@ -43,11 +43,7 @@ export const FormItem: React.FC<FormItemProps> = ({
43
43
 
44
44
  const wrappedChildren = (
45
45
  <React.Fragment>
46
- {hasReactNode(top) && (
47
- <Subhead weight="regular" vkuiClass="FormItem__top">
48
- {top}
49
- </Subhead>
50
- )}
46
+ {hasReactNode(top) && <Subhead vkuiClass="FormItem__top">{top}</Subhead>}
51
47
  {children}
52
48
  {hasReactNode(bottom) && (
53
49
  <Caption level="1" weight="regular" vkuiClass="FormItem__bottom">
@@ -75,7 +75,7 @@ const HeaderAside: React.FC<HeaderAsideProps> = ({
75
75
  ...restProps
76
76
  }) => {
77
77
  return platform === Platform.VKCOM ? (
78
- <Subhead weight="regular" {...restProps} />
78
+ <Subhead {...restProps} />
79
79
  ) : (
80
80
  <Text weight="regular" {...restProps} />
81
81
  );
@@ -89,7 +89,7 @@ const HeaderSubtitle: React.FC<HeaderSubtitleProps> = ({
89
89
  ...restProps
90
90
  }) => {
91
91
  return mode === "secondary" ? (
92
- <Subhead weight="regular" {...restProps} />
92
+ <Subhead {...restProps} />
93
93
  ) : (
94
94
  <Caption weight="regular" level="1" {...restProps} />
95
95
  );
@@ -24,9 +24,7 @@ const CellTypography: React.FC<CellTypographyProps> = ({
24
24
  {children}
25
25
  </Caption>
26
26
  ) : (
27
- <Subhead weight="regular" {...restProps}>
28
- {children}
29
- </Subhead>
27
+ <Subhead {...restProps}>{children}</Subhead>
30
28
  );
31
29
  };
32
30
 
@@ -24,7 +24,7 @@ const InfoRow: React.FunctionComponent<InfoRowProps> = ({
24
24
  weight="regular"
25
25
  >
26
26
  {hasReactNode(header) && (
27
- <Subhead Component="span" vkuiClass="InfoRow__header" weight="regular">
27
+ <Subhead Component="span" vkuiClass="InfoRow__header">
28
28
  {header}
29
29
  </Subhead>
30
30
  )}
@@ -25,14 +25,12 @@ export interface RemovableProps {
25
25
  onRemove?: (e: React.MouseEvent, rootEl?: HTMLElement) => void;
26
26
  }
27
27
 
28
- interface RemovableIosOwnProps
29
- extends Pick<RemovableProps, "removePlaceholder"> {
30
- onRemoveClick?: (e: React.MouseEvent, rootEl?: HTMLElement) => void;
28
+ interface RemovableIosOwnProps extends RemovableProps {
31
29
  removePlaceholderString?: string;
32
30
  }
33
31
 
34
32
  const RemovableIos: React.FC<RemovableIosOwnProps> = ({
35
- onRemoveClick,
33
+ onRemove,
36
34
  removePlaceholder,
37
35
  removePlaceholderString,
38
36
  children,
@@ -40,6 +38,7 @@ const RemovableIos: React.FC<RemovableIosOwnProps> = ({
40
38
  const { window } = useDOM();
41
39
 
42
40
  const removeButtonRef = React.useRef<HTMLElement>(null);
41
+ const disabledRef = React.useRef(true);
43
42
  const [removeOffset, updateRemoveOffset] = React.useState(0);
44
43
 
45
44
  useGlobalEventListener(
@@ -56,6 +55,8 @@ const RemovableIos: React.FC<RemovableIosOwnProps> = ({
56
55
  const onRemoveTransitionEnd = () => {
57
56
  if (removeOffset > 0) {
58
57
  removeButtonRef?.current?.focus();
58
+ } else {
59
+ disabledRef.current = true;
59
60
  }
60
61
  };
61
62
 
@@ -65,6 +66,7 @@ const RemovableIos: React.FC<RemovableIosOwnProps> = ({
65
66
  return;
66
67
  }
67
68
  const { offsetWidth } = removeButtonRef.current;
69
+ disabledRef.current = false;
68
70
  updateRemoveOffset(offsetWidth);
69
71
  };
70
72
 
@@ -92,10 +94,10 @@ const RemovableIos: React.FC<RemovableIosOwnProps> = ({
92
94
  Component="button"
93
95
  hasActive={false}
94
96
  hasHover={false}
95
- disabled={removeOffset === 0}
97
+ disabled={disabledRef.current}
96
98
  getRootRef={removeButtonRef}
97
99
  vkuiClass="Removable__remove"
98
- onClick={onRemoveClick}
100
+ onClick={onRemove}
99
101
  >
100
102
  <span vkuiClass="Removable__remove-in">{removePlaceholder}</span>
101
103
  </Tappable>
@@ -162,7 +164,7 @@ export const Removable: React.FC<RemovableOwnProps> = ({
162
164
 
163
165
  {platform === IOS && (
164
166
  <RemovableIos
165
- onRemoveClick={onRemoveClick}
167
+ onRemove={onRemoveClick}
166
168
  removePlaceholder={removePlaceholder}
167
169
  removePlaceholderString={removePlaceholderString}
168
170
  >
@@ -82,11 +82,7 @@ const RichCell: React.FC<RichCellProps> = ({
82
82
  </Text>
83
83
  )}
84
84
  {hasReactNode(caption) && (
85
- <Subhead
86
- Component="span"
87
- weight="regular"
88
- vkuiClass="RichCell__caption"
89
- >
85
+ <Subhead Component="span" vkuiClass="RichCell__caption">
90
86
  {caption}
91
87
  </Subhead>
92
88
  )}
@@ -105,11 +105,7 @@ const SimpleCell: React.FC<SimpleCellProps> = ({
105
105
  )}
106
106
  </div>
107
107
  {description && (
108
- <Subhead
109
- Component="span"
110
- weight="regular"
111
- vkuiClass="SimpleCell__description"
112
- >
108
+ <Subhead Component="span" vkuiClass="SimpleCell__description">
113
109
  {description}
114
110
  </Subhead>
115
111
  )}
@@ -36,7 +36,7 @@ const SubnavigationButtonTypography: React.FC<SubnavButtonTypographyProps> = ({
36
36
  ...restProps
37
37
  }: SubnavButtonTypographyProps) => {
38
38
  if (textLevel === 1) {
39
- return <Subhead weight="regular" {...restProps} />;
39
+ return <Subhead {...restProps} />;
40
40
  }
41
41
 
42
42
  return (
@@ -37,18 +37,14 @@ export const TextTooltip: React.FC<TextTooltipProps> = ({
37
37
  {hasReactNode(header) && (
38
38
  <Subhead
39
39
  Component="span"
40
- weight="medium"
40
+ weight="2"
41
41
  vkuiClass="TextTooltip__header"
42
42
  >
43
43
  {header}
44
44
  </Subhead>
45
45
  )}
46
46
  {hasReactNode(text) && (
47
- <Subhead
48
- Component="span"
49
- weight="regular"
50
- vkuiClass="TextTooltip__text"
51
- >
47
+ <Subhead Component="span" vkuiClass="TextTooltip__text">
52
48
  {text}
53
49
  </Subhead>
54
50
  )}
@@ -58,15 +58,11 @@ const SimpleTooltip = React.forwardRef<HTMLDivElement, SimpleTooltipProps>(
58
58
  />
59
59
  <div vkuiClass="Tooltip__content">
60
60
  {header && (
61
- <Subhead weight="semibold" vkuiClass="Tooltip__title">
61
+ <Subhead weight="1" vkuiClass="Tooltip__title">
62
62
  {header}
63
63
  </Subhead>
64
64
  )}
65
- {text && (
66
- <Subhead weight="regular" vkuiClass="Tooltip__text">
67
- {text}
68
- </Subhead>
69
- )}
65
+ {text && <Subhead vkuiClass="Tooltip__text">{text}</Subhead>}
70
66
  </div>
71
67
  </div>
72
68
  </div>
@@ -1,27 +1,21 @@
1
- Упрощения в Android-версии (происходят автоматически):
1
+ ```jsx { "props": { "layout": false, "iframe": false } }
2
+ <div style={{ padding: 20 }}>
3
+ <Subhead>Subhead</Subhead>
4
+ </div>
5
+ ```
6
+
7
+ ## Кастомизация
2
8
 
3
- - `semibold` превращается в `medium`
9
+ Есть возможность переопределить жирность.
4
10
 
5
- ```jsx
6
- <View activePanel="test">
7
- <Panel id="test">
8
- <PanelHeader>Subhead</PanelHeader>
9
- <Group>
10
- <Div>
11
- <Subhead weight="regular" style={{ marginBottom: 16 }}>
12
- Subhead regular
13
- </Subhead>
14
- <Subhead weight="medium" style={{ marginBottom: 16 }}>
15
- Subhead medium
16
- </Subhead>
17
- <Subhead weight="semibold" style={{ marginBottom: 16 }}>
18
- Subhead semibold
19
- </Subhead>
20
- <Subhead weight="bold" style={{ marginBottom: 16 }}>
21
- Subhead bold
22
- </Subhead>
23
- </Div>
24
- </Group>
25
- </Panel>
26
- </View>
11
+ ```jsx { "props": { "layout": false, "iframe": false } }
12
+ <div style={{ padding: 20 }}>
13
+ <Subhead weight="1" style={{ marginBottom: 16 }}>
14
+ Subhead weight 1
15
+ </Subhead>
16
+ <Subhead weight="2" style={{ marginBottom: 16 }}>
17
+ Subhead weight 2
18
+ </Subhead>
19
+ <Subhead weight="3">Subhead weight 3</Subhead>
20
+ </div>
27
21
  ```
@@ -1,28 +1,43 @@
1
1
  .Subhead {
2
2
  margin: 0;
3
- font-size: 14px;
4
- line-height: 18px;
3
+ font-size: var(--vkui--font_subhead--font_size--regular);
4
+ line-height: var(--vkui--font_subhead--line_height--regular);
5
+ font-weight: var(--vkui--font_subhead--font_weight--regular);
5
6
  }
6
7
 
8
+ .Subhead--sizeY-compact {
9
+ font-size: var(--vkui--font_subhead--font_size--compact);
10
+ line-height: var(--vkui--font_subhead--line_height--compact);
11
+ }
12
+
13
+ /* TODO Удалить перед релизом 5.0.0 */
7
14
  .Subhead--w-regular {
8
15
  font-weight: 400;
9
16
  }
10
17
 
18
+ /* TODO Удалить перед релизом 5.0.0 */
11
19
  .Subhead--w-medium {
12
20
  font-weight: 500;
13
21
  }
14
22
 
23
+ /* TODO Удалить перед релизом 5.0.0 */
15
24
  .Subhead--w-semibold {
16
25
  font-weight: 600;
17
26
  }
18
27
 
28
+ /* TODO Удалить перед релизом 5.0.0 */
19
29
  .Subhead--w-bold {
20
30
  font-weight: 700;
21
31
  }
22
32
 
23
- /**
24
- * ANDROID
25
- */
26
- .Subhead--android.Subhead--w-semibold {
27
- font-weight: 500;
33
+ .Subhead--w-1 {
34
+ font-weight: var(--vkui--font_weight_accent1);
35
+ }
36
+
37
+ .Subhead--w-2 {
38
+ font-weight: var(--vkui--font_weight_accent2);
39
+ }
40
+
41
+ .Subhead--w-3 {
42
+ font-weight: var(--vkui--font_weight_accent3);
28
43
  }
@@ -1,29 +1,45 @@
1
1
  import * as React from "react";
2
2
  import { HasComponent } from "../../../types";
3
- import { usePlatform } from "../../../hooks/usePlatform";
4
3
  import { classNames } from "../../../lib/classNames";
5
- import { getClassName } from "../../../helpers/getClassName";
4
+ import { warnOnce } from "../../../lib/warnOnce";
5
+ import { useAdaptivity } from "../../../hooks/useAdaptivity";
6
6
  import "./Subhead.css";
7
7
 
8
8
  export interface SubheadProps
9
9
  extends React.AllHTMLAttributes<HTMLElement>,
10
10
  HasComponent {
11
- weight: "regular" | "medium" | "semibold" | "bold";
11
+ /**
12
+ * Начертания "regular", "medium", "semibold" и "bold" устарели и будут удалены в 5.0.0.
13
+ */
14
+ weight?: "regular" | "medium" | "semibold" | "bold" | "1" | "2" | "3";
12
15
  }
13
16
 
17
+ const warn = warnOnce("Subhead");
18
+
14
19
  const Subhead: React.FC<SubheadProps> = ({
15
20
  children,
16
- weight = "regular",
17
- Component = "h4",
21
+ weight,
22
+ Component = "h5",
18
23
  ...restProps
19
24
  }: SubheadProps) => {
20
- const platform = usePlatform();
25
+ const { sizeY } = useAdaptivity();
26
+
27
+ if (process.env.NODE_ENV === "development") {
28
+ if (
29
+ weight &&
30
+ ["heavy", "bold", "semibold", "medium", "regular"].includes(weight)
31
+ )
32
+ warn(
33
+ `Начертание weight="${weight}" устарело и будет удалено в 5.0.0. Используйте значения "1", "2" и "3"`
34
+ );
35
+ }
21
36
 
22
37
  return (
23
38
  <Component
24
39
  {...restProps}
25
40
  vkuiClass={classNames(
26
- getClassName("Subhead", platform),
41
+ "Subhead",
42
+ `Subhead--sizeY-${sizeY}`,
27
43
  `Subhead--w-${weight}`
28
44
  )}
29
45
  >
@@ -41,7 +41,7 @@ const Title: React.FC<TitleProps> = ({
41
41
  ["heavy", "bold", "semibold", "medium", "regular"].includes(weight)
42
42
  )
43
43
  warn(
44
- `Начертание "${weight}" устарело и будет удалено в 5.0.0. Используйте значения "1", "2" и "3"`
44
+ `Начертание weight="${weight}" устарело и будет удалено в 5.0.0. Используйте значения "1", "2" и "3"`
45
45
  );
46
46
  }
47
47
 
@@ -82,7 +82,7 @@
82
82
  getAvatarUrl("user_va"),
83
83
  getAvatarUrl("user_tc"),
84
84
  ]}
85
- style={{ color: "#fff", padding: "8px 0" }}
85
+ style={{ color: "#fff", padding: "8px 16px" }}
86
86
  >
87
87
  Проголосовали 2 176 человек
88
88
  </UsersStack>
@@ -84,7 +84,7 @@ const UsersStack: React.FC<UsersStackProps> = (props: UsersStackProps) => {
84
84
  )}
85
85
  </div>
86
86
  {hasReactNode(children) && (
87
- <Subhead Component="span" weight="regular" vkuiClass="UsersStack__text">
87
+ <Subhead Component="span" vkuiClass="UsersStack__text">
88
88
  {children}
89
89
  </Subhead>
90
90
  )}
@@ -16,3 +16,9 @@ export type {
16
16
  SegmentedControlOptionInterface,
17
17
  SegmentedControlValue,
18
18
  } from "../components/SegmentedControl/SegmentedControl";
19
+
20
+ export { default as Title } from "../components/Typography/Title/Title";
21
+ export type { TitleProps } from "../components/Typography/Title/Title";
22
+
23
+ export { default as Subhead } from "../components/Typography/Subhead/Subhead";
24
+ export type { SubheadProps } from "../components/Typography/Subhead/Subhead";