-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(icons): enable customization (#1839)
* feat(icons): enable customization * chore: alert snapshots * fix: story
- Loading branch information
Showing
155 changed files
with
1,043 additions
and
294 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@twilio-paste/icons': minor | ||
--- | ||
|
||
[Icons] enable all icons to respect customization by giving them a generic element name, and ability to create custom element names. |
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,49 @@ | ||
import * as React from 'react'; | ||
import {matchers} from 'jest-emotion'; | ||
import {render} from '@testing-library/react'; | ||
import {CustomizationProvider} from '@twilio-paste/customization'; | ||
import {AgentIcon} from '../src/AgentIcon'; | ||
|
||
expect.extend(matchers); | ||
|
||
describe('Icons', () => { | ||
describe('HTML attributes', () => { | ||
it('should have the default element name', () => { | ||
const {container} = render(<AgentIcon decorative />); | ||
expect(container.querySelector('[data-paste-element="ICON"]')).toBeInTheDocument(); | ||
}); | ||
it('should have a custom element name', () => { | ||
const {container} = render(<AgentIcon element="CUSTOM_ICON" decorative />); | ||
expect(container.querySelector('[data-paste-element="CUSTOM_ICON"]')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('Customization', () => { | ||
it('should apply custom styles to customizaed icons', () => { | ||
const {container} = render( | ||
<CustomizationProvider | ||
baseTheme="default" | ||
elements={{ | ||
ICON: {borderRadius: 'borderRadius20', backgroundColor: 'colorBackgroundSuccess'}, | ||
CUSTOM_ICON: {borderRadius: 'borderRadius20', backgroundColor: 'colorBackgroundDestructive'}, | ||
}} | ||
> | ||
<> | ||
<AgentIcon decorative /> | ||
<AgentIcon element="CUSTOM_ICON" decorative /> | ||
</> | ||
</CustomizationProvider> | ||
); | ||
expect(container.querySelector('[data-paste-element="ICON"]')).toHaveStyleRule('border-radius', '4px'); | ||
expect(container.querySelector('[data-paste-element="ICON"]')).toHaveStyleRule( | ||
'background-color', | ||
'rgb(20,176,83)' | ||
); | ||
expect(container.querySelector('[data-paste-element="CUSTOM_ICON"]')).toHaveStyleRule('border-radius', '4px'); | ||
expect(container.querySelector('[data-paste-element="CUSTOM_ICON"]')).toHaveStyleRule( | ||
'background-color', | ||
'rgb(214,31,31)' | ||
); | ||
}); | ||
}); | ||
}); |
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
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
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
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
Oops, something went wrong.