aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/hooks
Commit message (Collapse)AuthorAgeFilesLines
* refactor(hooks): rewrite usePagination hookArmand Philippot2023-11-134-119/+233
| | | | | | | * replace `isLoadingInitialData` with `isLoading` & `isRefreshing` * rename `fallbackData` prop to `fallback` * replace `setSize` return with a `loadMore` callback * add tests
* feat(hooks): add an useForm hookArmand Philippot2023-11-1110-0/+788
| | | | | | | | | * 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-115-38/+121
| | | | | | * extract setTimeout logic using useTimeout * change condition to be a function * return a ref
* feat(hooks): add an useTimeout hookArmand Philippot2023-11-114-0/+81
|
* refactor(hooks): rewrite useOnClickOutside hookArmand Philippot2023-11-114-50/+81
| | | | | | | * remove `useCapture` parameter (it does not make sense to use bubbling here) * return a MutableRefObject instead of a RefObject to be able to test the hook
* feat(components): add an Overlay componentArmand Philippot2023-11-117-0/+141
| | | | | | | | * 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-117-0/+132
|
* refactor(providers,hooks): rewrite PrismThemeProvider & usePrismThemeArmand Philippot2023-11-117-107/+190
| | | | | | * 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-118-0/+144
| | | | | | | 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-114-0/+77
| | | | | | | | | | 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-115-18/+61
|
* refactor(hooks): rewrite useLocalStorage hookArmand Philippot2023-11-114-33/+98
| | | | | | | * return a tuple instead of an object * add a validator function as parameter (if the stored value is manually changed, it is not safe to cast its type) * add tests
* refactor(components): rewrite Breadcrumbs componentArmand Philippot2023-11-111-34/+53
|
* refactor(components): rewrite Code component and usePrism hookArmand Philippot2023-11-114-183/+309
| | | | | | | | | | | | * move Prism styles to Sass placeholders to avoid repeats * let usePrism consumer define its plugins (remove default ones) * remove `plugins` prop from Code component * add new props to Code component to let consumer configure plugins (and handle plugin list from the given options) However there are some problems with Prism plugins: line-highlight and treeview does not seems to be loaded. I don't want to use Babel instead of SWC so I have no solution for now.
* refactor(components): rewrite Branding componentArmand Philippot2023-11-112-28/+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(routes): replace hardcoded routes with constantsArmand Philippot2023-10-241-11/+13
| | | | | | | | It makes it easier to change a route if needed and it avoid typo mistakes. I also refactored a bit the concerned files to be complient with the new ESlint config. However, I should rewrite the pages to reduce the number of statements.
* refactor: use named export for everything except pagesArmand Philippot2023-09-2024-90/+80
| | | | | | 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.
* refactor(build): replace paths aliases with relative pathsArmand Philippot2023-09-1911-19/+19
| | | | | | Using paths aliases starting with "@" can be confusing and can lead to conflict with existings modules. I prefer to use relative paths to avoid extra configuration in tools because of these aliases.
* fix(projects): load content dynamically and refresh table of contentsArmand Philippot2022-09-212-1/+40
| | | | | | | The previous way of handling content import was causing issue. So I use dynamic import instead. However, the table of contents was not displayed because the wrapper is first empty. I added a mutation observer to refresh the table of contents when the body is updated.
* fix(comments): load all comments on a postArmand Philippot2022-08-211-20/+7
| | | | | | | | | Previously, only the first 10 comments was loaded. So I update the fetching method to retrieve all the comments on a post. Also, I choose to order comments on client side because of a bug with WPGraphQL. Finally, I renamed the Comment type to SingleComment to avoid conflict with existing types.
* refactor(types): move and rename GraphQL typesArmand Philippot2022-08-203-11/+8
| | | | | | | The api file in services was not really readable. So I move the types and I also rewrite a little the fetch function. I also rename most of the type to avoid conflict with preexisting types (like Node) and to keep consistency.
* fix(article): prevent TypeError on buildArmand Philippot2022-07-232-8/+25
| | | | | | By switching to custom hooks for revalidating articles and comments, everything was working on development mode but articles failed to build for production.
* refactor(article): wrap useSWR with a custom hook to revalidate articleArmand Philippot2022-07-222-4/+28
|
* fix(comments): refresh comments on changes or new commentArmand Philippot2022-07-221-0/+33
|
* fix(settings): close tooltip when modal is closingArmand Philippot2022-06-082-46/+52
| | | | | The event was not captured so the tooltip remained open when the settings was closed. It prevented to click on the toolbar buttons.
* chore: replace the toggle componentArmand Philippot2022-06-011-0/+19
|
* build(deps): bump all dependenciesArmand Philippot2022-05-251-21/+0
| | | | | | | I moved the website picture from useSettings to the layout component since it is only used here. This reduce the number of Jest errors. However, there's still some issues with some images import...
* chore: close search form when launching searchArmand Philippot2022-05-241-0/+12
|
* chore: give autofocus to the toolbar search formArmand Philippot2022-05-241-0/+39
|
* fix: close Ackee tooltip on button clickArmand Philippot2022-05-211-2/+5
| | | | | | | The tooltip was closing and reopening on click because of a conflict between the button event and the hook useClickOutside. By checking that the event target is not the button, the tooltip is now closing as expected.
* chore: handle blog pagination when JS is disabledArmand Philippot2022-05-202-1/+35
|
* refactor: rewrite Prism hooks and providersArmand Philippot2022-05-197-207/+253
| | | | | It avoid some hydratation errors on project pages (not in article however) and the hooks are now reusable.
* chore: handle settings changeArmand Philippot2022-05-185-0/+125
|
* chore: close toolbar modals on click/focus outsideArmand Philippot2022-05-181-0/+43
|
* chore: add branding animationArmand Philippot2022-05-181-0/+29
|
* chore: listen scroll to hide/show back to top buttonArmand Philippot2022-05-171-0/+15
|
* chore: adjust and complete missing stylesArmand Philippot2022-05-161-0/+60
| | | | | | * add logo to topics pages and links * add Prism styles to articles * and a few other adjustements
* refactor: use custom hook for breadcrumb items and schemaArmand Philippot2022-05-161-0/+106
|
* chore: add Search pageArmand Philippot2022-05-152-1/+25
|
* chore: handle blog paginationArmand Philippot2022-05-131-0/+116
|
* chore: add the Blog index pageArmand Philippot2022-05-131-0/+58
|
* chore: add Project single pagesArmand Philippot2022-05-132-1/+31
|
* chore: add a Contact pageArmand Philippot2022-05-071-1/+7
|
* chore: add homepageArmand Philippot2022-05-031-0/+112
|
* chore: remove old pages, components, helpers and typesArmand Philippot2022-04-292-127/+0
| | | | | Since I'm using new components, I will also rewrite the GraphQL queries so it is easier to start from scratch.
* chore: add a PageLayout componentArmand Philippot2022-04-251-0/+19
|
* chore: add a TableOfContents componentArmand Philippot2022-04-221-0/+153
|
* chore: add a Code componentArmand Philippot2022-04-191-0/+115
|
* chore(toc): exclude comments section for headings listArmand Philippot2022-02-121-1/+1
|
* refactor(project): replace repo api call method with hook and swrArmand Philippot2022-01-241-0/+23
| | | | | | | | | | Instead of using post slug and an environment variable to fetch repo data, I use the given repo in each project MDX file. It allows me to fetch data from another user/organization if needed. To make it work, I no longer provide the full URL in MDX file. The new format is: "User/repo-slug". I also replaced the fetch method with SWR to improve caching and to avoid React complaining about cleanup useEffect.