Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@/CivicSignal: Fix previews on research blog content #983

Merged
merged 20 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ec0a0c4
chore: Fix crash due to RichText with missing TypographyProps
m453h Oct 28, 2024
db36e09
chore: Update Typography props for PageHeader and FooterDescription
m453h Oct 28, 2024
2de0750
fix: Handle undefined values for current and default apps for first t…
m453h Oct 28, 2024
5ce5896
fix: Add missing options for fetching draft page content to enable pr…
m453h Oct 29, 2024
ae48c2b
fix: Add preview for posts
m453h Oct 30, 2024
5a48635
chore: Update pageheader snapshot
m453h Oct 31, 2024
de4677d
chore: Remove defaultProps in Pages and Navbar compoments
m453h Nov 1, 2024
b2673e7
fix: Improve post tags and filter form UI
m453h Nov 11, 2024
67916fd
fix: Fix preview crashing due to missing image
m453h Nov 12, 2024
87ff9d8
feat: Implement temporary solution for rendering Article Component on…
m453h Nov 13, 2024
5c09e73
Merge branch 'main' into fix/civicsignal_live_previews
m453h Nov 13, 2024
63f30c3
chore: Update Article and ArticleGrid snapshots
m453h Nov 13, 2024
3767350
Merge branch 'fix/civicsignal_live_previews' of github.com:CodeForAfr…
m453h Nov 13, 2024
d03d2b8
chore: Revert to original live-preview implementation
m453h Nov 14, 2024
9738693
Merge branch 'main' into fix/civicsignal_live_previews
m453h Nov 14, 2024
5853a56
chore: Remove unnecessary string conversion in allowedAppSelect value…
m453h Nov 14, 2024
d707cea
chore: Remove wrong props in ArticleGrid
m453h Nov 14, 2024
886ba8a
Merge branch 'fix/civicsignal_live_previews' of github.com:CodeForAfr…
m453h Nov 14, 2024
50d00ed
chore: Fix formatting issues
m453h Nov 14, 2024
68747d9
Merge branch 'main' into fix/civicsignal_live_previews
m453h Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions apps/civicsignalblog/src/components/ArticleGrid/ArticleGrid.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Section } from "@commons-ui/core";
import { RichTypography } from "@commons-ui/next";
import { Grid } from "@mui/material";
import { Box, Grid } from "@mui/material";
import React from "react";

