diff --git a/app/soapbox/features/soapbox_config/components/site_preview.js b/app/soapbox/features/soapbox_config/components/site-preview.tsx similarity index 64% rename from app/soapbox/features/soapbox_config/components/site_preview.js rename to app/soapbox/features/soapbox_config/components/site-preview.tsx index 3d52d7200..87706f3d8 100644 --- a/app/soapbox/features/soapbox_config/components/site_preview.js +++ b/app/soapbox/features/soapbox_config/components/site-preview.tsx @@ -1,13 +1,19 @@ import classNames from 'classnames'; -import React from 'react'; -import ImmutablePropTypes from 'react-immutable-proptypes'; +import React, { useMemo } from 'react'; import { defaultSettings } from 'soapbox/actions/settings'; +import { normalizeSoapboxConfig } from 'soapbox/normalizers'; import { generateThemeCss } from 'soapbox/utils/theme'; -export default function SitePreview({ soapbox }) { +interface ISitePreview { + /** Raw Soapbox configuration. */ + soapbox: any, +} - const settings = defaultSettings.mergeDeep(soapbox.get('defaultSettings')); +/** Renders a preview of the website's style with the configuration applied. */ +const SitePreview: React.FC = ({ soapbox }) => { + const soapboxConfig = useMemo(() => normalizeSoapboxConfig(soapbox), [soapbox]); + const settings = defaultSettings.mergeDeep(soapboxConfig.defaultSettings); const bodyClass = classNames('site-preview', `theme-mode-${settings.get('themeMode')}`, { 'no-reduce-motion': !settings.get('reduceMotion'), @@ -18,7 +24,7 @@ export default function SitePreview({ soapbox }) { return (
- +
@@ -26,15 +32,15 @@ export default function SitePreview({ soapbox }) {
@@ -49,8 +55,6 @@ export default function SitePreview({ soapbox }) {
); -} - -SitePreview.propTypes = { - soapbox: ImmutablePropTypes.record.isRequired, }; + +export default SitePreview; diff --git a/app/soapbox/features/soapbox_config/index.js b/app/soapbox/features/soapbox_config/index.js index b6fe7f17f..da108e92d 100644 --- a/app/soapbox/features/soapbox_config/index.js +++ b/app/soapbox/features/soapbox_config/index.js @@ -27,7 +27,7 @@ import Accordion from '../ui/components/accordion'; import ColorWithPicker from './components/color-with-picker'; import IconPicker from './components/icon-picker'; -import SitePreview from './components/site_preview'; +import SitePreview from './components/site-preview'; const messages = defineMessages({ heading: { id: 'column.soapbox_config', defaultMessage: 'Soapbox config' }, diff --git a/app/soapbox/normalizers/soapbox/soapbox_config.ts b/app/soapbox/normalizers/soapbox/soapbox_config.ts index e37a4faad..07fd5aff3 100644 --- a/app/soapbox/normalizers/soapbox/soapbox_config.ts +++ b/app/soapbox/normalizers/soapbox/soapbox_config.ts @@ -89,7 +89,7 @@ export const SoapboxConfigRecord = ImmutableRecord({ colors: ImmutableMap(), copyright: `♥${new Date().getFullYear()}. Copying is an act of love. Please copy and share.`, customCss: ImmutableList(), - defaultSettings: ImmutableMap(), + defaultSettings: ImmutableMap(), extensions: ImmutableMap(), greentext: false, promoPanel: PromoPanelRecord(),