Skip to content

Commit

Permalink
feat(hiccup-html): add more elems (tables)
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jul 1, 2020
1 parent af290ca commit f0616e6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/hiccup-html/src/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ export interface BlockquoteAttribs extends Attribs {

export const blockquote = defElement<Partial<BlockquoteAttribs>>("blockquote");

export const [div, figure, figcaption, para, pre] = defElements([
export const [div, figure, figcaption, para, pre, template] = defElements([
"div",
"figure",
"figcaption",
"p",
"pre",
"template",
]);

export const hr = defElement<Partial<Attribs>, never>("hr");
Expand Down
1 change: 1 addition & 0 deletions packages/hiccup-html/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from "./inline";
export * from "./lists";
export * from "./media";
export * from "./sections";
export * from "./table";
12 changes: 12 additions & 0 deletions packages/hiccup-html/src/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,15 @@ export interface VideoAttribs extends AudioAttribs, DimensionAttribs {
}

export const video = defElement<Partial<VideoAttribs>>("video");

export interface TrackAttribs extends Attribs {
default: BooleanAttrib;
kind: AttribVal<
"captions" | "chapters" | "descriptions" | "metadata" | "subtitles"
>;
label: StringAttrib;
src: StringAttrib;
srclang: StringAttrib;
}

export const track = defElement<Partial<TrackAttribs>>("track");
34 changes: 34 additions & 0 deletions packages/hiccup-html/src/table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { defElements, defElement } from "./def";
import { NumericAttrib, AttribVal, Attribs } from "./api";

export const [table, tbody, tfoot, thead, tr, caption] = defElements([
"table",
"tbody",
"tfoot",
"thead",
"tr",
"caption",
]);

export interface TableCellAttribs extends Attribs {
colspan: NumericAttrib;
headers: AttribVal<string | string[]>;
rowspan: NumericAttrib;
}

export const td = defElement<Partial<TableCellAttribs>>("td");

export interface TableCellHeaderAttribs extends TableCellAttribs {
scope: AttribVal<"auto" | "col" | "colgroup" | "row" | "rowgroup">;
}

export const th = defElement<Partial<TableCellHeaderAttribs>>("th");

export interface ColAttribs extends Attribs {
span: NumericAttrib;
}

export const [col, colgroup] = defElements<Partial<ColAttribs>>([
"col",
"colgroup",
]);

0 comments on commit f0616e6

Please sign in to comment.