import ArticleCardList from "@/civicsignalblog/components/ArticleCardList";
Expand All @@ -26,12 +26,10 @@ const ArticleGrid = React.forwardRef(function ArticleGrid(props, ref) {
return (
<Section sx={{ px: { xs: "20px", sm: 0 }, ...sx }} {...other} ref={ref}>
<Grid container sx={{ py: { xs: "28px", md: 8, lg: "105.29px" } }}>
<Grid
item
xs={12}
<Box
sx={{
order: { xs: 0, md: 1 },
display: articles?.length > 0 ? "flex" : "none",
width: "100%",
}}
>
{/* title is below featuredArticle in md and above hence needs margin-top */}
Expand Down Expand Up @@ -59,7 +57,7 @@ const ArticleGrid = React.forwardRef(function ArticleGrid(props, ref) {
mb: { xs: 2.5, md: 5 },
}}
/>
</Grid>
</Box>
{featuredArticle ? (
<Grid
item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`<ArticleGrid /> renders unchanged 1`] = `
class="MuiGrid-root MuiGrid-container css-teoma9-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 css-1rk8ai9-MuiGrid-root"
class="MuiBox-root css-1xugy04"
>
<div
class="MuiStack-root css-kbcct1-MuiStack-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports[`<Articles /> renders unchanged 1`] = `
class="MuiGrid-root MuiGrid-container css-teoma9-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 css-1cj7j73-MuiGrid-root"
class="MuiBox-root css-1xugy04"
>
<div
class="MuiTypography-root MuiTypography-h4 css-7yxv5i-MuiTypography-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const FooterDescription = React.forwardRef(
</Link>
<RichText
variant="footer"
typographyProps={{
TypographyProps={{
LinkProps: {
color: "text.secondary",
sx: { textDecorationColor: "text.secondary" },
Expand Down
48 changes: 25 additions & 23 deletions apps/civicsignalblog/src/components/LongFormMedia/LongFormMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,34 @@ const LongFormMedia = React.forwardRef((props, ref) => {
}}
ref={ref}
>
<Figure
ImageProps={{
alt: image.alt,
sx: {
objectFit: "cover",
position: "relative !important",
},
src: image.src,
}}
sx={{
height: {
xs: "200px",
md: "500px",
},
width: "100%",
}}
>
<figcaption
style={{
{image && (
<Figure
ImageProps={{
alt: image.alt,
sx: {
objectFit: "cover",
position: "relative !important",
},
src: image.src,
}}
sx={{
height: {
xs: "200px",
md: "500px",
},
width: "100%",
margin: "0 auto",
}}
>
{image.alt}
</figcaption>
</Figure>
<figcaption
style={{
width: "100%",
margin: "0 auto",
}}
>
{image.alt}
</figcaption>
</Figure>
)}
</Box>
);
});
Expand Down
4 changes: 0 additions & 4 deletions apps/civicsignalblog/src/components/NavBar/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,4 @@ NavBar.propTypes = {
),
};

NavBar.defaultProps = {
menus: undefined,
};

export default NavBar;
8 changes: 0 additions & 8 deletions apps/civicsignalblog/src/components/Page/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,4 @@ Page.propTypes = {
title: PropTypes.string,
};

Page.defaultProps = {
children: undefined,
navbar: undefined,
blocks: undefined,
footer: undefined,
title: undefined,
};

export default Page;
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const PageHeader = React.forwardRef(function PageHeader(props, ref) {
{title}
</RichTypography>
<RichText
typographyProps={{
TypographyProps={{
fontWeight: "normal",
variant: "h2",
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ exports[`<PageHeader /> renders unchanged 1`] = `
</h2>
<div
class="MuiBox-root css-0"
typographyprops="[object Object]"
>
<p
class="MuiTypography-root MuiTypography-body1 css-oo170e-MuiTypography-root"
<h2
class="MuiTypography-root MuiTypography-h2 css-hd3436-MuiTypography-root"
>
Let's
<strong>
Expand All @@ -28,7 +27,7 @@ exports[`<PageHeader /> renders unchanged 1`] = `
<strong>
together
</strong>
</p>
</h2>
</div>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions apps/civicsignalblog/src/lib/data/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,13 @@ function getDefaultErrorPageProps(slug = "404") {
}

export async function getPageProps(api, context) {
const { params } = context;
const { params, draftMode = false } = context;
const options = { draft: draftMode };

const slug = getPageSlug(context);
let {
docs: [page],
} = await api.findPage(slug);
} = await api.findPage(slug, options);
if (!page) {
if (["404", "500"].includes(slug)) {
return getDefaultErrorPageProps(slug);
Expand Down
5 changes: 3 additions & 2 deletions apps/civicsignalblog/src/lib/data/pagify/post.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { getPost } from "@/civicsignalblog/lib/data/utils/posts";

async function post(api, context) {
const { params } = context;
const { params, draftMode = false } = context;
const options = { draft: draftMode };
const page = params.slugs[1];
const slug = params.slugs[2];
return getPost(api, slug, page);
return getPost(api, slug, page, options);
}

export default post;
3 changes: 2 additions & 1 deletion apps/civicsignalblog/src/lib/data/utils/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ export async function getPosts(api, params, primaryTag) {
};
}

export async function getPost(api, slug, primaryTag) {
export async function getPost(api, slug, primaryTag, options) {
const { docs } = await api.getCollection("posts", {
...options,
where: {
slug: {
equals: slug,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default async function canAccessApplication(req, searchString) {
if (user) {
const app = headers["CS-App"] || user.currentApp || user.defaultApp;
return (
app.toLowerCase() === searchString.toLowerCase() &&
app?.toLowerCase() === searchString.toLowerCase() &&
m453h marked this conversation as resolved.
Show resolved Hide resolved
user.allowedApps.includes(app)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import applications from "#civicsignalblog/payload/lib/data/common/applications"

function CustomSelectComponent({ path, label }) {
const { user } = useAuth();
const { value, setValue } = useField({ path });
const { value, setValue } = useField<string>({ path });
const [options, setOptions] = useState([]);

useEffect(() => {
Expand All @@ -32,7 +32,7 @@ function CustomSelectComponent({ path, label }) {
path={path}
name={path}
options={options}
value={String(value)}
value={value}
onChange={(e) => setValue(e.value)}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/commons-ui-payload/src/RichText/RichText.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const serialize = (children, props) =>
if (!node) {
return null;
}
const TypographyProps = { ...DEFAULT_PROPS, ...props.TypographyProps };
const TypographyProps = { ...DEFAULT_PROPS, ...props?.TypographyProps };
switch (node.type) {
case "h1":
return (
Expand Down
Loading