-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
120 changed files
with
7,510 additions
and
7,841 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { SeqflowFunctionContext } from "seqflow-js"; | ||
|
||
async function Button(this: SeqflowFunctionContext, data: { text: string }) { | ||
this.renderSync(<button type="button">{data.text}</button>); | ||
} | ||
|
||
export async function Main(this: SeqflowFunctionContext) { | ||
let counter = 0; | ||
const incrementButton = <Button text="Increment" />; | ||
const decrementButton = <Button text="Decrement" />; | ||
const counterDiv = <div>{counter}</div>; | ||
this.renderSync( | ||
<> | ||
<div> | ||
{decrementButton} | ||
{incrementButton} | ||
</div> | ||
{counterDiv} | ||
</>, | ||
); | ||
|
||
const events = this.waitEvents( | ||
this.domEvent("click", { el: this._el as HTMLElement }), | ||
); | ||
for await (const ev of events) { | ||
if (incrementButton.contains(ev.target)) { | ||
counter++; | ||
} else if (decrementButton.contains(ev.target)) { | ||
counter--; | ||
} | ||
|
||
counterDiv.textContent = `${counter}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2015", "dom"], | ||
"jsx": "react", | ||
"jsxFactory": "this.createDOMElement", | ||
"jsxFragmentFactory": "this.createDOMFragment" | ||
}, | ||
"include": ["./src/**/*", "./tests/**/*"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { SeqflowFunctionContext } from "seqflow-js"; | ||
import { | ||
CounterChanged, | ||
CounterDomain, | ||
CounterReset, | ||
components, | ||
} from "./domains/counter"; | ||
|
||
import "./index.css"; | ||
|
||
export async function Main(this: SeqflowFunctionContext) { | ||
const counter = this.app.domains.counter.get(); | ||
|
||
const decrement = ( | ||
<components.ChangeCounterButton delta={-1} text={"Decrement"} /> | ||
); | ||
const increment = ( | ||
<components.ChangeCounterButton delta={1} text={"Increment"} /> | ||
); | ||
const reset = <components.ResetCounterButton />; | ||
const counterDiv = <div>{counter}</div>; | ||
this.renderSync( | ||
<> | ||
<div /> | ||
<div id="counter-card"> | ||
<div id="actions"> | ||
{decrement} | ||
<div /> | ||
{increment} | ||
<div /> | ||
{reset} | ||
</div> | ||
{counterDiv} | ||
</div> | ||
<div /> | ||
</>, | ||
); | ||
|
||
const events = this.waitEvents( | ||
this.domainEvent(CounterChanged), | ||
this.domainEvent(CounterReset), | ||
); | ||
for await (const ev of events) { | ||
counterDiv.textContent = `${ev.detail.counter}`; | ||
} | ||
} | ||
|
||
declare module "seqflow-js" { | ||
interface Domains { | ||
counter: CounterDomain; | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
examples/counter-domain/src/domains/counter/components/ChangeCounterButton.ts
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
examples/counter-domain/src/domains/counter/components/ChangeCounterButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { SeqflowFunctionContext } from "seqflow-js"; | ||
|
||
export async function ChangeCounterButton( | ||
this: SeqflowFunctionContext, | ||
data: { delta: number; text: string }, | ||
) { | ||
this.renderSync(<button type="button">{data.text}</button>); | ||
const events = this.waitEvents( | ||
this.domEvent("click", { el: this._el as HTMLElement }), | ||
); | ||
for await (const _ of events) { | ||
this.app.domains.counter.applyDelta(data.delta); | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
examples/counter-domain/src/domains/counter/components/ResetCounterButton.ts
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
examples/counter-domain/src/domains/counter/components/ResetCounterButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { SeqflowFunctionContext } from "seqflow-js"; | ||
|
||
export async function ResetCounterButton(this: SeqflowFunctionContext) { | ||
this.renderSync(<button type="button">Reset</button>); | ||
const events = this.waitEvents( | ||
this.domEvent("click", { el: this._el as HTMLElement }), | ||
); | ||
for await (const _ of events) { | ||
this.app.domains.counter.reset(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2015", "dom"], | ||
"jsx": "react", | ||
"jsxFactory": "this.createDOMElement", | ||
"jsxFragmentFactory": "this.createDOMFragment" | ||
}, | ||
"include": ["./src/**/*", "./tests/**/*"] | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.