-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support for <react.Component.Item /> + automatic injection of c…
…omponents to sveltify(...) - `<react.div>` now even works when no `div:"div"` is passed to sveltify. Fixes #46
- Loading branch information
Showing
11 changed files
with
160 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,6 @@ | ||
/// <reference path="global.d.ts" /> | ||
|
||
import type { Sveltified } from "./internal/types.js"; | ||
/// <reference types="./global" /> | ||
export { default as hooks } from "./hooks.js"; | ||
export { default as reactify } from "./reactify.js"; | ||
export { default as sveltify } from "./sveltify.svelte.js"; | ||
export { default as used } from "./used.js"; | ||
export { default as useStore } from "./useStore.js"; | ||
|
||
declare global { | ||
function sveltify< | ||
T extends { | ||
[key: string]: | ||
| keyof JSX.IntrinsicElements | ||
| React.JSXElementConstructor<any>; | ||
}, | ||
>( | ||
reactComponents: T, | ||
): { | ||
[K in keyof T]: Sveltified<T[K]>; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
import List from "../../tests/fixtures/List.svelte"; | ||
</script> | ||
|
||
<List /> | ||
|
||
<!-- <react.div><react.h1>Heading1</react.h1></react.div> --> | ||
<!-- <react.h2>Heading2</react.h2> --> | ||
<!-- <react.h1>Heading1</react.h1> | ||
<react.h2>Heading2</react.h2> | ||
<react.h3>Heading3</react.h3> --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
import List from "./List"; | ||
const react = sveltify({ List }); | ||
</script> | ||
|
||
<react.List> | ||
<react.List.Item label="1" /> | ||
<react.List.Item>Item 2</react.List.Item> | ||
<react.List.Item>Item <span>3</span></react.List.Item> | ||
</react.List> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from "react"; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
}; | ||
export default function List({ children }: Props) { | ||
return <ul className="list">{children}</ul>; | ||
} | ||
|
||
type ItemProps = { | ||
label: string; | ||
children: React.ReactNode; | ||
}; | ||
|
||
List.Item = ({ label, children }: ItemProps) => { | ||
return ( | ||
<li className="list__item"> | ||
{label} | ||
{children} | ||
</li> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters