@salutejs/plasma-new-hope 0.76.5-canary.1188.8748029637.0 → 0.76.6-canary.1183.8752730341.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. package/cjs/components/Avatar/Avatar.js +28 -3
  2. package/cjs/components/Avatar/Avatar.js.map +1 -1
  3. package/es/components/Avatar/Avatar.js +29 -4
  4. package/es/components/Avatar/Avatar.js.map +1 -1
  5. package/package.json +2 -2
  6. package/styled-components/cjs/components/Avatar/Avatar.js +33 -3
  7. package/styled-components/cjs/components/Avatar/Avatar.template-doc.mdx +52 -2
  8. package/styled-components/cjs/examples/plasma_b2c/components/Avatar/Avatar.stories.tsx +26 -1
  9. package/styled-components/cjs/examples/plasma_b2c/components/AvatarGroup/AvatarGroup.stories.tsx +36 -18
  10. package/styled-components/cjs/examples/plasma_b2c/components/Button/Button.stories.tsx +27 -11
  11. package/styled-components/cjs/examples/plasma_b2c/components/Radiobox/Radiobox.stories.tsx +42 -37
  12. package/styled-components/cjs/examples/plasma_web/components/Avatar/Avatar.stories.tsx +26 -1
  13. package/styled-components/cjs/examples/sds_engineer/components/Avatar/Avatar.stories.tsx +27 -1
  14. package/styled-components/es/components/Avatar/Avatar.js +34 -3
  15. package/styled-components/es/components/Avatar/Avatar.template-doc.mdx +52 -2
  16. package/styled-components/es/examples/plasma_b2c/components/Avatar/Avatar.stories.tsx +26 -1
  17. package/styled-components/es/examples/plasma_b2c/components/AvatarGroup/AvatarGroup.stories.tsx +36 -18
  18. package/styled-components/es/examples/plasma_b2c/components/Button/Button.stories.tsx +27 -11
  19. package/styled-components/es/examples/plasma_b2c/components/Radiobox/Radiobox.stories.tsx +42 -37
  20. package/styled-components/es/examples/plasma_web/components/Avatar/Avatar.stories.tsx +26 -1
  21. package/styled-components/es/examples/sds_engineer/components/Avatar/Avatar.stories.tsx +27 -1
  22. package/types/components/Avatar/Avatar.d.ts +3 -1
  23. package/types/components/Avatar/Avatar.d.ts.map +1 -1
  24. package/types/components/Avatar/Avatar.types.d.ts +7 -0
  25. package/types/components/Avatar/Avatar.types.d.ts.map +1 -1
  26. package/types/examples/plasma_b2c/components/Avatar/Avatar.d.ts +2 -0
  27. package/types/examples/plasma_b2c/components/Avatar/Avatar.d.ts.map +1 -1
  28. package/types/examples/plasma_web/components/Avatar/Avatar.d.ts +2 -0
  29. package/types/examples/plasma_web/components/Avatar/Avatar.d.ts.map +1 -1
  30. package/types/examples/sds_engineer/components/Avatar/Avatar.d.ts +1 -0
  31. package/types/examples/sds_engineer/components/Avatar/Avatar.d.ts.map +1 -1
@@ -51,56 +51,61 @@ const items = [
51
51
  { langName, value: 'elixir', label: 'Elixir', disabled: true },
52
52
  ];
53
53
 
