-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Finalize blog post. Add tests. (#1436)
* Update deps. * Update layout. * Finalize blog post. * Fix tests. * Use millis.
- Loading branch information
Showing
16 changed files
with
257 additions
and
112 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
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
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
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 |
---|---|---|
@@ -1,11 +1,61 @@ | ||
/* eslint-disable node/no-unsupported-features/node-builtins */ | ||
|
||
import './app.css'; | ||
import { useState } from 'preact/hooks'; | ||
import { Graph } from './components/Graph'; | ||
|
||
const SUPPORTED_LAYOUTS = ['dagre', 'klay', 'breadthfirst', 'grid']; | ||
|
||
function getLayoutFromQuery(): string { | ||
let layout = new URLSearchParams(window.location.search).get('layout'); | ||
|
||
if (!layout || !SUPPORTED_LAYOUTS.includes(layout)) { | ||
layout = 'dagre'; | ||
} | ||
|
||
return layout; | ||
} | ||
|
||
function setLayoutIntoQuery(layout: string) { | ||
const query = new URLSearchParams(window.location.search); | ||
query.set('layout', layout); | ||
|
||
// Doesn't reload the page | ||
window.history.pushState(null, '', `${window.location.pathname}?${query}`); | ||
} | ||
|
||
export function App() { | ||
const [layout, setLayout] = useState(getLayoutFromQuery()); | ||
|
||
function handleChange(event: Event) { | ||
const target = event.target as HTMLSelectElement; | ||
const newLayout = target.value; | ||
|
||
setLayout(newLayout); | ||
setLayoutIntoQuery(newLayout); | ||
} | ||
|
||
return ( | ||
<main> | ||
<div className="p-4 flex items-center float-right"> | ||
<span className="inline-block mr-1">Layout:</span> | ||
|
||
<select | ||
className="border border-slate-400 rounded bg-slate-600 text-slate-50 p-1" | ||
value={layout} | ||
onChange={handleChange} | ||
> | ||
{SUPPORTED_LAYOUTS.map((value) => ( | ||
<option key={value} value={value}> | ||
{value} | ||
</option> | ||
))} | ||
</select> | ||
</div> | ||
|
||
<h2 className="m-0 p-4 text-3xl font-extrabold sm:text-4xl">{window.PAGE_TITLE}</h2> | ||
<Graph /> | ||
|
||
<Graph layout={layout} /> | ||
</main> | ||
); | ||
} |
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
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,15 @@ | ||
platform: 'node' | ||
|
||
tasks: | ||
run1: | ||
command: 'node ./sleep.mjs' | ||
options: | ||
mutex: 'test-lock' | ||
run2: | ||
command: 'node ./sleep.mjs' | ||
options: | ||
mutex: 'test-lock' | ||
run3: | ||
command: 'node ./sleep.mjs' | ||
options: | ||
mutex: 'test-lock' |
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 @@ | ||
await new Promise((resolve) => setTimeout(resolve, 3000)); |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.