Skip to content

Commit

Permalink
PR #1
Browse files Browse the repository at this point in the history
Merges the changes of PR #1.
  • Loading branch information
EthanThatOneKid committed Apr 6, 2024
1 parent 02d9bf0 commit 79f06ca
Show file tree
Hide file tree
Showing 136 changed files with 2,232 additions and 12 deletions.
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [@fartlabs/htx](https://jsr.io/@fartlabs/htx)

[![GitHub Actions][GitHub Actions badge]][GitHub Actions]
[![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.

Expand Down Expand Up @@ -42,9 +42,15 @@ deno add @fartlabs/jsonx @fartlabs/htx
5\. Add a file ending in `.[j|t]sx` to your project. For example, `main.tsx`.

```tsx
import { a } from "@fartlabs/htx";
import { A, BODY, H1, P } from "@fartlabs/htx";

const html = <a href="https://example.com">Hello, world!</a>;
const html = (
<BODY>
<H1>Hello, World!</H1>
<P>This is a paragraph.</P>
<A href="https://jsr.io/@fartlabs/htx">@fartlabs/htx</A>
</BODY>
);

Deno.writeTextFileSync("index.html", html);
```
Expand All @@ -58,7 +64,7 @@ deno run --allow-net main.tsx
Resulting `index.html`:

```html
<a href="https://example.com">Hello, world!</a>
<body><h1>Hello, World!</h1><p>This is a paragraph.</p><a href="https://jsr.io/@fartlabs/htx">@fartlabs/htx</a></body>
```

## Contribute
Expand All @@ -69,13 +75,10 @@ Run `deno fmt` to format the code.

Run `deno lint` to lint the code.

### Code generation

Run `deno task generate` to generate the code.

---

Developed with ❤️ [**@FartLabs**](https://github.com/FartLabs)

[JSR]: https://jsr.io/@fartlabs/htx
[JSR badge]: https://jsr.io/badges/@fartlabs/htx
[JSR score]: https://jsr.io/@fartlabs/htx/score
[JSR score badge]: https://jsr.io/badges/@fartlabs/htx/score
[GitHub Actions]: https://github.com/FartLabs/htx/actions/workflows/check.yaml
[GitHub Actions badge]: https://github.com/FartLabs/htx/actions/workflows/check.yaml/badge.svg
13 changes: 13 additions & 0 deletions a.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { AElementProps } from "@fartlabs/ht/a";
import { a as render } from "@fartlabs/ht/a";

export type { AElementProps };

/**
* A component renders the [`a`](https://developer.mozilla.org/docs/Web/HTML/Element/a) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/a>
*/
export function A(props: AElementProps & { children?: string[] } = {}): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions abbr.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { AbbrElementProps } from "@fartlabs/ht/abbr";
import { abbr as render } from "@fartlabs/ht/abbr";

export type { AbbrElementProps };

/**
* ABBR component renders the [`abbr`](https://developer.mozilla.org/docs/Web/HTML/Element/abbr) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/abbr>
*/
export function ABBR(
props: AbbrElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
16 changes: 16 additions & 0 deletions acronym.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { AcronymElementProps } from "@fartlabs/ht/acronym";
import { acronym as render } from "@fartlabs/ht/acronym";

export type { AcronymElementProps };

/**
* ACRONYM component renders the [`acronym`](https://developer.mozilla.org/docs/Web/HTML/Element/acronym) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/acronym>
* @deprecated
*/
export function ACRONYM(
props: AcronymElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions address.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { AddressElementProps } from "@fartlabs/ht/address";
import { address as render } from "@fartlabs/ht/address";

export type { AddressElementProps };

/**
* ADDRESS component renders the [`address`](https://developer.mozilla.org/docs/Web/HTML/Element/address) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/address>
*/
export function ADDRESS(
props: AddressElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions area.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { AreaElementProps } from "@fartlabs/ht/area";
import { area as render } from "@fartlabs/ht/area";

export type { AreaElementProps };

/**
* AREA component renders the [`area`](https://developer.mozilla.org/docs/Web/HTML/Element/area) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/area>
*/
export function AREA(
props: AreaElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
}
15 changes: 15 additions & 0 deletions article.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { ArticleElementProps } from "@fartlabs/ht/article";
import { article as render } from "@fartlabs/ht/article";

export type { ArticleElementProps };

/**
* ARTICLE component renders the [`article`](https://developer.mozilla.org/docs/Web/HTML/Element/article) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/article>
*/
export function ARTICLE(
props: ArticleElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions aside.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { AsideElementProps } from "@fartlabs/ht/aside";
import { aside as render } from "@fartlabs/ht/aside";

export type { AsideElementProps };

/**
* ASIDE component renders the [`aside`](https://developer.mozilla.org/docs/Web/HTML/Element/aside) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/aside>
*/
export function ASIDE(
props: AsideElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions audio.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { AudioElementProps } from "@fartlabs/ht/audio";
import { audio as render } from "@fartlabs/ht/audio";

export type { AudioElementProps };

/**
* AUDIO component renders the [`audio`](https://developer.mozilla.org/docs/Web/HTML/Element/audio) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/audio>
*/
export function AUDIO(
props: AudioElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
13 changes: 13 additions & 0 deletions b.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { BElementProps } from "@fartlabs/ht/b";
import { b as render } from "@fartlabs/ht/b";

export type { BElementProps };

/**
* B component renders the [`b`](https://developer.mozilla.org/docs/Web/HTML/Element/b) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/b>
*/
export function B(props: BElementProps & { children?: string[] } = {}): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions base.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { BaseElementProps } from "@fartlabs/ht/base";
import { base as render } from "@fartlabs/ht/base";

export type { BaseElementProps };

/**
* BASE component renders the [`base`](https://developer.mozilla.org/docs/Web/HTML/Element/base) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/base>
*/
export function BASE(
props: BaseElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
}
15 changes: 15 additions & 0 deletions bdi.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { BdiElementProps } from "@fartlabs/ht/bdi";
import { bdi as render } from "@fartlabs/ht/bdi";

export type { BdiElementProps };

/**
* BDI component renders the [`bdi`](https://developer.mozilla.org/docs/Web/HTML/Element/bdi) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/bdi>
*/
export function BDI(
props: BdiElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions bdo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { BdoElementProps } from "@fartlabs/ht/bdo";
import { bdo as render } from "@fartlabs/ht/bdo";

export type { BdoElementProps };

/**
* BDO component renders the [`bdo`](https://developer.mozilla.org/docs/Web/HTML/Element/bdo) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/bdo>
*/
export function BDO(
props: BdoElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
16 changes: 16 additions & 0 deletions big.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { BigElementProps } from "@fartlabs/ht/big";
import { big as render } from "@fartlabs/ht/big";

export type { BigElementProps };

/**
* BIG component renders the [`big`](https://developer.mozilla.org/docs/Web/HTML/Element/big) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/big>
* @deprecated
*/
export function BIG(
props: BigElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions blockquote.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { BlockquoteElementProps } from "@fartlabs/ht/blockquote";
import { blockquote as render } from "@fartlabs/ht/blockquote";

export type { BlockquoteElementProps };

/**
* BLOCKQUOTE component renders the [`blockquote`](https://developer.mozilla.org/docs/Web/HTML/Element/blockquote) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/blockquote>
*/
export function BLOCKQUOTE(
props: BlockquoteElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions body.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { BodyElementProps } from "@fartlabs/ht/body";
import { body as render } from "@fartlabs/ht/body";

export type { BodyElementProps };

/**
* BODY component renders the [`body`](https://developer.mozilla.org/docs/Web/HTML/Element/body) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/body>
*/
export function BODY(
props: BodyElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions br.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { BrElementProps } from "@fartlabs/ht/br";
import { br as render } from "@fartlabs/ht/br";

export type { BrElementProps };

/**
* BR component renders the [`br`](https://developer.mozilla.org/docs/Web/HTML/Element/br) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/br>
*/
export function BR(
props: BrElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest);
}
15 changes: 15 additions & 0 deletions button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { ButtonElementProps } from "@fartlabs/ht/button";
import { button as render } from "@fartlabs/ht/button";

export type { ButtonElementProps };

/**
* BUTTON component renders the [`button`](https://developer.mozilla.org/docs/Web/HTML/Element/button) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/button>
*/
export function BUTTON(
props: ButtonElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions canvas.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { CanvasElementProps } from "@fartlabs/ht/canvas";
import { canvas as render } from "@fartlabs/ht/canvas";

export type { CanvasElementProps };

/**
* CANVAS component renders the [`canvas`](https://developer.mozilla.org/docs/Web/HTML/Element/canvas) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/canvas>
*/
export function CANVAS(
props: CanvasElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions caption.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { CaptionElementProps } from "@fartlabs/ht/caption";
import { caption as render } from "@fartlabs/ht/caption";

export type { CaptionElementProps };

/**
* CAPTION component renders the [`caption`](https://developer.mozilla.org/docs/Web/HTML/Element/caption) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/caption>
*/
export function CAPTION(
props: CaptionElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
16 changes: 16 additions & 0 deletions center.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { CenterElementProps } from "@fartlabs/ht/center";
import { center as render } from "@fartlabs/ht/center";

export type { CenterElementProps };

/**
* CENTER component renders the [`center`](https://developer.mozilla.org/docs/Web/HTML/Element/center) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/center>
* @deprecated
*/
export function CENTER(
props: CenterElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
15 changes: 15 additions & 0 deletions cite.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { CiteElementProps } from "@fartlabs/ht/cite";
import { cite as render } from "@fartlabs/ht/cite";

export type { CiteElementProps };

/**
* CITE component renders the [`cite`](https://developer.mozilla.org/docs/Web/HTML/Element/cite) element.
* @see <https://developer.mozilla.org/docs/Web/HTML/Element/cite>
*/
export function CITE(
props: CiteElementProps & { children?: string[] } = {},
): string {
const { children, ...rest } = props;
return render(rest, ...(children ?? []));
}
Loading

0 comments on commit 79f06ca

Please sign in to comment.