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

encapsulate hub head block #43

Merged
merged 26 commits into from
Oct 4, 2024
Merged

encapsulate hub head block #43

merged 26 commits into from
Oct 4, 2024

Conversation

rccsousa
Copy link
Collaborator

@rccsousa rccsousa commented Oct 3, 2024

Why:

  • hub hero/head block was not encapsulating, leading to cluttered code on the hub page main file
    How:
  • this PR encapsulates Hub Head onto a standalone component;
  • also added minor changes and fixes to other components (styling and props for finer control when using on other components/blocks);

- addded font-size variables;
- added new typeface variables;
- move the "CSS Reset" outside of root, which was breaking elements such
  as the header navbar;
- created general fetcher utility;
- added graphQL query to fetch all content;
- minor changes to css globals;
- rename variables for consistency,
- improved typing,
- repurpose Settings collection to define highlights;
- update graphQL queries to reflect changes;
- style ContentPilland AuthorPill components;
- fix icons svg fields to be compliant with React;
- moved content nav bar together with content grid;
- css styling fixes and changes;
@rccsousa rccsousa marked this pull request as ready for review October 3, 2024 10:55
<h6> {title} </h6>
<div className={styles.metadataContainer}>
{/* TODO: is this a good approach for multi category items? */}
{categories.length > 1 ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make sense? Why not just always do the map?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sort of a band-aid solution to tackle this problem on smaller screens:
imagem

maybe reduce the gap if there categories > 1?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, either reduce the gap, or limit to n categories, or split into 2 rows on smaller screens, it depends 😂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, sounds like a plan! i'll add it to the issue list

<ArchiveButton collection={archiveMap[contentType]} />
<h6>{title}</h6>
<p>{summary}</p>

{Array.isArray(categories) && categories.length > 0
Copy link
Contributor

@davelange davelange Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was confused by this, then I checked the generated type definition for Blogpost:
Screenshot 2024-10-03 at 13 52 37
This is a very unhelpful type, and I've no ideia why payload generates it like that 🤷

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, it's giving me some headaches as TS is going crazy about that. could we enforce just (for example) Category[] and remove the string part?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the ideal. the problem is that this is generated by payload from the collection configs, and they look fine to me. I might look into this later

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will leave it as is for now

<div
className={styles.contentGridContainer}
style={{
borderColor: windowWidth >= 1024 ? colorMap[activeButton] : 'var(--dark-rock-800)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be better done in pure CSS, with media queries

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this be a case for clsx?
change class based on active button just for desktop?

@@ -25,6 +26,12 @@ export default function HubContentGrid({ articles }: HubContentGridProps) {

const [activeButton, setActiveButton] = useState<keyof ContentTypeArrays | 'All'>('All')

let windowWidth = window.innerWidth

window.addEventListener('resize', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary (because of the other comment about media queries), but anyway, event listeners in React need some extra care because they need to be cleaned up when the component unmounts. The best practice looks like this: https://www.pluralsight.com/resources/blog/guides/event-listeners-in-react-components

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. i'll update it and shift to using pure css

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in: f4f6c9e

@rccsousa rccsousa changed the title Rs/encapsulate hub head block encapsulate hub head block Oct 3, 2024
@rccsousa rccsousa merged commit 76c6b79 into main Oct 4, 2024
1 check passed
@rccsousa rccsousa deleted the rs/encapsulate-hub-head-block branch October 4, 2024 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants