@salutejs/plasma-new-hope 0.238.1-canary.1692.12540362812.0 → 0.239.0-canary.1696.12710467472.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.
Files changed (91) hide show
  1. package/cjs/components/Avatar/Avatar.js +39 -3
  2. package/cjs/components/Avatar/Avatar.js.map +1 -1
  3. package/cjs/components/Avatar/Avatar.styles.js +32 -1
  4. package/cjs/components/Avatar/Avatar.styles.js.map +1 -1
  5. package/cjs/components/Avatar/Avatar.styles_131qvfx.css +8 -0
  6. package/cjs/components/Avatar/Avatar.tokens.js +41 -2
  7. package/cjs/components/Avatar/Avatar.tokens.js.map +1 -1
  8. package/cjs/components/Avatar/utils/index.js +21 -0
  9. package/cjs/components/Avatar/utils/index.js.map +1 -0
  10. package/cjs/index.css +8 -5
  11. package/emotion/cjs/components/Avatar/Avatar.js +39 -4
  12. package/emotion/cjs/components/Avatar/Avatar.styles.js +29 -10
  13. package/emotion/cjs/components/Avatar/Avatar.template-doc.mdx +54 -0
  14. package/emotion/cjs/components/Avatar/Avatar.tokens.js +41 -2
  15. package/emotion/cjs/components/Avatar/utils/index.js +15 -1
  16. package/emotion/cjs/examples/plasma_b2c/components/Avatar/Avatar.config.js +25 -7
  17. package/emotion/cjs/examples/plasma_b2c/components/Avatar/Avatar.stories.tsx +134 -1
  18. package/emotion/cjs/examples/plasma_web/components/Avatar/Avatar.config.js +25 -7
  19. package/emotion/cjs/examples/plasma_web/components/Avatar/Avatar.stories.tsx +134 -1
  20. package/emotion/es/components/Avatar/Avatar.js +41 -6
  21. package/emotion/es/components/Avatar/Avatar.styles.js +29 -10
  22. package/emotion/es/components/Avatar/Avatar.template-doc.mdx +54 -0
  23. package/emotion/es/components/Avatar/Avatar.tokens.js +41 -2
  24. package/emotion/es/components/Avatar/utils/index.js +14 -1
  25. package/emotion/es/examples/plasma_b2c/components/Avatar/Avatar.config.js +25 -7
  26. package/emotion/es/examples/plasma_b2c/components/Avatar/Avatar.stories.tsx +134 -1
  27. package/emotion/es/examples/plasma_web/components/Avatar/Avatar.config.js +25 -7
  28. package/emotion/es/examples/plasma_web/components/Avatar/Avatar.stories.tsx +134 -1
  29. package/es/components/Avatar/Avatar.js +40 -4
  30. package/es/components/Avatar/Avatar.js.map +1 -1
  31. package/es/components/Avatar/Avatar.styles.js +30 -2
  32. package/es/components/Avatar/Avatar.styles.js.map +1 -1
  33. package/es/components/Avatar/Avatar.styles_131qvfx.css +8 -0
  34. package/es/components/Avatar/Avatar.tokens.js +41 -2
  35. package/es/components/Avatar/Avatar.tokens.js.map +1 -1
  36. package/es/components/Avatar/utils/index.js +17 -0
  37. package/es/components/Avatar/utils/index.js.map +1 -0
  38. package/es/index.css +8 -5
  39. package/package.json +5 -5
  40. package/styled-components/cjs/components/Avatar/Avatar.js +38 -3
  41. package/styled-components/cjs/components/Avatar/Avatar.styles.js +18 -2
  42. package/styled-components/cjs/components/Avatar/Avatar.template-doc.mdx +54 -0
  43. package/styled-components/cjs/components/Avatar/Avatar.tokens.js +41 -2
  44. package/styled-components/cjs/components/Avatar/utils/index.js +15 -1
  45. package/styled-components/cjs/examples/plasma_b2c/components/Avatar/Avatar.config.js +22 -4
  46. package/styled-components/cjs/examples/plasma_b2c/components/Avatar/Avatar.stories.tsx +134 -1
  47. package/styled-components/cjs/examples/plasma_web/components/Avatar/Avatar.config.js +22 -4
  48. package/styled-components/cjs/examples/plasma_web/components/Avatar/Avatar.stories.tsx +134 -1
  49. package/styled-components/es/components/Avatar/Avatar.js +40 -5
  50. package/styled-components/es/components/Avatar/Avatar.styles.js +18 -2
  51. package/styled-components/es/components/Avatar/Avatar.template-doc.mdx +54 -0
  52. package/styled-components/es/components/Avatar/Avatar.tokens.js +41 -2
  53. package/styled-components/es/components/Avatar/utils/index.js +14 -1
  54. package/styled-components/es/examples/plasma_b2c/components/Avatar/Avatar.config.js +22 -4
  55. package/styled-components/es/examples/plasma_b2c/components/Avatar/Avatar.stories.tsx +134 -1
  56. package/styled-components/es/examples/plasma_web/components/Avatar/Avatar.config.js +22 -4
  57. package/styled-components/es/examples/plasma_web/components/Avatar/Avatar.stories.tsx +134 -1
  58. package/types/components/Avatar/Avatar.d.ts +3 -21
  59. package/types/components/Avatar/Avatar.d.ts.map +1 -1
  60. package/types/components/Avatar/Avatar.styles.d.ts +59 -0
  61. package/types/components/Avatar/Avatar.styles.d.ts.map +1 -1
  62. package/types/components/Avatar/Avatar.tokens.d.ts +37 -0
  63. package/types/components/Avatar/Avatar.tokens.d.ts.map +1 -1
  64. package/types/components/Avatar/Avatar.types.d.ts +47 -2
  65. package/types/components/Avatar/Avatar.types.d.ts.map +1 -1
  66. package/types/components/Avatar/utils/index.d.ts +1 -0
  67. package/types/components/Avatar/utils/index.d.ts.map +1 -1
  68. package/types/components/Badge/Badge.types.d.ts +8 -21
  69. package/types/components/Badge/Badge.types.d.ts.map +1 -1
  70. package/types/components/Counter/Counter.d.ts +2 -12
  71. package/types/components/Counter/Counter.d.ts.map +1 -1
  72. package/types/components/Counter/Counter.types.d.ts +1 -2
  73. package/types/components/Counter/Counter.types.d.ts.map +1 -1
  74. package/types/examples/plasma_b2c/components/Avatar/Avatar.config.d.ts +18 -0
  75. package/types/examples/plasma_b2c/components/Avatar/Avatar.config.d.ts.map +1 -1
  76. package/types/examples/plasma_b2c/components/Avatar/Avatar.d.ts +138 -6
  77. package/types/examples/plasma_b2c/components/Avatar/Avatar.d.ts.map +1 -1
  78. package/types/examples/plasma_b2c/components/Badge/Badge.d.ts +8 -48
  79. package/types/examples/plasma_b2c/components/Badge/Badge.d.ts.map +1 -1
  80. package/types/examples/plasma_b2c/components/Counter/Counter.d.ts +1 -6
  81. package/types/examples/plasma_b2c/components/Counter/Counter.d.ts.map +1 -1
  82. package/types/examples/plasma_web/components/Avatar/Avatar.config.d.ts +18 -0
  83. package/types/examples/plasma_web/components/Avatar/Avatar.config.d.ts.map +1 -1
  84. package/types/examples/plasma_web/components/Avatar/Avatar.d.ts +138 -6
  85. package/types/examples/plasma_web/components/Avatar/Avatar.d.ts.map +1 -1
  86. package/types/examples/plasma_web/components/Badge/Badge.d.ts +8 -48
  87. package/types/examples/plasma_web/components/Badge/Badge.d.ts.map +1 -1
  88. package/types/examples/plasma_web/components/Counter/Counter.d.ts +1 -6
  89. package/types/examples/plasma_web/components/Counter/Counter.d.ts.map +1 -1
  90. package/cjs/components/Avatar/Avatar.styles_1gd252x.css +0 -5
  91. package/es/components/Avatar/Avatar.styles_1gd252x.css +0 -5
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import type { ComponentProps } from 'react';
2
3
  import type { StoryObj, Meta } from '@storybook/react';
