diff --git a/apps/admin-x-settings/src/admin-x-ds/global/Button.tsx b/apps/admin-x-settings/src/admin-x-ds/global/Button.tsx index 3540ac0213..3ffe39e57f 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/Button.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/Button.tsx @@ -16,6 +16,7 @@ export interface ButtonProps { link?: boolean; disabled?: boolean; className?: string; + tag?: string; onClick?: () => void; } @@ -29,8 +30,9 @@ const Button: React.FC = ({ fullWidth, link, disabled, - onClick, className = '', + tag = 'button', + onClick, ...props }) => { if (!color) { @@ -68,18 +70,17 @@ const Button: React.FC = ({ styles += (disabled) ? ' opacity-40' : ' cursor-pointer'; styles += ` ${className}`; - return ( - - ); + const buttonChildren = <> + {icon && } + {(label && hideLabel) ? {label} : label} + ; + const buttonElement = React.createElement(tag, {className: styles, + disabled: disabled, + type: 'button', + onClick: onClick, + ...props}, buttonChildren); + + return buttonElement; }; export default Button; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/form/ImageUpload.tsx b/apps/admin-x-settings/src/admin-x-ds/global/form/ImageUpload.tsx index 6dcb368f93..fc72c4a6ee 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/form/ImageUpload.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/form/ImageUpload.tsx @@ -119,7 +119,7 @@ const ImageUpload: React.FC = ({ height: (unstyled ? '' : height) } } unstyled={unstyled} onUpload={onUpload}> - {children} + {children} ); } diff --git a/apps/admin-x-settings/src/admin-x-ds/global/modal/Modal.tsx b/apps/admin-x-settings/src/admin-x-ds/global/modal/Modal.tsx index 1c17502c6e..54ebf9bc0e 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/modal/Modal.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/modal/Modal.tsx @@ -133,7 +133,7 @@ const Modal: React.FC = ({ case 'full': modalClasses += ' h-full '; - backdropClasses += ' p-[2vmin]'; + backdropClasses += ' p-[3vmin]'; padding = 'p-10'; break; @@ -206,7 +206,7 @@ const Modal: React.FC = ({
- Publication cover + Publication cover { const [isExpanded, setExpanded] = useState(false); return setExpanded(!isExpanded)} />} - detail={ - isExpanded ? - <> -
- Affected files: -
    - {problem.failures.map(failure =>
  • {failure.ref}{failure.message ? `: ${failure.message}` : ''}
  • )} -
- : - null + title={ + <> +
+ {problem.level === 'error' ? 'Error: ' : 'Warning: '} + +
+
+
+ { + isExpanded ? +
+
+ Affected files: +
    + {problem.failures.map(failure =>
  • {failure.ref}{failure.message ? `: ${failure.message}` : ''}
  • )} +
+
: + null + } + } - title={<> - {problem.level === 'error' ? 'Error: ' : 'Warning: '} - - } hideActions separator />; @@ -39,7 +45,8 @@ const ThemeInstalledModal: React.FC<{ prompt: ReactNode installedTheme: InstalledTheme; setThemes: (callback: (themes: Theme[]) => Theme[]) => void; -}> = ({title, prompt, installedTheme, setThemes}) => { + onActivate?: () => void; +}> = ({title, prompt, installedTheme, setThemes, onActivate}) => { const api = useApi(); let errorPrompt = null; @@ -53,7 +60,7 @@ const ThemeInstalledModal: React.FC<{ let warningPrompt = null; if (installedTheme.warnings) { - warningPrompt =
+ warningPrompt =
{installedTheme.warnings?.map(warning => )} @@ -101,6 +108,7 @@ const ThemeInstalledModal: React.FC<{ message: `${updatedTheme.name} is now your active theme.` }); } + onActivate?.(); activateModal?.remove(); }} />; diff --git a/apps/admin-x-settings/src/components/settings/site/theme/ThemePreview.tsx b/apps/admin-x-settings/src/components/settings/site/theme/ThemePreview.tsx index 7d42d0d5ce..019e23ba86 100644 --- a/apps/admin-x-settings/src/components/settings/site/theme/ThemePreview.tsx +++ b/apps/admin-x-settings/src/components/settings/site/theme/ThemePreview.tsx @@ -11,17 +11,19 @@ import {Theme} from '../../../../types/api'; const ThemePreview: React.FC<{ selectedTheme?: OfficialTheme; - onBack: () => void; isInstalling?: boolean; installedTheme?: Theme; installButtonLabel?: string; + onBack: () => void; + onClose: () => void; onInstall?: () => void | Promise; }> = ({ selectedTheme, - onBack, isInstalling, installedTheme, installButtonLabel, + onBack, + onClose, onInstall }) => { const [previewMode, setPreviewMode] = useState('desktop'); @@ -57,7 +59,8 @@ const ThemePreview: React.FC<{
{ const searchBar = page.getByLabel('Search'); - await searchBar.fill('theme'); + await searchBar.fill('design'); - await expect(page.getByTestId('theme')).toBeVisible(); + await expect(page.getByTestId('design')).toBeVisible(); await expect(page.getByTestId('title-and-description')).not.toBeVisible(); await searchBar.fill('title'); - await expect(page.getByTestId('theme')).not.toBeVisible(); + await expect(page.getByTestId('design')).not.toBeVisible(); await expect(page.getByTestId('title-and-description')).toBeVisible(); }); }); diff --git a/apps/admin-x-settings/test/e2e/site/theme.test.ts b/apps/admin-x-settings/test/e2e/site/theme.test.ts index aebe601b81..74bf88d11b 100644 --- a/apps/admin-x-settings/test/e2e/site/theme.test.ts +++ b/apps/admin-x-settings/test/e2e/site/theme.test.ts @@ -26,13 +26,17 @@ test.describe('Theme settings', async () => { await page.goto('/'); - const section = page.getByTestId('theme'); + const designSection = page.getByTestId('design'); - await section.getByRole('button', {name: 'Manage themes'}).click(); + await designSection.getByRole('button', {name: 'Customize'}).click(); + + const designModal = page.getByTestId('design-modal'); + + await designModal.getByTestId('change-theme').click(); const modal = page.getByTestId('theme-modal'); - // The default theme is always considered "installed" + // // The default theme is always considered "installed" await modal.getByRole('button', {name: /Casper/}).click(); @@ -40,7 +44,7 @@ test.describe('Theme settings', async () => { await expect(page.locator('iframe[title="Theme preview"]')).toHaveAttribute('src', 'https://demo.ghost.io/'); - await modal.getByRole('button', {name: 'Official themes'}).click(); + await modal.getByRole('button', {name: 'Change theme'}).click(); // Try installing another theme @@ -71,9 +75,13 @@ test.describe('Theme settings', async () => { await page.goto('/'); - const section = page.getByTestId('theme'); + const designSection = page.getByTestId('design'); - await section.getByRole('button', {name: 'Manage themes'}).click(); + await designSection.getByRole('button', {name: 'Customize'}).click(); + + const designModal = page.getByTestId('design-modal'); + + await designModal.getByTestId('change-theme').click(); const modal = page.getByTestId('theme-modal');