diff --git a/src/cms/cms.js b/src/cms/cms.js index aedded28..c56b3946 100644 --- a/src/cms/cms.js +++ b/src/cms/cms.js @@ -20,7 +20,7 @@ CMS.registerWidget("url-image", UrlImageControl, UrlImagePreview); CMS.registerPreviewTemplate("index", IndexPagePreview); CMS.registerPreviewTemplate("about", AboutPagePreview); -CMS.registerPreviewTemplate("idea", IdeaPostPreview); +CMS.registerPreviewTemplate("ideas", IdeaPostPreview); // Decap exposes a number of lifecycle stages we can hook into and register. CMS.registerEventListener({ diff --git a/src/cms/preview-templates/IdeaPostPreview.js b/src/cms/preview-templates/IdeaPostPreview.js deleted file mode 100644 index d3d35171..00000000 --- a/src/cms/preview-templates/IdeaPostPreview.js +++ /dev/null @@ -1,26 +0,0 @@ -import React from "react"; - -import PropTypes from "prop-types"; - -import { IdeaPostTemplate } from "../../templates/idea-post"; - -const IdeaPostPreview = ({ entry, widgetFor }) => { - const tags = entry.getIn(["data", "tags"]); - return ( - - ); -}; - -IdeaPostPreview.propTypes = { - entry: PropTypes.shape({ - getIn: PropTypes.func, - }), - widgetFor: PropTypes.func, -}; - -export default IdeaPostPreview; diff --git a/src/cms/preview-templates/IdeaPostPreview.tsx b/src/cms/preview-templates/IdeaPostPreview.tsx new file mode 100644 index 00000000..56eba3f7 --- /dev/null +++ b/src/cms/preview-templates/IdeaPostPreview.tsx @@ -0,0 +1,77 @@ +import React from "react"; + +import { IdeaPostTemplate } from "../../templates/idea-post"; +import { IdeaPostNode } from "../../types"; +import { ImmutableLike, fromImmutable } from "../utils/immutable"; + +interface PreviewProps { + entry?: ImmutableLike; +} + +const previewBannerStyle: React.CSSProperties = { + padding: "8px 12px", + marginBottom: "12px", + backgroundColor: "#fff8e1", + border: "1px solid #ffe082", + borderRadius: "4px", + fontSize: "16px", + color: "#6d4c00", +}; + +const placeholderStyle: React.CSSProperties = { + border: "1.5px dashed #ffe082", + borderRadius: "4px", + padding: "16px 20px", + backgroundColor: "#fffdf5", + color: "#6d4c00", + fontSize: "14px", + lineHeight: 1.6, +}; + +const ResourcePlaceholder: React.FC = () => ( +
+
+

+ Resource details are loaded from related entries at build time + and cannot be previewed here. The published page will display + full resource cards with descriptions and links. +

+
+
+); + +const IdeaPostPreview: React.FC = ({ entry }) => { + const raw = entry?.get("data"); + const data = fromImmutable(raw) ?? ({} as IdeaPostNode); + + return ( +
+
+ Preview approximation — because of the way this site it built, + it's hard to preview the entire context of the way the idea will + sit in the layout, and we can't access relational data (like the + relevant resources). So this preview is an overal look of the + initial proposal, title, etc. +
+ +
+ +
+
+ ); +}; + +export default IdeaPostPreview; diff --git a/src/components/ExpandableDescriptionView.tsx b/src/components/ExpandableDescriptionView.tsx index 6ce4bb7b..7b1b7078 100644 --- a/src/components/ExpandableDescriptionView.tsx +++ b/src/components/ExpandableDescriptionView.tsx @@ -3,15 +3,9 @@ import React from "react"; import { ArrowLeftOutlined } from "@ant-design/icons"; import { Button } from "antd"; +import "../style/idea-post.css"; import { CustomReactMarkdown } from "./CustomReactMarkdown"; -const { - backBar, - container, - mainTitle, - sectionText, -} = require("../style/idea-post.module.css"); - interface ExpandedDescriptionViewProps { content: string; label: string; @@ -27,14 +21,17 @@ interface ExpandedDescriptionViewProps { export const ExpandedDescriptionView: React.FC< ExpandedDescriptionViewProps > = ({ content, label, onBack }) => ( -
-
+
+
-

{label}

- +

{label}

+
); diff --git a/src/components/ExpandableText.tsx b/src/components/ExpandableText.tsx index 2cd7c453..e5a64971 100644 --- a/src/components/ExpandableText.tsx +++ b/src/components/ExpandableText.tsx @@ -3,11 +3,10 @@ import React from "react"; import { Button } from "antd"; import { MAX_RESOURCE_DESCRIPTION_LENGTH } from "../constants"; +import "../style/idea-post.css"; import { truncateAtWord } from "../utils/utils"; import { CustomReactMarkdown } from "./CustomReactMarkdown"; -const { sectionText } = require("../style/idea-post.module.css"); - interface ExpandableTextProps { fullText?: string | null; onExpand?: () => void; @@ -30,7 +29,10 @@ export const ExpandableText: React.FC = ({ // shortText only — show as-is if (shortText && !fullText) { return ( - + ); } @@ -41,7 +43,7 @@ export const ExpandableText: React.FC = ({ return ( <> = ({ // Both — show shortText, "See more" opens full-page view return ( <> - + {fullText && onExpand && (