Skip to content

Commit

Permalink
chore(deploy): Release (#44)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
willybrauner and github-actions[bot] authored Sep 7, 2024
1 parent 4e31d18 commit be0463d
Show file tree
Hide file tree
Showing 4 changed files with 3,640 additions and 4,363 deletions.
90 changes: 0 additions & 90 deletions .changeset/tough-socks-marry.md

This file was deleted.

92 changes: 92 additions & 0 deletions packages/low-router-preact/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# @wbe/low-router-preact

## 0.1.0

### Minor Changes

- 4e31d18: Low router preact wrapper first release.

## Usage example

(check the readme for more information)

main.tsx:

```tsx
import { render } from "preact"
import { createBrowserHistory } from "@wbe/wbe-router"
import { Router } from "@wbe/low-router-preact"

// Prepare the routes list
const routes = [
{
name: "home",
path: "/",
action: () => Home,
},
{
name: "about",
path: "/about",
action: () => About,
},
]

// Pass the routes list as LowRouter param
const router = new LowRouter(routes)

// Prepare a browser history
const history = createBrowserHistory()

// Render the app wrapped by the Router
render(
<Router router={router} history={history}>
<App />
</Router>,
document.getElementById("root"),
)
```

App.tsx

```tsx
import { Link, Stack } from "@wbe/low-router-preact"

export default function App() {
return (
<div>
<nav>
<Link to={{ name: "home" }}>{"home"}</Link>
<Link to={{ name: "about" }}>{"about"}</Link>
</nav>
{/* Render current route here */}
<Stack />
</div>
)
}
```

Home.tsx

```tsx
import { useRef, useImperativeHandle } from "preact/hooks"

const Home = (props, ref) => {
const rootRef = useRef(null)

// Each route need to attached name, DOM root, playIn & playOut to the forwarded ref.
// The Stack use this forwarded ref in order to control the component.
useImperativeHandle(
ref,
() => ({
name: "Home",
root: rootRef.current,
playIn: () => customPlayIn(rootRef.current),
playOut: () => customPlayOut(rootRef.current),
}),
[],
)
return <div ref={rootRef}>Hello home!</div>
}

export default forwardRef(Home)
```
2 changes: 1 addition & 1 deletion packages/low-router-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@wbe/low-router-preact",
"author": "Willy Brauner",
"license": "MIT",
"version": "0.0.1",
"version": "0.1.0",
"type": "module",
"files": [
"dist"
Expand Down
Loading

0 comments on commit be0463d

Please sign in to comment.