Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Jun 22, 2024
1 parent 944fff6 commit a129f3a
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 38 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

[![GitHub Actions](https://github.com/FartLabs/htx/actions/workflows/check.yaml/badge.svg)](https://github.com/FartLabs/htx/actions/workflows/check.yaml)

Render HTML components with JSX.
Render HTML components with JSX powered by Deno and
[**@fartlabs/jsonx**](https://jsr.io/@fartlabs/jsonx).

## API documentation

Expand All @@ -12,7 +13,7 @@ Generated API documentation is available at <https://jsr.io/@fartlabs/htx>.

### Deno

Let's learn how to get started with rtx by creating a simple router in Deno.
Let's learn how to get started with htx by creating a simple router in Deno.

1\. [Install Deno](https://docs.deno.com/runtime/manual).

Expand All @@ -22,10 +23,10 @@ Let's learn how to get started with rtx by creating a simple router in Deno.
deno init
```

3\. Add `@fartlabs/jsonx` and `@fartlabs/htx` as project dependencies.
3\. Add `@fartlabs/htx` as a project dependency.

```sh
deno add @fartlabs/jsonx @fartlabs/htx
deno add @fartlabs/htx
```

4\. Add the following values to your `deno.json(c)` file.
Expand All @@ -34,7 +35,7 @@ deno add @fartlabs/jsonx @fartlabs/htx
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@fartlabs/jsonx"
"jsxImportSource": "@fartlabs/htx"
}
}
```
Expand Down
3 changes: 1 addition & 2 deletions area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { AreaElementProps };
export function AREA(
props: AreaElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
3 changes: 1 addition & 2 deletions base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { BaseElementProps };
export function BASE(
props: BaseElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
3 changes: 1 addition & 2 deletions br.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { BrElementProps };
export function BR(
props: BrElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
8 changes: 4 additions & 4 deletions cli/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ if (import.meta.main) {
initializer: "{}",
}],
returnType: "string",
statements: [
statements: descriptor.isVoid ? ["return render(props);"] : [
"const { children, ...rest } = props;",
descriptor.isVoid
? "return render(rest);"
: "return render(rest, ...(children ?? []));",
"return render(rest, ...(children ?? []));",
],
docs: toDocs({
description:
Expand All @@ -67,6 +65,7 @@ if (import.meta.main) {
undefined,
{ overwrite: true },
);
modFile.addStatements(`export * from "./special/mod.ts";`);
for (const descriptor of descriptors) {
modFile.addStatements(`export * from "./${descriptor.tag}.tsx";`);
}
Expand All @@ -78,6 +77,7 @@ if (import.meta.main) {
const denoConfig = JSON.parse(await Deno.readTextFile("./deno.json"));
denoConfig.exports = {
".": "./mod.ts",
"./jsx-runtime": "./jsx-runtime.ts",
...Object.fromEntries(descriptors.map((descriptor) => [
`./${descriptor.tag}`,
`./${descriptor.tag}.tsx`,
Expand Down
3 changes: 1 addition & 2 deletions col.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { ColElementProps };
export function COL(
props: ColElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"exports": {
".": "./mod.ts",
"./special": "./special/mod.ts",
"./jsx-runtime": "./jsx-runtime.ts",
"./a": "./a.tsx",
"./abbr": "./abbr.tsx",
"./acronym": "./acronym.tsx",
Expand Down
3 changes: 1 addition & 2 deletions embed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { EmbedElementProps };
export function EMBED(
props: EmbedElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
3 changes: 1 addition & 2 deletions hr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { HrElementProps };
export function HR(
props: HrElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
3 changes: 1 addition & 2 deletions img.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { ImgElementProps };
export function IMG(
props: ImgElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
3 changes: 1 addition & 2 deletions input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { InputElementProps };
export function INPUT(
props: InputElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
1 change: 1 addition & 0 deletions jsx-runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "@fartlabs/jsonx/jsx-runtime";
3 changes: 1 addition & 2 deletions link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { LinkElementProps };
export function LINK(
props: LinkElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
3 changes: 1 addition & 2 deletions meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { MetaElementProps };
export function META(
props: MetaElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
1 change: 1 addition & 0 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./special/mod.ts";
export * from "./a.tsx";
export * from "./abbr.tsx";
export * from "./acronym.tsx";
Expand Down
3 changes: 1 addition & 2 deletions param.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ export type { ParamElementProps };
export function PARAM(
props: ParamElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
3 changes: 1 addition & 2 deletions source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { SourceElementProps };
export function SOURCE(
props: SourceElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
3 changes: 1 addition & 2 deletions track.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { TrackElementProps };
export function TRACK(
props: TrackElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}
3 changes: 1 addition & 2 deletions wbr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export type { WbrElementProps };
export function WBR(
props: WbrElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
return render(props);
}

0 comments on commit a129f3a

Please sign in to comment.