diff --git a/ghost/admin-x-settings/src/admin-x-ds/global/MobileChrome.stories.tsx b/ghost/admin-x-settings/src/admin-x-ds/global/MobileChrome.stories.tsx new file mode 100644 index 0000000000..951324adc0 --- /dev/null +++ b/ghost/admin-x-settings/src/admin-x-ds/global/MobileChrome.stories.tsx @@ -0,0 +1,27 @@ +import type {Meta, StoryObj} from '@storybook/react'; + +import MobileChrome from './MobileChrome'; + +const meta = { + title: 'Global / Chrome / Mobile Chrome', + component: MobileChrome, + tags: ['autodocs'], + decorators: [(_story: any) => (
{_story()}
)] +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: { + children: ( +
+

This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text.

+ + Testimage + +

This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text. This is a mobile chrome with lots of text.

+
+ ) + } +}; diff --git a/ghost/admin-x-settings/src/admin-x-ds/global/MobileChrome.tsx b/ghost/admin-x-settings/src/admin-x-ds/global/MobileChrome.tsx new file mode 100644 index 0000000000..1687f4c815 --- /dev/null +++ b/ghost/admin-x-settings/src/admin-x-ds/global/MobileChrome.tsx @@ -0,0 +1,17 @@ +import React from 'react'; + +interface MobileChromeProps { + children?: React.ReactNode; +} + +const MobileChrome: React.FC = ({children}) => { + return ( +
+
+ {children} +
+
+ ); +}; + +export default MobileChrome; \ No newline at end of file diff --git a/ghost/admin-x-settings/src/admin-x-ds/global/PreviewModal.tsx b/ghost/admin-x-settings/src/admin-x-ds/global/PreviewModal.tsx index 3475a42c50..044da4e84c 100644 --- a/ghost/admin-x-settings/src/admin-x-ds/global/PreviewModal.tsx +++ b/ghost/admin-x-settings/src/admin-x-ds/global/PreviewModal.tsx @@ -1,9 +1,10 @@ import ButtonGroup from './ButtonGroup'; import DesktopChromeHeader from './DesktopChromeHeader'; import Heading from './Heading'; +import MobileChrome from './MobileChrome'; import Modal from './Modal'; import NiceModal, {useModal} from '@ebay/nice-modal-react'; -import React from 'react'; +import React, {useState} from 'react'; import URLSelect from './URLSelect'; import {IButton} from './Button'; import {SelectOption} from './Select'; @@ -52,6 +53,16 @@ export const PreviewModalContent: React.FC = ({ const modal = useModal(); let buttons: IButton[] = []; + const [view, setView] = useState('desktop'); + + if (view === 'mobile') { + preview = ( + + {preview} + + ); + } + if (previewToolbar) { let toolbarCenter = (<>); if (previewToolbarURLs) { @@ -60,6 +71,7 @@ export const PreviewModalContent: React.FC = ({ ); } + const unSelectedIconColorClass = 'text-grey-500'; const toolbarRight = ( = ({ icon: 'laptop', link: true, size: 'sm', - onClick: onSelectDesktopView + iconColorClass: (view === 'desktop' ? 'text-black' : unSelectedIconColorClass), + onClick: onSelectDesktopView || (() => { + setView('desktop'); + }) }, { icon: 'mobile', link: true, size: 'sm', - iconColorClass: 'text-grey-500', - onClick: onSelectMobileView + iconColorClass: (view === 'mobile' ? 'text-black' : unSelectedIconColorClass), + onClick: onSelectMobileView || (() => { + setView('mobile'); + }) } ]} />