54
- const StoryDefault = ({ label, description, ...props }: RadioboxProps) => {
54
+ const StoryDefault = (props: RadioboxProps) => {
55
55
  const value = 0;
56
56
  const [checked, setChecked] = useState(true);
57
57
 
58
58
  return (
59
- <Radiobox
60
- name="item.name"
61
- value={value}
62
- singleLine
63
- label={label}
64
- description={description}
65
- checked={checked}
66
- onChange={(event) => {
67
- event.persist();
68
-
69
- setChecked(event.target.checked);
70
- onChange(event);
71
- }}
72
- onFocus={onFocus}
73
- onBlur={onBlur}
74
- {...props}
75
- />
59
+ <>
60
+ <Radiobox
61
+ name="item.name"
62
+ value={value}
63
+ singleLine
64
+ label="Label"
65
+ description="Description"
66
+ checked={checked}
67
+ onChange={(event) => {
68
+ event.persist();
69
+
70
+ setChecked(event.target.checked);
71
+ onChange(event);
72
+ }}
73
+ onFocus={onFocus}
74
+ onBlur={onBlur}
75
+ {...props}
76
+ />
77
+ <Radiobox
78
+ name="item.name"
79
+ value={value}
80
+ singleLine
81
+ label="Label looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooonger"
82
+ description="Description looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooonger"
83
+ checked={checked}
84
+ onChange={(event) => {
85
+ event.persist();
86
+
87
+ setChecked(event.target.checked);
88
+ onChange(event);
89
+ }}
90
+ onFocus={onFocus}
91
+ onBlur={onBlur}
92
+ {...props}
93
+ />
94
+ </>
76
95
  );
77
96
  };
78
97
 
79
98
  export const Default: StoryObj<RadioboxProps> = {
80
- args: {
81
- ...meta.args,
82
- label: 'Это label',
83
- description: 'Это описание',
84
- },
85
- render: (args) => <StoryDefault {...args} />,
86
- };
87
-
88
- export const LongText: StoryObj<RadioboxProps> = {
89
- args: {
90
- ...meta.args,
91
- label: 'Ооооооооооооооооооооочень длинный label',
92
- description: 'Ооооооооооооооооооооочень длинный description',
93
- },
94
99
  render: (args) => <StoryDefault {...args} />,
95
100
  };
96
101
 
97
- const StoryRadioGroup = (props: RadioboxProps) => {
102
+ const StoryComplex = (props: RadioboxProps) => {
98
103
  const [value, setValue] = useState('c');
99
104
 
100
105
  return (
101
- <RadioGroup aria-labelledby="radiogroup-title-id">
106
+ <RadioGroup>
102
107
  <div id="radiogroup-title-id" style={{ margin: '1rem 0', fontWeight: '600' }}>
103
- Выберите язык программирования для изучения.
108
+ Radiogroup Title
104
109
  </div>
105
110
  {items.map((item) => (
106
111
  <Radiobox
@@ -124,6 +129,6 @@ const StoryRadioGroup = (props: RadioboxProps) => {
124
129
  );
125
130
  };
126
131
 
127
- export const ExampleRadioGroup: StoryObj<RadioboxProps> = {
128
- render: (args) => <StoryRadioGroup {...args} />,
132
+ export const Complex: StoryObj<RadioboxProps> = {
133
+ render: (args) => <StoryComplex {...args} />,
129
134
  };
@@ -34,13 +34,38 @@ export const Default: Story = {
34
34
  };
35
35
 
36
36
  export const Accessibility: Story = {
37
+ args: {
38
+ role: 'button',
39
+ name: 'Геннадий Силуянович',
40
+ tabIndex: 0,
41
+ view: 'default',
42
+ size: 'xxl',
43
+ status: 'active',
44
+ focused: true,
45
+ },
46
+ };
47
+
48
+ export const AccessibilityWithURL: Story = {
37
49
  args: {
38
50
  role: 'button',
39
51
  tabIndex: 0,
40
52
  view: 'default',
41
53
  size: 'xxl',
42
- name: 'Иван Фадеев',
43
54
  status: 'active',
44
55
  focused: true,
56
+ name: 'Микула Селянинович',
57
+ url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
58
+ },
59
+ };
60
+
61
+ export const AccessibilityWithCustomText: Story = {
62
+ args: {
63
+ role: 'button',
64
+ tabIndex: 0,
65
+ view: 'default',
66
+ size: 'xxl',
67
+ status: 'inactive',
68
+ focused: true,
69
+ customText: 'ФИО',
45
70
  },
46
71
  };
@@ -30,10 +30,36 @@ export const Default: Story = {
30
30
  export const Accessibility: Story = {
31
31
  args: {
32
32
  role: 'button',
33
+ name: 'Геннадий Силуянович',
33
34
  tabIndex: 0,
34
35
  view: 'default',
35
36
  size: 'xxl',
36
- name: 'Иван Фадеев',
37
+ status: 'active',
38
+ focused: true,
39
+ },
40
+ };
41
+
42
+ export const AccessibilityWithURL: Story = {
43
+ args: {
44
+ role: 'button',
45
+ tabIndex: 0,
46
+ view: 'default',
47
+ size: 'xxl',
48
+ status: 'active',
49
+ focused: true,
50
+ name: 'Микула Селянинович',
51
+ url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
52
+ },
53
+ };
54
+
55
+ export const AccessibilityWithCustomText: Story = {
56
+ args: {
57
+ role: 'button',
58
+ tabIndex: 0,
59
+ view: 'default',
60
+ size: 'xxl',
61
+ status: 'inactive',
37
62
  focused: true,
63
+ customText: 'ФИО',
38
64
  },
39
65
  };
@@ -1,5 +1,11 @@
1
- var _excluded = ["size", "name", "url", "customText", "status", "className", "focused", "isScalable"];
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["size", "name", "url", "customText", "status", "className", "focused", "isScalable", "statusLabels"];
2
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
3
9
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
10
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
11
  import React, { forwardRef, useMemo } from 'react';
@@ -12,6 +18,10 @@ import { base, Wrapper, Image, StatusIcon, Text } from './Avatar.styles';
12
18
  import { base as viewCSS } from './variations/_size/base';
13
19
  import { base as focusedCSS } from './variations/_focused/base';
14
20
  import { getInitialsForName } from './utils';
21
+ var StatusLabelsDefault = {
22
+ active: 'Активен',
23
+ inactive: 'Неактивен'
24
+ };
15
25
  var getAvatarContent = function getAvatarContent(_ref) {
16
26
  var customText = _ref.customText,
17
27
  url = _ref.url,
@@ -28,12 +38,26 @@ var getAvatarContent = function getAvatarContent(_ref) {
28
38
  }
29
39
  return /*#__PURE__*/React.createElement(Text, null, initials);
30
40
  };
41
+ var getAriaLabel = function getAriaLabel(_ref2) {
42
+ var url = _ref2.url,
43
+ name = _ref2.name,
44
+ status = _ref2.status,
45
+ ariaLabelProp = _ref2['aria-label'],
46
+ statusLabels = _ref2.statusLabels;
47
+ if (!url) {
48
+ return;
49
+ }
50
+
51
+ // INFO: включаем aria-label чтобы озвучить что на изображении
52
+ var ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;
53
+ return status ? "".concat(ariaLabel, ". ").concat(statusLabels[status]) : ariaLabel;
54
+ };
31
55
  var mergedConfig = /*#__PURE__*/mergeConfig(indicatorConfig);
32
56
  var Indicator = /*#__PURE__*/component(mergedConfig);
33
57
  var StyledIndicator = /*#__PURE__*/styled(Indicator).withConfig({
34
58
  componentId: "plasma-new-hope__sc-p4w0wq-0"
35
- })(["", ":var(", ");", ":", ""], indicatorTokens.size, tokens.statusIconSize, indicatorTokens.color, function (_ref2) {
36
- var status = _ref2.status;
59
+ })(["", ":var(", ");", ":", ""], indicatorTokens.size, tokens.statusIconSize, indicatorTokens.color, function (_ref3) {
60
+ var status = _ref3.status;
37
61
  return status === 'active' ? "var(".concat(tokens.statusOnlineColor, ")") : "var(".concat(tokens.statusOfflineColor, ")");
38
62
  });
39
63
  export var avatarRoot = function avatarRoot(Root) {
@@ -47,14 +71,20 @@ export var avatarRoot = function avatarRoot(Root) {
47
71
  _props$focused = props.focused,
48
72
  focused = _props$focused === void 0 ? true : _props$focused,
49
73
  isScalable = props.isScalable,
74
+ _props$statusLabels = props.statusLabels,
75
+ statusLabels = _props$statusLabels === void 0 ? StatusLabelsDefault : _props$statusLabels,
50
76
  rest = _objectWithoutProperties(props, _excluded);
51
77
  var initials = useMemo(function () {
52
78
  return getInitialsForName(name);
53
79
  }, [name]);
80
+ var ariaLabel = getAriaLabel(_objectSpread(_objectSpread({}, props), {}, {
81
+ statusLabels: statusLabels
82
+ }));
54
83
  return /*#__PURE__*/React.createElement(Root, _extends({
55
84
  ref: ref,
56
85
  size: avatarSize,
57
86
  className: cx(classes.avatarItem, className),
87
+ "aria-label": ariaLabel,
58
88
  focused: focused
59
89
  }, rest), /*#__PURE__*/React.createElement(Wrapper, {
60
90
  isScalable: isScalable
@@ -64,6 +94,7 @@ export var avatarRoot = function avatarRoot(Root) {
64
94
  initials: initials,
65
95
  name: name
66
96
  })), status && /*#__PURE__*/React.createElement(StatusIcon, null, /*#__PURE__*/React.createElement(StyledIndicator, {
97
+ "aria-label": statusLabels[status],
67
98
  status: status
68
99
  })));
69
100
  });
@@ -81,7 +81,32 @@ export function App() {
81
81
  ```
82
82
 
83
83
  ### Доступность
84
- Добавляем `"role"` и `"tabIndex"`.
84
+
85
+ #### Avatar c использованием изображения
86
+
87
+ В данном случае руководствуемся принципом универсального дизайна, т.е. незрячий должен получить ту же информацию, что и зрячий.
88
+
89
+ Поэтому добавляем/используем свойства: `role`, `tabIndex` и `aria-label`.
90
+
91
+ Примечание:
92
+ - если указано свойство `name` то `aria-label` можно опустить;
93
+
94
+ ```tsx live
95
+ import React from 'react';
96
+ import { Avatar } from '@salutejs/{{ package }}';
97
+
98
+ export function App() {
99
+ return (
100
+ <>
101
+ <Avatar role="button" tabIndex={0} name="Иван Фадеев" url="https://avatars.githubusercontent.com/u/1813468?v=4" />
102
+ </>
103
+ );
104
+ }
105
+ ```
106
+
107
+ #### Avatar c текстом
108
+
109
+ В этом случае достаточно указать свойство `name`.
85
110
 
86
111
  ```tsx live
87
112
  import React from 'react';
@@ -90,8 +115,33 @@ import { Avatar } from '@salutejs/{{ package }}';
90
115
  export function App() {
91
116
  return (
92
117
  <>
93
- <Avatar role="button" tabIndex="0" name="Иван Фадеев" />
118
+ <Avatar role="button" tabIndex={0} name="Иван Фадеев" />
94
119
  </>
95
120
  );
96
121
  }
97
122
  ```
123
+
124
+ #### Avatar и статус
125
+
126
+ Если указано свойство `status` его значение будет так же озвучено в комбинации со свойством `name` или `aria-label`.
127
+
128
+ ```tsx live
129
+ import React from 'react';
130
+ import { Avatar } from '@salutejs/{{ package }}';
131
+
132
+ export function App() {
133
+ return (
134
+ <>
135
+ <Avatar role="button" tabIndex={0} name="Иван Фадеев" status="inactive" />
136
+ </>
137
+ );
138
+ }
139
+ ```
140
+
141
+ Озвучит как `ИФ. Неактивен`. (В данном примере озвучиваются инициалы, производное от ФИО)
142
+
143
+ #### Свойство statusLabels
144
+
145
+ Опциональное свойство для корректной озвучки значений свойства `status`.
146
+
147
+ По-умолчанию стоит значение для русскоговорящих `{ active: 'Активен', inactive: 'Неактивен' }`.
@@ -34,13 +34,38 @@ export const Default: Story = {
34
34
  };
35
35
 
36
36
  export const Accessibility: Story = {
37
+ args: {
38
+ role: 'button',
39
+ name: 'Геннадий Силуянович',
40
+ tabIndex: 0,
41
+ view: 'default',
42
+ size: 'xxl',
43
+ status: 'active',
44
+ focused: true,
45
+ },
46
+ };
47
+
48
+ export const AccessibilityWithURL: Story = {
37
49
  args: {
38
50
  role: 'button',
39
51
  tabIndex: 0,
40
52
  view: 'default',
41
53
  size: 'xxl',
42
- name: 'Иван Фадеев',
43
54
  status: 'active',
44
55
  focused: true,
56
+ name: 'Микула Селянинович',
57
+ url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
58
+ },
59
+ };
60
+
61
+ export const AccessibilityWithCustomText: Story = {
62
+ args: {
63
+ role: 'button',
64
+ tabIndex: 0,
65
+ view: 'default',
66
+ size: 'xxl',
67
+ status: 'inactive',
68
+ focused: true,
69
+ customText: 'ФИО',
45
70
  },
46
71
  };
@@ -8,6 +8,7 @@ import { Avatar } from '../Avatar/Avatar';
8
8
  import { AvatarGroup } from './AvatarGroup';
9
9
 
10
10
  type Story = StoryObj<ComponentProps<typeof AvatarGroup>>;
11
+ type Avatar = ComponentProps<typeof Avatar>;
11
12
 
12
13
  const meta: Meta<typeof AvatarGroup> = {
13
14
  title: 'plasma_b2c/AvatarGroup',
@@ -33,40 +34,57 @@ export const Default: Story = {
33
34
 
34
35
  export const DynamicSize: Story = {
35
36
  args: { totalCount: 10, visibleCount: 3 },
36
- render: (args: ComponentProps<typeof AvatarGroup>) => {
37
- const itemLength = args.totalCount;
37
+ render: ({ visibleCount, totalCount, ...args }: ComponentProps<typeof AvatarGroup>) => {
38
+ const itemLength = totalCount;
38
39
 
39
40
  return (
40
41
  <AvatarGroup {...args}>
41
- {Array(args.visibleCount)
42
+ {Array(visibleCount)
42
43
  .fill(true)
43
44
  .map((_, index) => (
44
- <Avatar size="xxl" customText={index + 1} />
45
+ <Avatar size="xxl" key={index} customText={index + 1} />
45
46
  ))}
46
47
 
47
- {itemLength > args.visibleCount && (
48
- <Avatar size="xxl" customText={`+${itemLength - args.visibleCount}`} />
49
- )}
48
+ {itemLength > visibleCount && <Avatar size="xxl" customText={`+${itemLength - visibleCount}`} />}
50
49
  </AvatarGroup>
51
50
  );
52
51
  },
53
52
  };
54
53
 
54
+ const list: Array<Avatar> = [
55
+ {
56
+ name: 'Илья Муромец',
57
+ status: 'active',
58
+ url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
59
+ },
60
+ {
61
+ name: 'Алеша Попович',
62
+ status: 'active',
63
+ url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
64
+ },
65
+ {
66
+ name: 'Добрыня Никитич',
67
+ status: 'active',
68
+ url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
69
+ },
70
+ {
71
+ name: 'Микула Селянинович',
72
+ status: 'inactive',
73
+ url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
74
+ },
75
+ {
76
+ name: 'Ставр Годинович',
77
+ status: 'inactive',
78
+ },
79
+ ];
80
+
55
81
  export const Accessibility: Story = {
56
82
  render: (args: ComponentProps<typeof AvatarGroup>) => {
57
83
  return (
58
84
  <AvatarGroup {...args}>
59
- {Array(5)
60
- .fill(true)
61
- .map(() => (
62
- <Avatar
63
- role="button"
64
- tabIndex={0}
65
- focused
66
- size="xxl"
67
- url="https://avatars.githubusercontent.com/u/1813468?v=4"
68
- />
69
- ))}
85
+ {list.map((props) => (
86
+ <Avatar role="button" tabIndex={0} focused key={props.name} size="xxl" {...props} />
87
+ ))}
70
88
  </AvatarGroup>
71
89
  );
72
90
  },
@@ -1,6 +1,9 @@
1
- import { ComponentProps } from 'react';
1
+ import * as React from 'react';
2
+ import type { ComponentProps } from 'react';
2
3
  import type { StoryObj, Meta } from '@storybook/react';
4
+ import { disableProps } from '@salutejs/plasma-sb-utils';
3
5
 
6
+ import { IconMic } from '../../../../components/_Icon';
4
7
  import { buttonConfig } from '../../../../components/Button';
5
8
  import { mergeConfig } from '../../../../engines';
6
9
  import { WithTheme, argTypesFromConfig } from '../../../_helpers';
@@ -12,6 +15,16 @@ const meta: Meta<typeof Button> = {
12
15
  title: 'plasma_b2c/Button',
13
16
  decorators: [WithTheme],
14
17
  component: Button,
18
+ args: {
19
+ text: 'Hello',
20
+ view: 'default',
21
+ size: 'm',
22
+ disabled: false,
23
+ focused: true,
24
+ square: false,
25
+ stretching: 'auto',
26
+ isLoading: false,
27
+ },
15
28
  argTypes: {
16
29
  ...argTypesFromConfig(mergeConfig(buttonConfig, config)),
17
30
  pin: {
@@ -41,15 +54,18 @@ const meta: Meta<typeof Button> = {
41
54
 
42
55
  export default meta;
43
56
 
44
- export const Default: StoryObj<ComponentProps<typeof Button>> = {
45
- args: {
46
- children: 'Hello',
47
- view: 'default',
48
- size: 'm',
49
- disabled: false,
50
- focused: true,
51
- square: false,
52
- stretching: 'auto',
53
- isLoading: false,
57
+ export const Default: StoryObj<ComponentProps<typeof Button>> = {};
58
+
59
+ export const AccessibilityWithChildren: StoryObj<ComponentProps<typeof Button>> = {
60
+ argTypes: { ...disableProps(['text']) },
61
+ render: (props: ComponentProps<typeof Button>) => {
62
+ const args = { ...props, text: undefined };
63
+
64
+ return (
65
+ <Button {...args}>
66
+ <IconMic color="inherit" />
67
+ <span>Включить микрофон</span>
68
+ </Button>
69
+ );
54
70
  },
55
71
  };
@@ -51,56 +51,61 @@ const items = [
51
51
  { langName, value: 'elixir', label: 'Elixir', disabled: true },
52
52
  ];
53
53
 
54
- const StoryDefault = ({ label, description, ...props }: RadioboxProps) => {
54
+ const StoryDefault = (props: RadioboxProps) => {
55
55
  const value = 0;
56
56
  const [checked, setChecked] = useState(true);
57
57
 
58
58
  return (
59
- <Radiobox
60
- name="item.name"
61
- value={value}
62
- singleLine
63
- label={label}
64
- description={description}
65
- checked={checked}
66
- onChange={(event) => {
67
- event.persist();
68
-
69
- setChecked(event.target.checked);
70
- onChange(event);
71
- }}
72
- onFocus={onFocus}
73
- onBlur={onBlur}
74
- {...props}
75
- />
59
+ <>
60
+ <Radiobox
61
+ name="item.name"
62
+ value={value}
63
+ singleLine
64
+ label="Label"
65
+ description="Description"
66
+ checked={checked}
67
+ onChange={(event) => {
68
+ event.persist();
69
+
70
+ setChecked(event.target.checked);
71
+ onChange(event);
72
+ }}
73
+ onFocus={onFocus}
74
+ onBlur={onBlur}
75
+ {...props}
76
+ />
77
+ <Radiobox
78
+ name="item.name"
79
+ value={value}
80
+ singleLine
81
+ label="Label looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooonger"
82
+ description="Description looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooonger"
83
+ checked={checked}
84
+ onChange={(event) => {
85
+ event.persist();
86
+
87
+ setChecked(event.target.checked);
88
+ onChange(event);
89
+ }}
90
+ onFocus={onFocus}
91
+ onBlur={onBlur}
92
+ {...props}
93
+ />
94
+ </>
76
95
  );
77
96
  };
78
97
 
79
98
  export const Default: StoryObj<RadioboxProps> = {
80
- args: {
81
- ...meta.args,
82
- label: 'Это label',
83
- description: 'Это описание',
84
- },
85
- render: (args) => <StoryDefault {...args} />,
86
- };
87
-
88
- export const LongText: StoryObj<RadioboxProps> = {
89
- args: {
90
- ...meta.args,
91
- label: 'Ооооооооооооооооооооочень длинный label',
92
- description: 'Ооооооооооооооооооооочень длинный description',
93
- },
94
99
  render: (args) => <StoryDefault {...args} />,
95
100
  };
96
101
 
97
- const StoryRadioGroup = (props: RadioboxProps) => {
102
+ const StoryComplex = (props: RadioboxProps) => {
98
103
  const [value, setValue] = useState('c');
99
104
 
100
105
  return (
101
- <RadioGroup aria-labelledby="radiogroup-title-id">
106
+ <RadioGroup>
102
107
  <div id="radiogroup-title-id" style={{ margin: '1rem 0', fontWeight: '600' }}>
103
- Выберите язык программирования для изучения.
108
+ Radiogroup Title
104
109
  </div>
105
110
  {items.map((item) => (
106
111
  <Radiobox
@@ -124,6 +129,6 @@ const StoryRadioGroup = (props: RadioboxProps) => {
124
129
  );
125
130
  };
126
131
 
127
- export const ExampleRadioGroup: StoryObj<RadioboxProps> = {
128
- render: (args) => <StoryRadioGroup {...args} />,
132
+ export const Complex: StoryObj<RadioboxProps> = {
133
+ render: (args) => <StoryComplex {...args} />,
129
134
  };
@@ -34,13 +34,38 @@ export const Default: Story = {
34
34
  };
35
35
 
36
36
  export const Accessibility: Story = {
37
+ args: {
38
+ role: 'button',
39
+ name: 'Геннадий Силуянович',
40
+ tabIndex: 0,
41
+ view: 'default',
42
+ size: 'xxl',
43
+ status: 'active',
44
+ focused: true,
45
+ },
46
+ };
47
+
48
+ export const AccessibilityWithURL: Story = {
37
49
  args: {
38
50
  role: 'button',
39
51
  tabIndex: 0,
40
52
  view: 'default',
41
53
  size: 'xxl',
42
- name: 'Иван Фадеев',
43
54
  status: 'active',
44
55
  focused: true,
56
+ name: 'Микула Селянинович',
57
+ url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
58
+ },
59
+ };
60
+
61
+ export const AccessibilityWithCustomText: Story = {
62
+ args: {
63
+ role: 'button',
64
+ tabIndex: 0,
65
+ view: 'default',
66
+ size: 'xxl',
67
+ status: 'inactive',
68
+ focused: true,
69
+ customText: 'ФИО',
45
70
  },
46
71
  };