Skip to content

Image overlap custom hook#187

Open
dalecreativ wants to merge 54 commits intomainfrom
image-overlap-custom-hook
Open

Image overlap custom hook#187
dalecreativ wants to merge 54 commits intomainfrom
image-overlap-custom-hook

Conversation

@dalecreativ
Copy link
Contributor

@dalecreativ dalecreativ commented Feb 29, 2024

Use custom hook to handle news and blog featured image offset.

Created a custom hook so we can reuse the logic for image overlap on News and Blog pages. Should make it easier to update logic in one place

  • Replace window resize with a resizeObserver which reduces number of events being fired and focuses on the element we are tracking over the whole window. https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver
  • We now set state for the margin-top of the image and padding-bottom of the PageHeader. This replaces the need for a CSS custom property but also introduces state to the news and blog pages.
  • Removes the need to add a forwardRef on the DS PageHeader as we can handle values needed via state and pass those values to the style attribute of each component.

barkertron and others added 30 commits August 16, 2023 10:15
* NXT-180 Add basic routing; refactor fonts

* NXT-180 Add basic Storyblok integration

* NXT-180 Display SB data on home and about pages

* NXT-180 Fix TS issues, abstract Storyblok connection

---------

Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
* NXT-181 Card grid homepage WIP

* NXT-181 Fix TS errors

* NXT-181 Add card component from NDS

* NXT-181 TS integration for cards and homepage

* NXT-181 Resolve Storyblok link objects

* NXT-181 Fix links when SB returns empty link objects

* NXT-181 Alter card grid layout, fix failing tests

* NXT-181 Remove logging

---------

Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
* NXT-185 Add hero and catnav components

* NXT-185 Add SSL proxy for Storyblok preview mode

* NXT-185 Resolve draft versions from context

* NXT-185 Refactor page fetching, add catch-all about route

* NXT-185 Breadcrumbs WIP

---------

Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
* NXT-188 Fix failing tests

* NXT-188 Add metadata from Storyblok, update user-generated metadata

* NXT-188 Add canonical and language link/meta tags