3
4
  import { disableProps } from '@salutejs/plasma-sb-utils';
@@ -6,6 +7,11 @@ import { argTypesFromConfig, WithTheme } from '../../../_helpers';
6
7
 
7
8
  import { Avatar, mergedConfig } from './Avatar';
8
9
 
10
+ const extraPlacements = ['top-left', 'top-right', 'bottom-left', 'bottom-right'];
11
+ const extraType = ['', 'badge', 'counter'];
12
+ const counterViews = ['default', 'accent', 'positive', 'warning', 'negative', 'dark', 'light'];
13
+ const badgeViews = ['default', 'accent', 'positive', 'warning', 'negative', 'dark', 'light'];
14
+
9
15
  const meta: Meta<typeof Avatar> = {
10
16
  title: 'b2c/Data Display/Avatar',
11
17
  decorators: [WithTheme],
@@ -13,12 +19,69 @@ const meta: Meta<typeof Avatar> = {
13
19
  argTypes: {
14
20
  ...argTypesFromConfig(mergedConfig),
15
21
  status: { control: 'select', options: ['active', 'inactive'] },
22
+ type: {
23
+ control: 'select',
24
+ options: extraType,
25
+ if: { arg: 'hasExtra', truthy: true },
26
+ },
27
+ extraPlacement: {
28
+ control: 'select',
29
+ options: extraPlacements,
30
+ if: { arg: 'hasExtra', truthy: true },
31
+ },
32
+ counterView: {
33
+ control: 'select',
34
+ options: counterViews,
35
+ if: { arg: 'type', eq: 'counter' },
36
+ },
37
+ count: {
38
+ control: 'number',
39
+ if: { arg: 'type', eq: 'counter' },
40
+ },
41
+ maxCount: {
42
+ control: 'number',
43
+ if: { arg: 'type', eq: 'counter' },
44
+ },
45
+ badgeView: {
46
+ control: 'select',
47
+ options: badgeViews,
48
+ if: { arg: 'type', eq: 'badge' },
49
+ },
50
+ text: {
51
+ control: 'text',
52
+ if: { arg: 'type', eq: 'badge' },
53
+ },
54
+ customColor: {
55
+ control: 'color',
56
+ if: { arg: 'type', eq: 'badge' },
57
+ },
58
+ customBackgroundColor: {
59
+ control: 'color',
60
+ if: { arg: 'type', eq: 'badge' },
61
+ },
62
+ pilled: {
63
+ control: 'boolean',
64
+ if: { arg: 'type', eq: 'badge' },
65
+ },
16
66
  },
17
67
  };
18
68
 
19
69
  export default meta;
20
70
 
21
- type Story = StoryObj<ComponentProps<typeof Avatar>>;
71
+ type StoryProps = ComponentProps<typeof Avatar> & {
72
+ enableContentLeft: boolean;
73
+ enableContentRight: boolean;
74
+ };
75
+ type Story = StoryObj<StoryProps>;
76
+
77
+ const BellIcon = (props) => (
78
+ <svg width="100%" viewBox="0 0 24 24" fill="none" {...props}>
79
+ <path
80
+ d="M11.501 21.28c1.088 0 1.978-.889 1.978-1.977H9.524c0 1.088.88 1.978 1.977 1.978zm5.933-5.932v-4.944c0-3.035-1.622-5.576-4.45-6.248v-.673c0-.82-.662-1.483-1.483-1.483-.82 0-1.483.662-1.483 1.483v.672c-2.838.673-4.45 3.204-4.45 6.25v4.943l-1.275 1.276c-.623.623-.188 1.69.692 1.69h13.022c.88 0 1.325-1.067.702-1.69l-1.275-1.276z"
81
+ fill="currentColor"
82
+ />
83
+ </svg>
84
+ );
22
85
 
23
86
  export const Default: Story = {
24
87
  args: {
@@ -27,10 +90,56 @@ export const Default: Story = {
27
90
  name: 'Иван Фадеев',
28
91
  url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
29
92
  isScalable: false,
93
+ hasExtra: false,
94
+ extraPlacement: 'top-right',
95
+ type: undefined,
96
+ counterView: 'accent',
97
+ count: 3,
98
+ maxCount: 10,
99
+ badgeView: 'accent',
100
+ text: '31',
101
+ pilled: true,
102
+ enableContentLeft: false,
103
+ enableContentRight: false,
30
104
  },
31
105
  argTypes: {
106
+ enableContentLeft: {
107
+ control: { type: 'boolean' },
108
+ if: { arg: 'type', eq: 'badge' },
109
+ },
110
+ enableContentRight: {
111
+ control: { type: 'boolean' },
112
+ if: { arg: 'type', eq: 'badge' },
113
+ },
32
114
  ...disableProps(['focused']),
33
115
  },
116
+ render: ({ enableContentLeft, enableContentRight, size, ...rest }: StoryProps) => {
117
+ const iconSize = () => {
118
+ switch (size) {
119
+ case 'xxl':
120
+ return '1rem';
121
+ case 'm':
122
+ return '0.625rem';
123
+ default:
124
+ return '0.75rem';
125
+ }
126
+ };
127
+
128
+ return (
129
+ <>
130
+ <Avatar
131
+ contentLeft={enableContentLeft ? <BellIcon width={iconSize()} height={iconSize()} /> : undefined}
132
+ contentRight={
133
+ !enableContentLeft && enableContentRight ? (
134
+ <BellIcon width={iconSize()} height={iconSize()} />
135
+ ) : undefined
136
+ }
137
+ size={size}
138
+ {...rest}
139
+ />
140
+ </>
141
+ );
142
+ },
34
143
  };
35
144
 
36
145
  export const Accessibility: Story = {
@@ -42,6 +151,14 @@ export const Accessibility: Story = {
42
151
  size: 'xxl',
43
152
  status: 'active',
44
153
  focused: true,
154
+ hasExtra: false,
155
+ extraPlacement: 'top-right',
156
+ type: undefined,
157
+ counterView: 'accent',
158
+ count: 3,
159
+ maxCount: 10,
160
+ badgeView: 'accent',
161
+ text: '31',
45
162
  },
46
163
  };
47
164
 
@@ -55,6 +172,14 @@ export const AccessibilityWithURL: Story = {
55
172
  focused: true,
56
173
  name: 'Микула Селянинович',
57
174
  url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
175
+ hasExtra: false,
176
+ extraPlacement: 'top-right',
177
+ type: undefined,
178
+ counterView: 'accent',
179
+ count: 3,
180
+ maxCount: 10,
181
+ badgeView: 'accent',
182
+ text: '31',
58
183
  },
59
184
  };
60
185
 
@@ -67,5 +192,13 @@ export const AccessibilityWithCustomText: Story = {
67
192
  status: 'inactive',
68
193
  focused: true,
69
194
  customText: 'ФИО',
195
+ hasExtra: false,
196
+ extraPlacement: 'top-right',
197
+ type: undefined,
198
+ counterView: 'accent',
199
+ count: 3,
200
+ maxCount: 10,
201
+ badgeView: 'accent',
202
+ text: '31',
70
203
  },
71
204
  };