Skip to content

Commit

Permalink
chore(styles,react): update proptype, padding, and test
Browse files Browse the repository at this point in the history
  • Loading branch information
tbusillo committed Aug 2, 2023
1 parent 4a60376 commit a355e8e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
11 changes: 0 additions & 11 deletions packages/react/__tests__/src/components/Notice/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ test('should return correctly with props passed in', async () => {
expect(wrapper.prop('children')).toBe('bar');
});

test('should fallback to the `info-circle` icon when an invalid icon type is passed in', async () => {
const wrapper = mount(
<Notice type="info" icon="invalid-icon" title="foo">
bar
</Notice>
);

expect(wrapper.find('Notice').length).toBe(1);
expect(wrapper.find('Icon').prop('type')).toBe('info-circle');
});

test('should render with the correct icon when a valid icon `type` string is passed in', async () => {
const wrapper = mount(<Notice type="info" icon="bolt" title="Dynamo!" />);

Expand Down
12 changes: 4 additions & 8 deletions packages/react/src/components/Notice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ const Notice = forwardRef<HTMLDivElement, NoticeProps>(
{...otherProps}
>
<div className="Notice__title">
<Icon
type={icon || (iconTypeMap[type] as IconType) || iconTypeMap.info}
/>
<Icon type={icon || (iconTypeMap[type] as IconType)} />
{title}
</div>
{children && typeof children === 'string' ? (
Expand All @@ -53,11 +51,9 @@ Notice.propTypes = {
type: PropTypes.oneOf(['caution', 'info']),
// @ts-expect-error
title: PropTypes.oneOf([
'string',
'number',
'ReactElement',
'ReactFragment',
'ReactPortal'
PropTypes.string,
PropTypes.number,
PropTypes.element
]),
// @ts-expect-error
icon: PropTypes.string
Expand Down
2 changes: 1 addition & 1 deletion packages/styles/notice.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

.Notice {
display: block;
padding: var(--space-small) var(--space-small);
padding: var(--space-smaller) var(--space-small);
border: 1px solid var(--notice-border-color);
background-color: var(--notice-background-color);
color: var(--notice-text-color);
Expand Down

0 comments on commit a355e8e

Please sign in to comment.