Skip to content

Commit

Permalink
feat(Overlay): add rtl prop for overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
tao1991123 committed Nov 28, 2018
1 parent 8825c0c commit 6d77142
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/overlay/demo/nested.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Overlay } from '@alifd/next';

const { Popup } = Overlay;

ReactDOM.render((
ReactDOM.render(
<Popup trigger={<button>Open first overlay</button>}
triggerType="click">
<div className="overlay-demo">
Expand All @@ -33,7 +33,7 @@ ReactDOM.render((
<p>Hello World From First Overlay!</p>
</div>
</Popup>
), mountNode);
, mountNode);
````

````css
Expand Down
4 changes: 2 additions & 2 deletions docs/overlay/demo/scroll.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Overlay } from '@alifd/next';

const { Popup } = Overlay;

ReactDOM.render((
ReactDOM.render(
<div className="scroll-container">
<Popup trigger={<button>Open</button>}
triggerType="click"
Expand All @@ -31,7 +31,7 @@ ReactDOM.render((
</Popup>
<div style={{ height: '300px' }} />
</div>
), mountNode);
, mountNode);
````

````css
Expand Down
8 changes: 5 additions & 3 deletions src/overlay/overlay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default class Overlay extends Component {
static propTypes = {
prefix: PropTypes.string,
pure: PropTypes.bool,
rtl: PropTypes.bool,
className: PropTypes.string,
style: PropTypes.object,
/**
Expand Down Expand Up @@ -613,7 +614,7 @@ export default class Overlay extends Component {
const {
prefix, className, style, children: propChildren,
target, align, offset, container, hasMask, needAdjust,
beforePosition, onPosition, wrapperStyle,
beforePosition, onPosition, wrapperStyle, rtl,
shouldUpdatePosition: propShouldUpdatePosition,
cache, wrapperClassName, onMaskMouseEnter, onMaskMouseLeave
} = this.props;
Expand Down Expand Up @@ -661,12 +662,13 @@ export default class Overlay extends Component {
}, wrapperStyle);

children = (
<div className={wrapperClazz} style={newWrapperStyle}>
<div className={wrapperClazz} style={newWrapperStyle} dir={rtl ? 'rtl' : undefined}>
{hasMask ?
<div className={`${prefix}overlay-backdrop`}
onClick={this.handleMaskClick}
onMouseEnter={onMaskMouseEnter}
onMouseLeave={onMaskMouseLeave} /> :
onMouseLeave={onMaskMouseLeave}
dir={rtl ? 'rtl' : undefined} /> :
null}
{children}
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/overlay/popup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export default class Popup extends Component {
followTrigger: PropTypes.bool,
container: PropTypes.any,
hasMask: PropTypes.bool,
wrapperStyle: PropTypes.object
wrapperStyle: PropTypes.object,
rtl: PropTypes.bool,
};

static defaultProps = {
Expand All @@ -74,7 +75,8 @@ export default class Popup extends Component {
delay: 200,
canCloseByTrigger: true,
followTrigger: false,
container: () => document.body
container: () => document.body,
rtl: false,
};

constructor(props) {
Expand Down

0 comments on commit 6d77142

Please sign in to comment.