-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new Custom DialogTitle to @comet/admin #2609
base: main
Are you sure you want to change the base?
Conversation
const Title = createComponentSlot(MUIDialogTitle)<DialogTitleClassKey>({ | ||
componentName: "DialogTitle", | ||
slotName: "dialogTitle", | ||
})(css` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this slot should be called "Root" to be consistent with other components
.changeset/curvy-bulldogs-boil.md
Outdated
Add new custom `DialogTitle` to @comet/admin | ||
|
||
- optional `onClose` prop adds Close Button to the Component | ||
|
||
Example: | ||
|
||
- `<DialogTitle onClose={() => {...}} />` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mentioning "@comet/admin" is not necessary as this changelog is explicitly for "@comet/admin"
It is not possible to understand why we need this component without reading the JIRA task. Please make sure that a PR can be understood without having to look into the task. |
@jamesricky in the MUI docs they achieve this button using an IconButton and absolute positioning: https://mui.com/material-ui/react-dialog/#customization. Wouldn't this be the preferred way? |
Yes, probably a good idea 👍🏼 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better if it were a custom dialog, and not a dialog title? IMO the onClose prop would make more sense on the dialog.
@jamesricky @fichtnerma what do you think about this suggestion? |
That probably makes sense 👍🏼 <Dialog
open={showDialog}
title="This is a dialog"
onClose={() => {
setShowDialog(false);
}}
>
{dialogContent}
</Dialog> This could also be helpful for aligning the Buttons in |
Yeah makes more sense to me logically |
Dialog as MUIDialog, | ||
DialogTitle as MUIDialogTitle, | ||
IconButton as MUIIconButton, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Mui
instead of MUI
to stay consistent with other import renames.
const Root = createComponentSlot(MUIDialog)<DialogClassKey>({ | ||
componentName: "Dialog", | ||
slotName: "root", | ||
})(css``); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
})(css``); | |
})(); |
storybook/src/admin/Dialog.tsx
Outdated
const textContent = | ||
"Dialog content. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."; | ||
|
||
storiesOf("@comet/admin/Dialog", module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be combined with the existing Dialog
story: https://storybook.comet-dxp.com/?path=/story/comet-admin-mui--dialog
Maybe extend the existing one and add knobs for title
and onClose
, similar to Dialog size
:
comet/storybook/src/admin/mui/Dialog.tsx
Line 29 in f8ae084
const selectedDialogSize = select("Dialog size", dialogSizeOptions, "sm"); |
@@ -22,6 +22,7 @@ export { SplitButtonContext, SplitButtonContextOptions } from "./common/buttons/ | |||
export { useSplitButtonContext } from "./common/buttons/split/useSplitButtonContext"; | |||
export { ClearInputAdornment, ClearInputAdornmentProps } from "./common/ClearInputAdornment"; | |||
export { CometLogo } from "./common/CometLogo"; | |||
export { Dialog, DialogClassKey, DialogProps } from "./common/Dialog"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add an import restriction to prevent using MUIs Dialog
.
This is how it's done for Alert
for example:
comet/packages/eslint-config/react.js
Lines 42 to 46 in f8ae084
{ | |
name: "@mui/material", | |
importNames: ["Alert"], | |
message: "Please use Alert from @comet/admin instead", | |
}, |
const IconButton = createComponentSlot(MUIIconButton)<DialogClassKey>({ | ||
componentName: "Dialog", | ||
slotName: "iconButton", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IconButton
is too generic imo, I'd prefer something like CloseButton
})(css` | ||
color: inherit; | ||
width: 100%; | ||
padding-right: 40px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This padding should only be added when there is a close-button, otherwise the spacings left and right of the text are inconsistent.
color: inherit; | ||
width: 100%; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be the default when using a div
.
color: inherit; | |
width: 100%; |
right: 20px; | ||
`); | ||
|
||
const TitleWrapper = createComponentSlot("div")<DialogClassKey>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically a div
is not allowed inside h2
.
const TitleWrapper = createComponentSlot("div")<DialogClassKey>({ | |
const TitleWrapper = createComponentSlot("span")<DialogClassKey>({ |
I wouldn't do this. I'd render the button outside of the dialog title using absolute positioning, as MUI does in the example.
IMO we shouldn't add to many custom props/components for things which can be implemented easily without custom styling. But you could argue that the positioning is often done incorrectly 🤔 |
right: 20px; | ||
`); | ||
|
||
const TitleWrapper = createComponentSlot("div")<DialogClassKey>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't the styles of TitleWrapper
just be part of DialogTitle
directly? 🤔
Description
Create option to add an onClose callback with a close Button by creating a custom Dialog to replace MUI Dialogs
Example
Screenshots/screencasts
Changeset
Related tasks and documents
https://vivid-planet.atlassian.net/browse/COM-1045