import * as React from 'react';
import { css } from '../../../../stitches.config';
import * as AlertDialog from '@radix-ui/react-alert-dialog';
export default { title: 'Components/AlertDialog' };
export const Styled = () => (
delete everything
Are you sure?
This will do a very dangerous thing. Thar be dragons!
yolo, do it
maybe not
);
export const Controlled = () => {
const [open, setOpen] = React.useState(false);
const [housePurchased, setHousePurchased] = React.useState(false);
return (
{
if (housePurchased) {
e.preventDefault();
setHousePurchased(false);
}
}}
>
{housePurchased ? 'You bought the house! Sell it!' : 'Buy this house'}
Are you sure?
Houses are very expensive and it looks like you only have €20 in the bank. Maybe
consult with a financial advisor?
setHousePurchased(true)}>
buy it anyway
good point, I'll reconsider
);
};
export const Chromatic = () => (
Uncontrolled
Closed
delete everything
Title
Description
Confirm
Cancel
Open
delete everything
Title
Description
Confirm
Cancel
Uncontrolled with reordered parts
Closed
Title
Description
Confirm
Cancel
delete everything
Open
Title
Description
Confirm
Cancel
delete everything
Controlled
Closed
delete everything
Title
Description
Confirm
Cancel
Open
delete everything
Title
Description
Confirm
Cancel
Controlled with reordered parts
Closed
Title
Description
Confirm
Cancel
delete everything
Open
Title
Description
Confirm
Cancel
delete everything
State attributes
Closed
delete everything
Title
Description
Confirm
Cancel
Open
delete everything
Title
Description
Confirm
Cancel
);
Chromatic.parameters = { chromatic: { disable: false } };
const triggerClass = css({});
const RECOMMENDED_CSS__ALERT_DIALOG__OVERLAY: any = {
// ensures overlay is positionned correctly
position: 'fixed',
top: 0,
right: 0,
bottom: 0,
left: 0,
};
const overlayClass = css({
...RECOMMENDED_CSS__ALERT_DIALOG__OVERLAY,
backgroundColor: 'black',
opacity: 0.2,
});
const RECOMMENDED_CSS__ALERT_DIALOG__CONTENT: any = {
// ensures good default position for content
position: 'fixed',
top: 0,
left: 0,
};
const contentClass = css({
...RECOMMENDED_CSS__ALERT_DIALOG__CONTENT,
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
background: 'white',
minWidth: 300,
minHeight: 150,
padding: 50,
borderRadius: 10,
backgroundColor: 'white',
boxShadow: '0 2px 10px rgba(0, 0, 0, 0.12)',
});
const cancelClass = css({
appearance: 'none',
padding: 10,
border: 'none',
background: '$grey100',
});
const actionClass = css({
appearance: 'none',
padding: 10,
border: 'none',
backgroundColor: '$red',
color: '$white',
});
const titleClass = css({});
const descriptionClass = css({});
const chromaticContentClass = css(contentClass, {
padding: 10,
minWidth: 'auto',
minHeight: 'auto',
});
const styles = {
backgroundColor: 'rgba(0, 0, 255, 0.3)',
border: '2px solid blue',
padding: 10,
'&[data-state="closed"]': { borderColor: 'red' },
'&[data-state="open"]': { borderColor: 'green' },
};
const triggerAttrClass = css(styles);
const overlayAttrClass = css(overlayClass, styles);
const contentAttrClass = css(chromaticContentClass, styles);
const cancelAttrClass = css(styles);
const actionAttrClass = css(styles);
const titleAttrClass = css(styles);
const descriptionAttrClass = css(styles);