-
-
Notifications
You must be signed in to change notification settings - Fork 927
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Message): make the visual style of Message more prominent (#3603)
* fix(Message): make the visual style of Message more prominent * docs: add a11y guide * fix: fix error tests * fix: adjust the background color * fix: add zIndex for full message * docs: update examples
- Loading branch information
Showing
15 changed files
with
147 additions
and
39 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
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,35 @@ | ||
<!--start-code--> | ||
|
||
```js | ||
import { Message, Button, Divider } from 'rsuite'; | ||
|
||
const App = () => ( | ||
<> | ||
<Message showIcon type="warning" header={<strong>Cannot delete the file</strong>}> | ||
We are sorry, the file cannot be deleted. Please try again later. | ||
</Message> | ||
|
||
<Message showIcon type="error" header={<strong>A problem occurred</strong>}> | ||
<ol> | ||
<li>Please check your network connection.</li> | ||
<li>Please check the file permissions.</li> | ||
<li>Please check the file size.</li> | ||
<li>Please check the file format.</li> | ||
</ol> | ||
</Message> | ||
|
||
<Message showIcon type="info" header={<strong>Do you want to allow notifications?</strong>}> | ||
We can let you know when new messages arrive. | ||
<hr /> | ||
<ButtonToolbar> | ||
<Button size="sm">Don't allow</Button> | ||
<Button size="sm">Allow</Button> | ||
</ButtonToolbar> | ||
</Message> | ||
</> | ||
); | ||
ReactDOM.render(<App />, document.getElementById('root')); | ||
``` | ||
<!--end-code--> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import Message from '../index'; | ||
import { getDOMNode, getStyle, toRGB } from '@test/utils'; | ||
|
||
import { toRGB } from '@test/utils'; | ||
import '../styles/index.less'; | ||
|
||
describe('Message styles', () => { | ||
it('Should render the correct background color', () => { | ||
const instanceRef = React.createRef<HTMLDivElement>(); | ||
render(<Message ref={instanceRef} />); | ||
assert.equal(getStyle(getDOMNode(instanceRef.current), 'backgroundColor'), toRGB('#f0f9ff')); | ||
render(<Message />); | ||
expect(screen.getByRole('alert')).to.have.style('background-color', toRGB('#fff')); | ||
}); | ||
|
||
it('Icon should render the correct color', () => { | ||
const instanceRef = React.createRef<HTMLDivElement>(); | ||
render(<Message showIcon type="info" ref={instanceRef} />); | ||
const icon = getDOMNode(instanceRef.current).querySelector('.rs-icon') as HTMLElement; | ||
assert.equal(getStyle(icon, 'color'), toRGB('#2196f3')); | ||
render(<Message showIcon type="info" />); | ||
|
||
expect(screen.getByRole('alert').querySelector('.rs-icon')).to.have.style( | ||
'color', | ||
toRGB('#2196f3') | ||
); | ||
}); | ||
}); |
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