Skip to content

Commit d141eea

Browse files
author
Austin Green
authored
fix(notifications): show correct Notification and Alert styling (#379)
1 parent 31dc792 commit d141eea

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

packages/notifications/src/Alert.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import styled from 'styled-components';
99
import PropTypes from 'prop-types';
1010
import classNames from 'classnames';
1111
import CalloutStyles from '@zendeskgarden/css-callouts';
12-
import { retrieveTheme } from '@zendeskgarden/react-theming';
12+
import { retrieveTheme, isRtl } from '@zendeskgarden/react-theming';
1313

14-
import Well from './Well';
1514
const COMPONENT_ID = 'notifications.alert';
1615

1716
const VALIDATION = {
@@ -24,11 +23,16 @@ const VALIDATION = {
2423
/**
2524
* Supports all `<div>` props
2625
*/
27-
const Alert = styled(Well).attrs(props => ({
26+
const Alert = styled.div.attrs(props => ({
2827
'data-garden-id': COMPONENT_ID,
2928
'data-garden-version': PACKAGE_VERSION,
30-
recessed: props.type === VALIDATION.INFO,
31-
className: classNames(props.className, {
29+
className: classNames(CalloutStyles['c-callout'], {
30+
// RTL
31+
[CalloutStyles['is-rtl']]: isRtl(props),
32+
33+
// Styles
34+
[CalloutStyles['c-callout--recessed']]: props.type === VALIDATION.INFO,
35+
3236
// Validation types
3337
[CalloutStyles['c-callout--success']]: props.type === VALIDATION.SUCCESS,
3438
[CalloutStyles['c-callout--warning']]: props.type === VALIDATION.WARNING,

packages/notifications/src/Alert.spec.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@
66
*/
77

88
import React from 'react';
9-
import { render } from 'garden-test-utils';
9+
import { render, renderRtl } from 'garden-test-utils';
1010
import Alert from './Alert';
1111

1212
describe('Alert', () => {
1313
describe('validation', () => {
14+
it('should render with RTL styling if applied', () => {
15+
const { container } = renderRtl(<Alert type="success" />);
16+
17+
expect(container.firstChild).toHaveClass('is-rtl');
18+
});
19+
1420
it('should render success styling correctly', () => {
1521
const { container } = render(<Alert type="success" />);
1622

packages/notifications/src/Notification.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import styled from 'styled-components';
99
import PropTypes from 'prop-types';
1010
import classNames from 'classnames';
1111
import CalloutStyles from '@zendeskgarden/css-callouts';
12-
import { retrieveTheme } from '@zendeskgarden/react-theming';
12+
import { retrieveTheme, isRtl } from '@zendeskgarden/react-theming';
1313

14-
import Well from './Well';
1514
const COMPONENT_ID = 'notifications.notification';
1615

1716
const VALIDATION = {
@@ -24,11 +23,13 @@ const VALIDATION = {
2423
/**
2524
* Supports all `<div>` props
2625
*/
27-
const Notification = styled(Well).attrs(props => ({
26+
const Notification = styled.div.attrs(props => ({
2827
'data-garden-id': COMPONENT_ID,
2928
'data-garden-version': PACKAGE_VERSION,
30-
floating: true,
31-
className: classNames(props.className, {
29+
className: classNames(CalloutStyles['c-callout'], CalloutStyles['c-callout--dialog'], {
30+
// RTL
31+
[CalloutStyles['is-rtl']]: isRtl(props),
32+
3233
// Validation types
3334
[CalloutStyles['c-callout--success']]: props.type === VALIDATION.SUCCESS,
3435
[CalloutStyles['c-callout--warning']]: props.type === VALIDATION.WARNING,

packages/notifications/src/Notification.spec.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@
66
*/
77

88
import React from 'react';
9-
import { render } from 'garden-test-utils';
9+
import { render, renderRtl } from 'garden-test-utils';
1010
import Notification from './Notification';
1111

1212
describe('Notification', () => {
1313
describe('validation', () => {
14+
it('should render with RTL styling if applied', () => {
15+
const { container } = renderRtl(<Notification />);
16+
17+
expect(container.firstChild).toHaveClass('is-rtl');
18+
});
19+
1420
it('should render success styling correctly', () => {
1521
const { container } = render(<Notification type="success" />);
1622

0 commit comments

Comments
 (0)