Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@workday/canvas-kit-react-modal
Advanced tools
Modal to display a popup with a translucent background
A Modal component that allows you to render a Popup with translucent overlays.
yarn add @workday/canvas-kit-react
or
yarn add @workday/canvas-kit-react-modal
import * as React from 'react';
import {Button} from '@workday/canvas-kit-react-button';
import {Modal, useModal} from '@workday/canvas-kit-react-modal';
const DeleteItem = ({item, onDelete}) => {
const modal = useModal();
const deleteItem = event => {
modal.closeModal();
onDelete(event, item);
};
return (
<>
<Button variant={Button.Variant.Delete} {...modal.targetProps}>
Delete Item
</Button>
<Modal heading={'Delete Item'} {...modal.modalProps}>
<p>Are you sure you'd like to delete the item titled '{item.name}'?</p>
<Button onClick={deleteItem} variant={Button.Variant.Delete}>
Delete
</Button>
<Button onClick={closeModal} variant={Button.Variant.Secondary}>
Cancel
</Button>
</Modal>
</>
);
};
// usage
<DeleteItem
item={{id: 1, name: 'My Item'}}
onDelete={(event, item) => console.log(`Deleted ${item.id}: '${item.name}'`)}
/>;
Width: ModalWidth
<Modal width={Modal.Width.m} heading={'Modal Title'} handleClose={this.handleClose} />
heading: ReactNode
Heading at the top of the card.
open: boolean
Allows you to open/close modal
Default: false
width: ModalWidth
You can choose between s or m for your modal width
Default: ModalWidth.s
Name | Size (px) |
---|---|
s | 440 |
m | 800 |
padding: PopupPadding
You can choose between zero, s, l for your padding
Default: PopupPadding.l
Name | Size (px) |
---|---|
zero | 0 |
s | 16 |
l | 32 |
handleClose: () => void
Callback to handle close of your Modal and any other event when the Modal is closed.
firstFocusRef: React.RefObject<HTMLElement>
Optional override of the auto-select functionality of the Modal. If this ref is defined, that element will receive focus when the modal is opened. There are many suggestions to what that element should be. Contact an accessibility specialist or go through the https://www.w3.org/TR/wai-aria-practices/ document for instances where this might be useful. Make sure this is focusable ref, like a button. If you're unsure, don't define this and leave it to the default behavior.
If this ref is not provided the modal will try to use the close icon. If that icon is not available, it will make the modal heading focusable and focus on that instead.
closeButtonAriaLabel: string
Aria label string for the close icon button
FAQs
Modal to display a popup with a translucent background
The npm package @workday/canvas-kit-react-modal receives a total of 95 weekly downloads. As such, @workday/canvas-kit-react-modal popularity was classified as not popular.
We found that @workday/canvas-kit-react-modal demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.