Skip to content

Commit

Permalink
πŸ“ fix docs for @coven/pair
Browse files Browse the repository at this point in the history
  • Loading branch information
loucyx committed Jan 2, 2025
1 parent 99c4754 commit 95436ea
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
publish:
runs-on: ubuntu-latest
runs-on: macos-latest
permissions:
contents: read
id-token: write
Expand Down
10 changes: 6 additions & 4 deletions @coven/pair/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Currently supported frameworks:
### Preact

```tsx
import { createElement } from "preact";
import { useState } from "preact/hooks";
/** @jsxImportSource preact */
import { pair } from "@coven/pair/preact";
import { useState } from "preact/hooks";

const useCount = (initialCount: number) => {
const [count, setCount] = useState(initialCount);
Expand Down Expand Up @@ -53,9 +53,11 @@ const Component = ({ array = [] }) => (
### React

```tsx
// @deno-types="@types/react"
import { createElement, useState } from "react";
/** @jsxImportSource react */
/** @jsxImportSourceTypes @types/react */
import { pair } from "@coven/pair/react";
// @deno-types="@types/react"
import { useState } from "react";

const useCount = (initialCount: number) => {
const [count, setCount] = useState(initialCount);
Expand Down
2 changes: 1 addition & 1 deletion @coven/pair/preact/pair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { PairedComponentProperties } from "./PairedComponentProperties.ts";
*
* @example
* ```tsx
* import { createElement } from "preact";
* /** @jsxImportSource preact *\/
* import { useState } from "preact/hooks";
*
* const useCount = (initialCount: number) => {
Expand Down
5 changes: 4 additions & 1 deletion @coven/pair/react/pair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import type { PairedComponentProperties } from "./PairedComponentProperties.ts";
*
* @example
* ```tsx
* import { createElement, useState } from "react";
* /** @jsxImportSource react *\/
* /** @jsxImportSourceTypes @types/react *\/
* // @deno-types="@types/react"
* import { useState } from "react";
*
* const useCount = (initialCount: number) => {
* const [count, setCount] = useState(initialCount);
Expand Down
31 changes: 31 additions & 0 deletions @coven/pair/test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/** @jsxImportSource react */
/** @jsxImportSourceTypes @types/react */
import { pair } from "@coven/pair/react";
// @deno-types="@types/react"
import { useState } from "react";

const useCount = (initialCount: number) => {
const [count, setCount] = useState(initialCount);

return { onClick: () => setCount(count + 1), children: count };
};

const PairedCount = pair(useCount);

const Component = ({ array = [] }) => (
<ul>
{array.map((key) => (
<PairedCount key={key}>
{(usePairedCount) => {
const props = usePairedCount(key);

return (
<li>
<button type="button" {...props} />
</li>
);
}}
</PairedCount>
))}
</ul>
);

0 comments on commit 95436ea

Please sign in to comment.