Skip to content

Commit

Permalink
added options to disable close modal actions (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
lghiur authored Apr 9, 2021
1 parent c69509d commit 2db2bcb
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/tyk-ui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/tyk-ui.js.map

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions logo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const React = require('react')
const { version } = require('../package.json')

const Logo = () => {
return (
<a
className="rsg-logo"
href="https://github.com/TykTechnologies/tyk-ui"
target="_blank"
>
<img src="https://tyk.io/wp-content/themes/tyk/dist/svg/logo.svg" width="190px" height="62px"/>
<em className="rsg-logo-version">v.{version}</em>
</a>
);
};

module.exports = Logo
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tyk-technologies/tyk-ui",
"version": "2.1.10",
"version": "2.1.11",
"description": "Tyk UI - ui reusable components",
"main": "lib/index.js",
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions src/components/Modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export default class Modal extends Component {
PropTypes.node,
PropTypes.string,
]),
/** If set on true, the Modal won't close when clicking on the overlay or by pressing ESC key */
disableCloseCommands: PropTypes.bool,
/** If true the Modal will be by default opened */
opened: PropTypes.bool,
/** Callback method when the Modal is closed */
Expand Down Expand Up @@ -72,7 +74,7 @@ export default class Modal extends Component {

render() {
const {
children, opened, onClose, size, ...restProps
children, disableCloseCommands, opened, onClose, size, ...restProps
} = this.props;

return (
Expand Down Expand Up @@ -111,7 +113,7 @@ export default class Modal extends Component {
>
<button
className={this.getBackdropCssClasses()}
onClick={this.closeModal}
onClick={!disableCloseCommands && this.closeModal}
onKeyDown={() => {}}
type="button"
/>
Expand Down
32 changes: 16 additions & 16 deletions src/components/Modal/js/ModalHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import PropTypes from 'prop-types';
import Button from '../../Button';
import { ModalContext } from '../modal-context';

const ModalHeader = (props) => {
const { children } = props;

return (
<ModalContext.Consumer>
{
modalContext => (
<div className="tyk-modal__header">
{ children }
<Button onClick={modalContext.closeModal} iconType="times" iconOnly theme="white" iconPosition="left" />
</div>
)
}
</ModalContext.Consumer>
);
};
const ModalHeader = ({
children,
hideCloseButton = false,
}) => (
<ModalContext.Consumer>
{
modalContext => (
<div className="tyk-modal__header">
{ children }
{!hideCloseButton && <Button onClick={modalContext.closeModal} iconType="times" iconOnly theme="white" iconPosition="left" />}
</div>
)
}
</ModalContext.Consumer>
);

ModalHeader.propTypes = {
hideCloseButton: PropTypes.bool,
children: PropTypes.oneOfType([
PropTypes.element,
PropTypes.node,
Expand Down
2 changes: 1 addition & 1 deletion styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
path.join(__dirname, 'src/index.scss')
],
styleguideComponents: {
Logo: path.join(__dirname, 'lib/logo')
Logo: path.join(__dirname, 'logo')
},
template: {
favicon: 'https://tyk.io/wp-content/uploads/2019/08/cropped-favicon-384x384.png'
Expand Down
4 changes: 3 additions & 1 deletion styleguide.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ const styles = {
fontSize: theme.fontSize.small,
fontFamily: theme.fontFamily.monospace,
marginLeft: rhythm(0.25),
opacity: 0.5
opacity: 0.5,
display: 'flex',
justifyContent: 'center'
}
},
sidebar: {
Expand Down

0 comments on commit 2db2bcb

Please sign in to comment.