Skip to content

Commit

Permalink
Merge pull request #73 from mbwatson/update/news-ui-tweaks
Browse files Browse the repository at this point in the history
Update/news UI tweaks
  • Loading branch information
Woozl authored Dec 5, 2023
2 parents be01540 + 6c87904 commit 8953b72
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
2 changes: 1 addition & 1 deletion components/layout/section/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const Section = ({ title, children }) => {
)
}
</Box>
<Box sx={{ flex: '1' , wordWrap: 'break-word'}} >
<Box sx={{ flex: '1' , wordWrap: 'break-word', minWidth: 0 }} >
{ children }
</Box>
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion components/news/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const TYPES = {
},
default: {
bgColor: "#ededed",
color: "#414141",
color: "#474747",
},
};

Expand Down
51 changes: 34 additions & 17 deletions pages/news/[year]/[month]/[day]/[slug].js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { Fragment } from "react"
import { Page, Section } from "@/components/layout";
import { fetchArticle, fetchStrapiGraphQL } from "@/lib/strapi";
import { Divider, Typography, Box, Stack } from "@mui/material";
import { Divider, Typography, Stack, styled } from "@mui/material";
import { Markdown } from "@/components/markdown";
import Image from "next/image";
import { ArticleDate } from "@/components/news/article-date"
import { Tag } from "@/components/news/tag"
import qs from "qs";
import { Link } from "@/components/link"
import { useRouter } from "next/router";

export default function Article({ article }) {
const router = useRouter();

const tags = [
article.projects.map((x) => ({ ...x, type: 'projects' })),
Expand Down Expand Up @@ -60,13 +62,13 @@ export default function Article({ article }) {
const id = type === 'postTags' ? name : slug;

return (
<Link key={i} to={createTagLinkURL(id, type)}>
<Tag
type={type}
contents={name}
sx={{ minWidth: 'fit-content', maxWidth: 'revert' }}
/>
</Link>
<Tag
key={i}
type={type}
contents={name}
onClick={() => { router.push(createTagLinkURL(id, type)); }}
sx={{ maxWidth: 'revert', cursor: 'pointer' }}
/>
)
})}
</Stack>
Expand All @@ -78,15 +80,18 @@ export default function Article({ article }) {
{
article.content.map((item)=> {
return item.__typename == "ComponentPostSectionsImage" ? (
<Image
priority
src={item.image.data.attributes.url}
alt={item.altText}
width= {item.image.data.attributes.width}
height={item.image.data.attributes.height}
layout="responsive"
objectFit='cover'
/>
<Figure>
<Image
priority
src={item.image.data.attributes.url}
alt={item.altText}
width= {item.image.data.attributes.width}
height={item.image.data.attributes.height}
layout="responsive"
objectFit='cover'
/>
<Typography component={"figcaption"} variant="caption">{item.caption}</Typography>
</Figure>
) : (
<Markdown>{item.content}</Markdown>
)
Expand Down Expand Up @@ -157,6 +162,18 @@ export default function Article({ article }) {
)
}

const Figure = styled('figure')`
margin: 1rem 0;
display: flex;
flex-direction: column;
gap: 8px;
& figcaption.MuiTypography-root {
align-self: center;
font-style: italic;
}
`;

export async function getStaticPaths() {
const postsGql = await fetchStrapiGraphQL(`query {
posts(pagination: { limit: 1000 }, sort: "publishDate:desc") {
Expand Down
2 changes: 1 addition & 1 deletion pages/news/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default function News() {
const isTagSelected = useCallback((id, type) => {
if (id === undefined || type === undefined) return false;
return selectedTags[type]?.find((tag) => (
tag[type === 'freeSearch' ? 'name' : 'slug'] === id
tag[type === 'freeSearch' || type === 'postTags' ? 'name' : 'slug'] === id
)) !== undefined;
}, [selectedTags]);

Expand Down

0 comments on commit 8953b72

Please sign in to comment.