Skip to content

Commit

Permalink
Merge pull request #29 from 21TORR/dune
Browse files Browse the repository at this point in the history
Add Dune docs
  • Loading branch information
apfelbox authored Mar 12, 2024
2 parents 831d960 + eec1ed6 commit 3fc2afe
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
10 changes: 10 additions & 0 deletions blog/2024-03-12-dune-additions.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
slug: dune-additions
title: New Features + Docs for Dune
authors: [jannik]
tags: [dune]
---

[Dune] now has some docs, with focus on the new React components.

[Dune]: /docs/ts-scss/dune
23 changes: 23 additions & 0 deletions docs/ts-scss/dune/react/anchor-integration.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Anchor Integration

The anchor integration is a helper to fix weird anchor (URL fragment) positioning issues in React pages.

The main issue is that there is a race condition between the positioning of the browser window and React rendering. If React is finished rendering before the browser is trying to position to window to the anchor, everything is fine: the window will end up at the right place.

However, if the viewport is positioned before React is finished rendering, the temporary position of the anchored element might shift (e.g. because above the element a large container is rendered and pushes the following content down).

There is no proper fix, as we can't tell the browser to wait with the positioning.

This element circumvents the issue, by waiting after the initial render (and then 250ms by default) to reposition the viewport explicitly once again.

## Usage

You should load this component once in your app. If you are using Next.js, a (fairly top-level) layout would be the correct place for it.

```tsx
import {AnchorIntegration} from "@21torr/dune/next/components/Structure/AnchorIntegration.js";

<AnchorIntegration />
```

By default, the component waits 250ms after the initial render, you can adjust this value by explicitly passing the `timeout` prop.
15 changes: 15 additions & 0 deletions docs/ts-scss/dune/react/client-only-portal.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Client Only Portal

The ClientOnlyPortal is a React portal, that is only rendered on the client.
On the server it will render to `null`.

```tsx
import {ClientOnlyPortal} from "@21torr/dune/react/components/Structure/ClientOnlyPortal.js";

<ClientOnlyPortal>
<div>My content</div>
</ClientOnlyPortal>
```

You can pass an explicit `container` prop, to specify in which element the portal should point to.
By default, the `<body>` is used.
File renamed without changes.
10 changes: 10 additions & 0 deletions docs/ts-scss/dune/react/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# React Components

This is a list of all React components.

Some of these components are intended to be used in Next.js only, some can be used in a standalone React project.


- [AnchorIntegration](./anchor-integration)
- [ClientOnlyPortal](./client-only-portal)
- [Cookiebot component and hooks](./cookiebot)

0 comments on commit 3fc2afe

Please sign in to comment.