This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Icon): Prevent passed className from being overwritten (#35)
## Summary When the `Icon` component was being provided with a `className` prop, this prop was overwriting the default class name generated for the icon, namely `mdi mdi-X`. In the web-app several icons disappeared mysteriously and this was because those component had this structure... ```js <Icon className="blah" name="message" /> ``` ...which is explained by this snippet: ```js <Icon className="bagels" name="message" /> //=> render Icon with className prop const Icon = createComponent({ props: () => ({ className: 'mdi mdi-message', //=> generated by `Icon.getClassName` }); // and then inside of `utils#createComponent` const resolvedProps = { ...baseProps(props), //=> className: mdi mdi-message ...props, //=> className: overwritten by bagels!!! }; ```
- Loading branch information
1 parent
b6b0d9b
commit ebfca7a
Showing
5 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import { renderWithTheme } from '../../test/utils'; | ||
import Icon from './Icon'; | ||
|
||
describe('<Icon />', () => { | ||
test('renders', () => { | ||
const { asFragment } = renderWithTheme(<Icon name="message" />); | ||
|
||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
test('renders with passed class name', () => { | ||
const { asFragment } = renderWithTheme(<Icon className="bagels" name="message" />); | ||
|
||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Icon /> renders 1`] = ` | ||
<DocumentFragment> | ||
.c0 { | ||
color: inherit; | ||
font-size: inherit; | ||
} | ||
<i | ||
class="mdi mdi-message re-icon c0" | ||
name="message" | ||
/> | ||
</DocumentFragment> | ||
`; | ||
|
||
exports[`<Icon /> renders with passed class name 1`] = ` | ||
<DocumentFragment> | ||
.c0 { | ||
color: inherit; | ||
font-size: inherit; | ||
} | ||
<i | ||
class="bagels mdi mdi-message re-icon c0" | ||
name="message" | ||
/> | ||
</DocumentFragment> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters