Skip to content

Commit

Permalink
upgrade and reorg types
Browse files Browse the repository at this point in the history
  • Loading branch information
sidiousvic committed Jul 20, 2020
1 parent 1112df2 commit 40de6b4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
8 changes: 2 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import phantom from "./phantom";
import createPhantomStore from "./createPhantomStore";
// types
export {
PhantomElement,
PhantomDOMFunction,
PhantomDOM,
} from "./types/phantomDOM"; // phantomDOM
export { PhantomElement, PhantomComponent, PhantomDOM } from "./types/phantom";
export {
PhantomAction,
PhantomReducer,
Subscription,
} from "./types/phantomStore"; // phantomStore
} from "./types/phantomStore";

export { createPhantomStore };
export default phantom;
15 changes: 9 additions & 6 deletions src/phantom.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { PhantomStore } from "./types/phantomStore";
import { Phantom } from "./types/phantom";

import {
PhantomDOMFunction,
Phantom,
PhantomComponent,
PhantomDOM,
PhantomElement,
} from "./types/phantomDOM";
} from "./types/phantom";

import phantomExorciser from "./phantomExorciser";

function PHANTOM(phantomStore: PhantomStore, PhantomDOM: PhantomDOMFunction) {
function PHANTOM(
phantomStore: PhantomStore,
phantomComponent: PhantomComponent
) {
let phantomDOM: PhantomDOM = {
test: {
tagName: "div",
Expand Down Expand Up @@ -40,7 +43,7 @@ function PHANTOM(phantomStore: PhantomStore, PhantomDOM: PhantomDOMFunction) {
function coalescePhantomDOM() {
return `
<div id="PHANTOM">
${PhantomDOM()}
${phantomComponent()}
</div>
`;
}
Expand Down
19 changes: 17 additions & 2 deletions src/types/phantom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@ import {
PhantomStore,
FireFunction,
} from "./phantomStore";
import { PhantomDOMFunction } from "./phantomDOM";

export type PhantomElement = {
tagName: string;
attributes: { id?: string | number; class?: string | DOMTokenList };
children: PhantomElement[] | [];
innerHTML: string;
dataset?: DOMTokenList | {};
};

export type PhantomComponent = {
(): string;
};

export type PhantomDOM = {
[key: string]: PhantomElement;
};

export type Phantom = {
(phantomStore: PhantomStore, phantomElement: PhantomDOMFunction): {
(phantomStore: PhantomStore, phantomElement: PhantomComponent): {
fire: FireFunction;
data: () => any;
appear: () => HTMLElement;
Expand Down
15 changes: 0 additions & 15 deletions src/types/phantomDOM.ts

This file was deleted.

0 comments on commit 40de6b4

Please sign in to comment.