Skip to content

Commit

Permalink
Merge pull request #1 from thefrontside/very-basic-svg-package
Browse files Browse the repository at this point in the history
Add very basic SVG package
  • Loading branch information
cowboyd authored Oct 13, 2023
2 parents 35799ca + 4f8e69c commit c5de0f5
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deps.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type * from "https://esm.sh/v127/@types/hast@2.3.4/index.d.ts";
export type * from "npm:@types/hast@2.3.4";
9 changes: 6 additions & 3 deletions jsx-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type * as hast from "./deps.ts";
import type * as html from "./html.ts";
import type * as svg from "./svg.ts";

export type Element = hast.Element;

Expand All @@ -26,10 +27,12 @@ export interface JSXElementConstructor {
declare global {
namespace JSX {
type Element = JSXElement;
type ElementType = keyof html.HTMLElements | JSXElementConstructor;
type ElementType =
| keyof html.HTMLElements
| keyof svg.SVGElements
| JSXElementConstructor;

//deno-lint-ignore no-empty-interface
interface IntrinsicElements extends html.HTMLElements {}
interface IntrinsicElements extends html.HTMLElements, svg.SVGElements {}
interface ElementChildrenAttribute {
//deno-lint-ignore ban-types
children: {};
Expand Down
161 changes: 161 additions & 0 deletions svg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import type * as hast from "./deps.ts";

export type SVGChild =
| string
| number
| boolean
| hast.Element
| hast.Root
| hast.Text;

export type SVGChildren = SVGChild | Iterable<SVGChild>;

export interface SVGElement extends SVGAttributes, SVGPresentationAttributes {
children?: SVGChildren;
}

export interface SVGAttributes {
// accesskey?: string;
// autocapitalize?: "off" | "none" | "on" | "setences" | "words" | "characters";
class?: string;
// contenteditable?: "true" | "false" | "plaintext-only";
// dir?: "ltr" | "rtl" | "auto";
// draggable?: "true" | "false";
// enterkeyhint?:
// | "enter"
// | "done"
// | "go"
// | "next"
// | "previous"
// | "search"
// | "send";
// hidden?: "hidden" | "until-found";
id?: string;
// inert?: boolean;
// inputmode?:
// | "none"
// | "text"
// | "decimal"
// | "numeric"
// | "tel"
// | "search"
// | "email"
// | "url";
// is?: string;
// itemid?: string;
// itemprop?: string;
// itemref?: string;
// itemscope?: string;
// itemtype?: string;
// lang?: string;
// nonce?: string;
// spellcheck?: "true" | "false" | "default";
style?: string;
tabindex?: number;
// title?: string;
// translate?: "yes" | "no";
}

export interface SVGPresentationAttributes extends SVGAttributes {
"clip-path"?: string;
"lip-rule"?: string;
color?: string;
"color-interpolation"?: string;
"color-rendering"?: string;
cursor?:
| "auto"
| "crosshair"
| "default"
| "pointer"
| "move"
| "e-resize"
| "ne-resize"
| "nw-resize"
| "n-resize"
| "se-resize"
| "sw-resize"
| "s-resize"
| "w-resize"
| "text"
| "wait"
| "help"
| "inherit"
| string;
display?: string;
fill?: string;
"fill-rule"?: string;
filter?: string;
mask?: string;
opacity?: string;
"pointer-events"?:
| "bounding-box"
| "visiblePainted"
| "visibleFill"
| "visibleStroke"
| "visible"
| "painted"
| "fill"
| "stroke"
| "all"
| "none";
"shape-rendering"?:
| "auto"
| "optimizeSpeed"
| "crispEdges"
| "geometricPrecision";
stroke?: string;
"stroke-dasharray"?: string;
"stroke-dashoffset"?: string;
"stroke-linecap"?: "butt" | "round" | "square";
"stroke-linejoin"?: "arcs" | "bevel" | "miter" | "miter-clip" | "round";
"stroke-miterlimit"?: string | number;
"stroke-opacity"?: string | number;
"stroke-width"?: string | number;
transform?: string;
"vector-effect"?:
| "none"
| "non-scaling-stroke"
| "non-scaling-size"
| "non-rotation"
| "fixed-position";
visibility?: "visible" | "hidden" | "collapse";
}

export interface SVGSVG extends SVGElement {
xmlns?: "http://www.w3.org/2000/svg";
height?: string;
preserveAspectRation?: string;
viewBox?: string;
width?: string;
x?: string;
y?: string;
}

export interface SVGAnimate extends SVGElement {
begin?: string;
}

export interface SVGPath extends SVGElement {
d: string;
pathLength?: number;
}

export interface SVGRect extends SVGElement {
height?: string | number;
width?: string | number;
x?: string | number;
y?: string | number;
rx?: string | number;
ry?: string | number;
pathLength?: string | number;
}

export interface SVGElements {
svg: SVGSVG;
animate: SVGAnimate;
path: SVGPath;
g: SVGElement;
defs: SVGElement;
clipPath: SVGElement;
rect: SVGRect;
}

0 comments on commit c5de0f5

Please sign in to comment.