Skip to content

Commit

Permalink
fix(Offcanvas): use placement prop rather than direction prop (#2511
Browse files Browse the repository at this point in the history
)
  • Loading branch information
BenJenkinson committed Apr 29, 2022
1 parent 1179b87 commit e47569b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const propTypes = {
className: PropTypes.string,
container: targetPropType,
cssModule: PropTypes.object,
direction: PropTypes.oneOf(['start', 'end', 'bottom', 'top', 'left', 'right']),
placement: PropTypes.oneOf(['start', 'end', 'bottom', 'top']),
fade: PropTypes.bool,
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.func,]),
isOpen: PropTypes.bool,
Expand All @@ -54,7 +54,7 @@ const propsToOmit = Object.keys(propTypes);
const defaultProps = {
isOpen: false,
autoFocus: true,
direction: 'start',
placement: 'start',
scrollable: false,
role: 'dialog',
backdrop: true,
Expand Down Expand Up @@ -336,7 +336,7 @@ class Offcanvas extends React.Component {

render() {
const {
direction,
placement,
unmountOnClose
} = this.props;

Expand Down Expand Up @@ -410,7 +410,7 @@ class Offcanvas extends React.Component {
onExited={this.onClosed}
cssModule={cssModule}
className={mapToCssModules(classNames('offcanvas', className,
`offcanvas-${direction}`
`offcanvas-${placement}`
), cssModule)}
innerRef={(c) => {
this._dialog = c;
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/Offcanvas.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ describe('Offcanvas', () => {
wrapper.unmount();
});

it('should render with the class "offcanvas-${direction}" when direction is passed', () => {
it('should render with the class "offcanvas-${placement}" when placement is passed', () => {
isOpen = true;
const wrapper = mount(
<Offcanvas isOpen={isOpen} toggle={toggle} direction="top">
<Offcanvas isOpen={isOpen} toggle={toggle} placement="top">
Yo!
</Offcanvas>
);
Expand Down
2 changes: 1 addition & 1 deletion stories/examples/Offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Example.args = {
};

Example.argTypes = {
direction: {
placement: {
control: { type: 'select' },
options: ['top', 'start', 'end', 'bottom']
},
Expand Down
2 changes: 1 addition & 1 deletion types/lib/Offcanvas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { CSSModule } from './utils';
import { FadeProps } from './Fade';

export type Placement = 'start' | 'end' | 'left' | 'right' | 'bottom' | 'top';
export type Placement = 'start' | 'end' | 'bottom' | 'top';

export interface OffcanvasProps extends React.HTMLAttributes<HTMLElement> {
[key: string]: any;
Expand Down

0 comments on commit e47569b

Please sign in to comment.