From 9791b341be66970410121a38d47220343abd9d69 Mon Sep 17 00:00:00 2001 From: Peter Zimon Date: Thu, 25 May 2023 12:26:16 +0200 Subject: [PATCH] Added static user detail popup in AdminX Settings refs. https://github.com/TryGhost/Team/issues/3150 --- .../src/admin-x-ds/global/Button.tsx | 5 +- .../src/admin-x-ds/global/Heading.tsx | 5 +- .../src/admin-x-ds/global/ListItem.tsx | 2 +- .../src/admin-x-ds/global/Modal.tsx | 21 +- .../src/admin-x-ds/global/Radio.tsx | 6 +- .../src/admin-x-ds/global/Toggle.tsx | 2 +- .../settings/SettingGroup.stories.tsx | 8 + .../src/admin-x-ds/settings/SettingGroup.tsx | 44 ++-- .../settings/SettingGroupContent.tsx | 2 +- .../src/admin-x-ds/settings/SettingValue.tsx | 2 +- .../src/components/modals/UserDetailModal.tsx | 20 -- .../src/components/settings/general/Users.tsx | 4 +- .../general}/modals/InviteUserModal.tsx | 2 +- .../general/modals/UserDetailModal.tsx | 227 ++++++++++++++++++ .../settings/membership/Analytics.tsx | 9 +- 15 files changed, 297 insertions(+), 62 deletions(-) delete mode 100644 ghost/admin-x-settings/src/components/modals/UserDetailModal.tsx rename ghost/admin-x-settings/src/components/{ => settings/general}/modals/InviteUserModal.tsx (88%) create mode 100644 ghost/admin-x-settings/src/components/settings/general/modals/UserDetailModal.tsx diff --git a/ghost/admin-x-settings/src/admin-x-ds/global/Button.tsx b/ghost/admin-x-settings/src/admin-x-ds/global/Button.tsx index 4cef5253d8..e86641a6df 100644 --- a/ghost/admin-x-settings/src/admin-x-ds/global/Button.tsx +++ b/ghost/admin-x-settings/src/admin-x-ds/global/Button.tsx @@ -1,6 +1,6 @@ import React from 'react'; -export type ButtonColor = 'clear' | 'black' | 'green' | 'red'; +export type ButtonColor = 'clear' | 'grey' | 'black' | 'green' | 'red'; export interface IButton { label: string; @@ -35,6 +35,9 @@ const Button: React.FC = ({ case 'black': styles += link ? ' text-black hover:text-grey-800' : ' bg-black text-white hover:bg-grey-900'; break; + case 'grey': + styles += link ? ' text-black hover:text-grey-800' : ' bg-grey-100 text-black hover:!bg-grey-300'; + break; case 'green': styles += link ? ' text-green hover:text-green-400' : ' bg-green text-white hover:bg-green-400'; break; diff --git a/ghost/admin-x-settings/src/admin-x-ds/global/Heading.tsx b/ghost/admin-x-settings/src/admin-x-ds/global/Heading.tsx index d5b2d5ba6b..5d712a516a 100644 --- a/ghost/admin-x-settings/src/admin-x-ds/global/Heading.tsx +++ b/ghost/admin-x-settings/src/admin-x-ds/global/Heading.tsx @@ -6,6 +6,7 @@ type THeadingLevels = 1 | 2 | 3 | 4 | 5 | 6; interface IHeading { level?: THeadingLevels; children?: React.ReactNode; + styles?: string; /** * Only available for Heading 6 @@ -19,13 +20,13 @@ interface IHeading { useLabelTag?: boolean; } -const Heading: React.FC = ({level, children, grey, separator, useLabelTag, ...props}) => { +const Heading: React.FC = ({level, children, styles, grey, separator, useLabelTag, ...props}) => { if (!level) { level = 1; } const newElement = `${useLabelTag ? 'label' : `h${level}`}`; - let styles = (level === 6 || useLabelTag) ? (`block text-2xs font-semibold uppercase tracking-wide ${(grey && 'text-grey-700')}`) : ''; + styles += (level === 6 || useLabelTag) ? (` block text-2xs font-semibold uppercase tracking-wide ${(grey && 'text-grey-700')}`) : ' '; const Element = React.createElement(newElement, {className: styles, ...props}, children); diff --git a/ghost/admin-x-settings/src/admin-x-ds/global/ListItem.tsx b/ghost/admin-x-settings/src/admin-x-ds/global/ListItem.tsx index e0140a8b5b..c9969adcc5 100644 --- a/ghost/admin-x-settings/src/admin-x-ds/global/ListItem.tsx +++ b/ghost/admin-x-settings/src/admin-x-ds/global/ListItem.tsx @@ -28,7 +28,7 @@ const ListItem: React.FC = ({id, title, detail, action, hideActio {detail && {detail}} {action && -
+
{action}
} diff --git a/ghost/admin-x-settings/src/admin-x-ds/global/Modal.tsx b/ghost/admin-x-settings/src/admin-x-ds/global/Modal.tsx index d7de9fa17f..eed2367771 100644 --- a/ghost/admin-x-settings/src/admin-x-ds/global/Modal.tsx +++ b/ghost/admin-x-settings/src/admin-x-ds/global/Modal.tsx @@ -10,6 +10,7 @@ export interface ModalProps { size?: ModalSize; title?: string; okLabel?: string; + okColor?: string; cancelLabel?: string; leftButtonLabel?: string; customFooter?: React.ReactNode; @@ -18,7 +19,7 @@ export interface ModalProps { children?: React.ReactNode; } -const Modal: React.FC = ({size = 'md', title, okLabel, cancelLabel, customFooter, leftButtonLabel, onOk, onCancel, children}) => { +const Modal: React.FC = ({size = 'md', title, okLabel, cancelLabel, customFooter, leftButtonLabel, onOk, okColor, onCancel, children}) => { const modal = useModal(); let buttons: IButton[] = []; @@ -35,40 +36,40 @@ const Modal: React.FC = ({size = 'md', title, okLabel, cancelLabel, buttons.push({ key: 'ok-modal', label: okLabel ? okLabel : 'OK', - color: 'black', + color: okColor ? okColor : 'black', styles: 'min-w-[80px]', onClick: onOk }); } - let modalStyles = 'relative z-50 mx-auto flex flex-col justify-between bg-white p-8 shadow-xl w-full'; + let modalStyles = 'relative z-50 mx-auto flex flex-col justify-between bg-white shadow-xl w-full'; let backdropStyles = 'fixed inset-0 h-[100vh] w-[100vw] overflow-y-scroll '; switch (size) { case 'sm': - modalStyles += ' max-w-[480px]'; + modalStyles += ' max-w-[480px] p-8'; break; case 'md': - modalStyles += ' max-w-[720px]'; + modalStyles += ' max-w-[720px] p-8'; break; case 'lg': - modalStyles += ' max-w-[940px]'; + modalStyles += ' max-w-[940px] p-10'; break; case 'xl': - modalStyles += ' max-w-[1180px] '; + modalStyles += ' max-w-[1180px] p-12'; break; case 'full': case 'bleed': - modalStyles += ' h-full'; + modalStyles += ' h-full p-12'; break; } if (size !== 'bleed') { - modalStyles += ' rounded'; + modalStyles += ' rounded-md overflow-hidden'; } if (size !== 'bleed' && size !== 'full') { @@ -83,7 +84,7 @@ const Modal: React.FC = ({size = 'md', title, okLabel, cancelLabel, return (