---------

Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
* NXT-172 Add API endpoint for deleting fs cache entries (#122)

* NXT-155 Change alert functionality to read from InDev

* NXT-155 Updated snapshot test

* NXT-155 Added alert logic to docs/consultation tabs for project page

* NXT-155 Add API endpoint for deleting fs cache entries

* NXT-155 Prevent cacheing of API cache deletion response

* NXT-155 possible caching fixes (#134)

* NXT-155 possible caching fixes

* NXT-155 stop it generating multiple cache entries in different cases

* NXT-155 move lowercase fixes to getCacheKey function

* NXT-155 Lint cache api; send group keys in 400 err

* NXT-155 fix tests

---------

Co-authored-by: John Holland <john.holland@nice.org.uk>
Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
Co-authored-by: Claire Hunter <claire.hunter@nice.org.uk>

* NXT-178 Add international enquiry form and test (#132)

* NXT-190 embedded doesnt exist for hub pages (#138)

* NXT-186 Static paths WIP

* NXT-186 Update linting rules

---------

Co-authored-by: John Holland <john.holland@nice.org.uk>
Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
Co-authored-by: Claire Hunter <claire.hunter@nice.org.uk>
Co-authored-by: John Davey <66066685+johndavey72@users.noreply.github.com>
* NXT-172 Add API endpoint for deleting fs cache entries (#122)

* NXT-155 Change alert functionality to read from InDev

* NXT-155 Updated snapshot test

* NXT-155 Added alert logic to docs/consultation tabs for project page

* NXT-155 Add API endpoint for deleting fs cache entries

* NXT-155 Prevent cacheing of API cache deletion response

* NXT-155 possible caching fixes (#134)

* NXT-155 possible caching fixes

* NXT-155 stop it generating multiple cache entries in different cases

* NXT-155 move lowercase fixes to getCacheKey function

* NXT-155 Lint cache api; send group keys in 400 err

* NXT-155 fix tests

---------

Co-authored-by: John Holland <john.holland@nice.org.uk>
Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
Co-authored-by: Claire Hunter <claire.hunter@nice.org.uk>

* NXT-178 Add international enquiry form and test (#132)

* NXT-190 embedded doesnt exist for hub pages (#138)

* NXT-186 Static paths WIP

* NXT-186 Update linting rules

* NXT-186 Resolve custom rendering method

---------

Co-authored-by: John Holland <john.holland@nice.org.uk>
Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
Co-authored-by: Claire Hunter <claire.hunter@nice.org.uk>
Co-authored-by: John Davey <66066685+johndavey72@users.noreply.github.com>
Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
Chris Barker and others added 14 commits February 6, 2024 09:26
* chore: test updating the storyblok types from npm script

* feat: test adding image to the storyblok hero and test using button as link if ctaLink and ctatext returned from Storyblok

* chore: add storyblok richtext renderer as dep

* feat: add NewsArticle component to render news articles in app

- Add News Article component with PageHeader and richtext renderer for
  content.
- Update PageHeader to render formatted date from design

Dale H

* style: test adding basic layout styles from scss

* style: update image css

* feat: first pass at blockquote we will use in the richtext examples in news articles

* feat: test adding blockquote to the richtext renderer resolver

* feat: first pass at NewsLetterSignup using DS components

* styles: temp update to blockquote component style

* feat: first pass at adding route for news with catch all for news-blogs-and-podcasts (TEMP till slug sturcture agreed)

* chore: remove console log

* refactor: update NewsArticle component to start using DS components

* feat: first pass adding BlogPost component to render blog pages (TODO: move to its own route under pages dir)

* refactor: remove empty h2 tag

* feat: flesh out news article and move to correct path

- Updated the news article to show panels on sidebar
- updated StoryblokPageHeader to include tags and date (temporary test
  until new PageHeader version completed)
- Added first pass on StoryblokImage component to use Storyblok image
  service, adds support for webp and jpeg formats

Dale H

* feat: first pass on sidebar panels for related news and links

- Added first pass StoryblokRelatedLink and StoryblokRelatedNewsLink
  components
- Added Panels to sidebar on NewsArticle Page

TODO: update spacing across news article and it's components
TODO: add tests for components and pages

Dale H

* refactor: update related news and link components to use Link component from next-web

* chore: remove console.logs

* feat: first pass at updating breadcrumbs

- Update logic on breadcrumb function
- Add path on getBreadcrumbs call, using partly hard coded path.

TODO: get path dynamically, within getStaticProps

Dale H

* refactor: test PageHeader alpha release in StoryblokPageHeader

* styles: update featuredImage offset styles to use custom property, so we can update the variable value inside of media queries

* feat(ts): udpate type for image and pass rest prop to handle passing of common image attributes

* refactor: update newsarticle image to take width and height and maintain 16/9 aspect ratio

* test: update image component test and add fallback image for when src is empty

* refactor: hardcode Breadcrumbs in news article. Comment out breadcrumb logic from StoryblokPageHeader to test news article

* fix: remove updatedBreadcrumb

* feat: start richtextRenderer component

* styles: remove max width from blockquote to span full width of container

* fix: revert StoryblokPageHeader component for stories that use the StoryblokPageHeader blok

* feat: first pass on NewsPageHeader to use on news, in-depth, podcast and blog pages

* feat: update richtext and news article components

- Updated types for richtext component
- Add NewsPageHeader and updated Richtext component to NewsArticle page
  component

Dale H

* styles: update style to handle images contained within richtext content

* feat: first pass at YoutubeEmbed handled by rich text renderer

* refactor: update newspageheader to use date util from repo

* feat: Update richtext component to render inline images as
StoryblokImage component

`

* fix: add workaround to handle inline quotes in the richtext field of
news stories

NOTE: currently the children of the inline quote doesn't render correctly when
using the blockquote component in the nodeResolver of
storyblok-rich-text-renderer. We bump into a few issues around rendering
and correct typing. I've hardcoded the html and imported
styles so we can render the correctly styled quote

TODO: Update the blockquote component or richtext types to handle
passing through richtext quote children to the blockquote component

* fix: update richtext interface, revert to initial interface from previous commit

* tests: add tests for breadcrumbs and pageheader meta for tag and published date

* fix: update breadcrumb name and resources link panel

* test: remove test for fetchPriority attribute

* refactor: update the inner Link component to use href over to attribute

* tests: add relatednewslink tests

* tests: first pass adding youtube embed tests

TODO: add a field in storyblok for title so we can add an accessible
title to the video embed

Dale H

* tests: firstpass adding tests for StoryblokRichText component

* tests: first pass adding tests for Storyblok NewsArticle component

* styles: update cta button so inner text wraps

* fix: update types for newsarticle, add test to check whether signup action is rendered

* tests: update NewsArticle tests

* tests: first pass test news article slug page

* fix: remove unused imports from richtext component and tests

* chore: update design system version for new pageheader

* refactor: update the newsarticle component to take new page header over
newspageheader.

- Update NewsArticle.tsx to use design system PageHeader new version
- Add hardcoded breadcrumb values and handle in NewsArticle to be passed
  to PageHeader component

TODO: Possible refactor of NewsPageHeader to be a generic component that
can be used on news index and slug pages

TODO: Image spacing to be handled via useEffect and ref to image to
dynamically update the css varaible for its spacing

Dale H

`

* chore: rename pageheaderfooter that contains date and tag

* refactor: update StoryblokImage and NewsArticle for overlap

Added refs to NewsArticle and StoryblokImage so we can target them for
updating the custom property value for the image overlap between header
and body

* style: update spacing around pageheader elements

* tests: add further coverage on NewsArticle component

* fix: udpate relatedlink and relatednewslink to use resolveStoyblokLink util function

* round the pixels down on the featuredImageOffset value

* fix: append /m/ for webp source image

* fix: add title to Youtube embed for screen reader use

* chore: update storyblok types

* fix: update youtube iframe embed source value, remove comments
* NICE-170 Homepage WIP

* NICE-170 Latest news WIP

* NICE-170 List latest news articles

* NICE-170 Featured story WIP

* NICE-170 Implement homepage hero

* NICE-170 Action banner WIP

* NICE-170 Resolved link, promo box WIP

* NICE-170 Fix broken links for story objects

* NICE-170 Complete "latest from NICE" section

* NICE-170 Revert tsconfig, add NewsStory types

* NICE-170 Add unit tests for homepage news section & components

* NICE-170 Render news grid image as link, fix snapshots

* NICE-170 Use better semantics, fix snapshots

* NICE-170 misc fixes post review

---------

Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
* fix: add empty dependancy array to useEffect to run once on mount, resize event for image

* fix: add missing slash on jpeg src

* feat: first pass adding author blok

* styles: round image for author image

* refactor: bring in update to fetchStory function and add author blok

* first pass onblog post with listed authors - rough draft

* update author component, extract the authorlist from blog post

* update interface for blogpost and remove the inlined authorlist

* fix: remove trailing comma from tsconfig

* refactor: move authorlist to its own component, test author component

* add authorList component and extend tests

* start moving newspage header and child component into own files

* fix: rename blogpost and newsarticle component to keep naming convention for Storyblok blok components

* refactor: update AuthorList and tests

* tests: start blogpost component tests

* styles: update richtext elements vertical spacing and blog post

* tests: update blog post slug page tests

* tests: update youtube embed tests to include updated title property

* tests: add missing slash from returned image source in tests

* tests: update snapshot tests related to pageheader updates

* styles: remove need for nested grid on BlogPost component, spacing updates on articles and posts

* tests: update snapshots related to pageheader updates

* tests: add testid to pageheader to test id applied, after pageheader updates

* style: add commented styles to take over pageheader secondsection styles in NDS

* feat: first pass at StoryblokIframe component

* spike: spike nextjs/third-parties and react-lite youtube embeds

- Tested next third parties, works but difficulty testing
- Tested react-lite-youtube-embed, works and tested.

TODO: test accessibility of react-lite-yt-embed further and against
standard iframe implementation.
TODO: ensure component is typed correctly

* chore: remove spiked nextjs/third-parties

* fix: remove incomplete import from richtext styles causing no styles to load

* feat: use react-lite-youtube-embed for YT embed component

* fix: update params and cookie props on on LiteYoutubeEmbed

Issue with Safari not autoplaying the video once the poster play button
was clicked.

Adding cookie=true and updating params to include autoplay=1 solves this
issue.

* styles: update action banner spacing on newsarticle

* styles: first pass normalise spacing to use DS spacing values

* styles: normalise blockquote spacing

* styles: tidy duplicated spacing

* fix: add lodash debounce to handleResize functions on blog and news page components

* tests: update breadcrumb test on slug page, and remove expect from youtubeembed test
Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
* update test utils mocks for blog post and news article

* fix: update type of blogpost blok and update tests to use mock util data

* fix: udpate type of slug pages for blog and news to pass correct blok types

* fix: udpate types and mock for newsarticle component

- Update blok prop type and revert back to types generated by Storyblok
- remove previous override type for news article
- Update StoryblokNewsArticle to use mock data from test utils

Dale H

* refactor: update authorlist to render author blok over stoyblok component, and add className prop to AuthorBlok

* tests: update test to check for author data in blogpost component

* tests: update slug page tests on news and blog page slugs, using mock data from utils

* tests: add richtext mock data and update tests that use richtext
* NICE-169 Promo sections WIP

* NICE-169 Complete Promo Box & tests

---------

Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
* styles: update horizontal spacing

* styles: update targetting on Youtube embed when child of richtext component

* styles: update spacing on featuredImage and page header

* refactor: normalise grid layout between newArticle and blogPost, update featuredImage margins

* styles: switch featuredImage to 21/9 between sm and md breakpoints

* styles: udpate spacing between main content/sidebar, header and action banner

* styles: update bottom margin on youtube embed in richtext

* styles: add fallback styles for inset and set button hover cursor to pointer

* styles: update author styles from crit

* styles: remove pageheader bottom margin
Co-authored-by: Chris Barker <chris.barker@nice.org.uk>
@dalecreativ dalecreativ changed the base branch from main to storyblok-main February 29, 2024 17:33
@dalecreativ dalecreativ marked this pull request as ready for review March 4, 2024 11:59
@dalecreativ dalecreativ changed the title DRAFT: Image overlap custom hook Image overlap custom hook Mar 4, 2024
johndavey72
johndavey72 previously approved these changes Mar 11, 2024
Base automatically changed from storyblok-main to main June 3, 2024 11:32
@barkertron barkertron dismissed johndavey72’s stale review June 3, 2024 11:32

The base branch was changed.

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.

3 participants