aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/hooks/index.ts
Commit message (Collapse)AuthorAgeFilesLines
* refactor(hooks): rewrite useBreadcrumbs hookArmand Philippot2023-12-121-1/+1
| | | | | | | * use next/router to get the slug instead of using props * handle cases where the current page title is not provided * update JSON-LD schema to match the example in documentation * add tests
* refactor(pages): refine Project pagesArmand Philippot2023-12-081-0/+1
| | | | | | | | | | | * refactor ProjectOverview component to let consumers handle the value * extract project overview depending on Github to avoid fetching Github API if the project is not on Github * wrap dynamic import in a useMemo hook to avoid infinite rerender * fix table of contents by adding a useMutationObserver hook to refresh headings tree (without it useHeadingsTree is not retriggered once the dynamic import is done) * add Cypress tests
* refactor(hooks): replace useGithubApi with useGithubRepoMetaArmand Philippot2023-12-071-1/+1
| | | | | | | | * use GraphQL API instead of REST (the inconvenient however is that we now need an authorization token...) * move fetcher in services * add tests * mock response using MSW
* refactor(pages): refine Search pageArmand Philippot2023-12-071-1/+0
| | | | | | | * extract NoResults component to improve readability * provide a different message when the url does not contain a query * use hooks to refresh Thematics and Topics lists * remove useDataFromApi hook
* refactor(pages): refine Blog pagesArmand Philippot2023-12-041-2/+1
| | | | | | | | | | * replace usePostsList with useArticlesList to keep names coherent * remove useIsMounted hook * rewrite useRedirection hook * add redirect in getStaticProps to avoid unecessary fetching * move Pagination component in a noscript tag * use hooks to refresh thematics and topics lists * complete Cypress tests
* refactor(pages): refine Topic pagesArmand Philippot2023-12-011-0/+2
| | | | | | * add useTopic and useTopicsList hooks to refresh data * add a table of contents * add Cypress tests
* refactor(pages): refine Thematic pagesArmand Philippot2023-12-011-0/+2
| | | | | | | | | | | * add a table of contents (however posts heading are not included) * rename posts list section title * add a useThematic hook to refresh thematic contents * add a useThematicLists hook to refresh thematics list * add a `notIn` filter in thematics list fetcher to directly remove unwanted thematics * add Cypress tests
* refactor(components): replace items prop in Navbar componentArmand Philippot2023-11-211-1/+0
| | | | | | | | | | | | | | * replace `items` prop with `children` prop: it is more readable this way, * handle navbar item state inside NavbarItem component: it avoid using three differents states and their methods to do exactly the same thing * remove useAutofocus hook since we can't use it anymore * add `onActivation` and `activationHandlerDelay` prop to NavbarItem component to be able to focus the search input only when the item is activated (it replicates the functioning of useAutofocus hook) * replace `ref` type in SearchForm component: it does not make sense to use an input ref for a form. Instead I use useImperativeHandle to provide different a focus method to the given ref.
* refactor(components): replace PageLayout template with PageArmand Philippot2023-11-201-1/+0
| | | | | | | | | * split pages in smaller components (it is both easier to maintain and more readable, we avoid the use of fragments in pages directory) * extract breadcrumbs from article tag (the navigation is not related to the page contents) * remove useReadingTime hook * remove layout options except `isHome`
* refactor(hooks): remove unused hooksArmand Philippot2023-11-151-2/+0
| | | | | * useMutationObserver removed * useStateChange removed
* refactor(hooks): replace useRouteChange with useOnRouteChange hookArmand Philippot2023-11-151-1/+1
| | | | | | * handle both event start and event complete * clean the effect * add tests
* refactor(hooks): remove useSettings hookArmand Philippot2023-11-151-1/+0
| | | | | | | It does not make sense to re-export an existing object through a hook. On some pages both the hook and the object was imported... It is better to use the CONFIG (previously settings) object directly and by doing it we avoid potential errors because of conditional hooks.
* refactor(components): rewrite PostsList componentArmand Philippot2023-11-131-0/+1
| | | | | | | | | | | | | | | * remove NoResults component and move logic to Search page * add a usePostsList hook * remove Pagination from PostsList (it is only used if javascript is disabled and not on every posts list) * replace `byYear` prop with `sortByYear` * replace `loadMore` prop with `onLoadMore` * remove `showLoadMoreBtn` (we can use `loadMore` prop instead to determine if we need to display the button) * replace `titleLevel` prop with `headingLvl` * add `firstNewResult` prop to handle focus on the new results when loading more article (we should not focus a useless span but the item directly)
* feat(hooks): add an useForm hookArmand Philippot2023-11-111-0/+1
| | | | | | | | | * add two "sub"-hooks: useFormValues and useFormSubmit (that can be used independently) * handle initial data * handle custom submit callback * handle data validation * handle submit status
* refactor(hooks): replace useInputAutofocus with useAutofocus hookArmand Philippot2023-11-111-1/+1
| | | | | | * extract setTimeout logic using useTimeout * change condition to be a function * return a ref
* feat(hooks): add an useTimeout hookArmand Philippot2023-11-111-0/+1
|
* feat(components): add an Overlay componentArmand Philippot2023-11-111-0/+2
| | | | | | | | * add useScrollbarWidth hook * add useScrollLock hook * add a new component to lock scroll with an overlay (it can be useful especially on small screens to prevent background contents to be scrolled)
* feat(hooks): add useBoolean and useToggle hooksArmand Philippot2023-11-111-0/+2
|
* refactor(providers,hooks): rewrite PrismThemeProvider & usePrismThemeArmand Philippot2023-11-111-3/+1
| | | | | | * reuse Theme provider logic * move DOM mutation from provider to hook * add a script to init theme before page load
* feat: replace next-themes with a custom ThemeProviderArmand Philippot2023-11-111-0/+3
| | | | | | | To be honest, next-themes was working fine. However since I use a theme provider for Prism code blocks, some code is duplicated between this app and the library. So I prefer to use a custom Provider without the options I don't need.
* refactor(hooks,provider): move reduce motion setterArmand Philippot2023-11-111-0/+1
| | | | | | | | | | Since the local storage key is not meant to change between the components, it should be set directly inside the app file. So both the local storage and the data attribute should be handle in a provider. I also added a custom document because we need a script to retrieve the stored value in local storage earlier to avoid flashing on hydration.
* refactor(hooks,providers): rewrite useAckee hook and AckeeProviderArmand Philippot2023-11-111-1/+1
|
* refactor(components): rewrite Branding componentArmand Philippot2023-11-111-1/+0
| | | | | | The component should only be responsible of the layout for the logo, the name and the optional baseline. Also, the homepage url could be different from `/` so the consumer should give the right url.
* refactor: use named export for everything except pagesArmand Philippot2023-09-201-0/+24
Next expect a default export for pages so only those components should use default exports. Everything else should use named exports to reduce the number of import statements.