uikit-react-public 0.50.2 → 0.50.4

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.
@@ -111,8 +111,8 @@ export const WithActionButton: Story = {
111
111
  {...args}
112
112
  actionButton={
113
113
  <Button
114
- leftIcon={<Icon.ChevronRight />}
115
- rightIcon={<Icon.ChevronRight />}
114
+ leftIcon={<Icon.ArrowRight />}
115
+ rightIcon={<Icon.ArrowRight />}
116
116
  >
117
117
  Action
118
118
  </Button>
@@ -61,7 +61,7 @@ const Alert = ({
61
61
  const baseStyles = css`
62
62
  display: flex;
63
63
  align-items: flex-start;
64
- gap: ${theme.margin.m8};
64
+ gap: ${actionButton ? theme.margin.m32 : theme.margin.m8};
65
65
  padding: ${padding.p16} ${padding.p12} ${padding.p16} ${padding.p8};
66
66
  border-left-width: 4px;
67
67
  border-left-style: solid;
@@ -123,10 +123,17 @@ const Alert = ({
123
123
  overflow-wrap: anywhere;
124
124
  `;
125
125
 
126
+ const contentGroupStyle = css`
127
+ display: flex;
128
+ align-items: flex-start;
129
+ gap: ${theme.margin.m8};
130
+ flex: 1;
131
+ min-width: 0;
132
+ `;
133
+
126
134
  const actionButtonStyle = css`
127
135
  align-self: center;
128
136
  flex-shrink: 0;
129
- margin-left: auto;
130
137
  `;
131
138
 
132
139
  const IconComp = {
@@ -151,6 +158,22 @@ const Alert = ({
151
158
  })
152
159
  : null;
153
160
 
161
+ const alertContent = (
162
+ <>
163
+ <IconComp
164
+ className={iconStyle}
165
+ aria-label={typeName}
166
+ {...iconProps}
167
+ />
168
+ <div
169
+ {...contentProps}
170
+ className={cx(contentStyle, contentProps?.className)}
171
+ >
172
+ {children}
173
+ </div>
174
+ </>
175
+ );
176
+
154
177
  return (
155
178
  <AlertContext.Provider value={{ type }}>
156
179
  <div
@@ -159,17 +182,11 @@ const Alert = ({
159
182
  role='alert'
160
183
  {...props}
161
184
  >
162
- <IconComp
163
- className={iconStyle}
164
- aria-label={typeName}
165
- {...iconProps}
166
- />
167
- <div
168
- {...contentProps}
169
- className={cx(contentStyle, contentProps?.className)}
170
- >
171
- {children}
172
- </div>
185
+ {actionButton ? (
186
+ <div className={contentGroupStyle}>{alertContent}</div>
187
+ ) : (
188
+ alertContent
189
+ )}
173
190
  {renderedActionButton}
174
191
  </div>
175
192
  </AlertContext.Provider>
@@ -104,8 +104,8 @@ describe('Alert', () => {
104
104
  type='info'
105
105
  actionButton={
106
106
  <Button
107
- leftIcon={<Icon.ChevronRight />}
108
- rightIcon={<Icon.ChevronRight />}
107
+ leftIcon={<Icon.ArrowRight />}
108
+ rightIcon={<Icon.ArrowRight />}
109
109
  onClick={onClick}
110
110
  >
111
111
  Action
@@ -122,4 +122,20 @@ describe('Alert', () => {
122
122
  await user.click(screen.getByRole('button', { name: 'Action' }));
123
123
  expect(onClick).toHaveBeenCalledOnce();
124
124
  });
125
+
126
+ test('keeps 32px between the content and action button', () => {
127
+ render(
128
+ <ThemeContextProvider>
129
+ <Alert
130
+ type='info'
131
+ actionButton={<Button>Action</Button>}
132
+ >
133
+ <Alert.Message>Alert message</Alert.Message>
134
+ </Alert>
135
+ </ThemeContextProvider>
136
+ );
137
+
138
+ const alert = screen.getByRole('alert');
139
+ expect(getComputedStyle(alert).gap).toBe('32px');
140
+ });
125
141
  });
@@ -17,7 +17,7 @@ export const usage = {
17
17
  destructiveNoPadding: `<Button variant='tertiary-destructive-no-padding'>Destructive Action</Button>`,
18
18
  onDark: `<Button variant='secondary' onLight={false}>Secondary Button</Button>`,
19
19
  withIcon: `<Button icon={<Icon.AlertTriangle />}>Button</Button>`,
20
- withTwoIcons: `<Button leftIcon={<Icon.ChevronRight />} rightIcon={<Icon.ChevronRight />}>Action</Button>`,
20
+ withTwoIcons: `<Button leftIcon={<Icon.ArrowRight />} rightIcon={<Icon.ArrowRight />}>Action</Button>`,
21
21
  loading: `<Button loading>Loading Button</Button>`,
22
22
  link: `<Button as='a' href='https://www.ucl.ac.uk' target='_blank'>Go to UCL&#39;s website</Button>`,
23
23
  fullWidth: `<Button fullWidth>Full Width Button</Button>`,
@@ -365,8 +365,8 @@ export const WithTwoIcons: Story = {
365
365
  name: 'With two icons',
366
366
  args: {
367
367
  children: 'Action',
368
- leftIcon: <Icon.ChevronRight />,
369
- rightIcon: <Icon.ChevronRight />,
368
+ leftIcon: <Icon.ArrowRight />,
369
+ rightIcon: <Icon.ArrowRight />,
370
370
  },
371
371
  };
372
372
 
@@ -83,8 +83,8 @@ describe('Button', () => {
83
83
  render(
84
84
  <ThemeContextProvider>
85
85
  <Button
86
- leftIcon={<Icon.ChevronRight />}
87
- rightIcon={<Icon.ChevronRight />}
86
+ leftIcon={<Icon.ArrowRight />}
87
+ rightIcon={<Icon.ArrowRight />}
88
88
  size='xsmall'
89
89
  >
90
90
  Action
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "uikit-react-public",
3
3
  "private": false,
4
4
  "license": "UNLICENSED",
5
- "version": "0.50.2",
5
+ "version": "0.50.4",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",