uikit-react-public 0.50.2 → 0.50.3

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.
@@ -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>
@@ -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
  });
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.3",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",