Skip to content

Commit

Permalink
feat: improve ui
Browse files Browse the repository at this point in the history
  • Loading branch information
DerYeger committed Aug 16, 2023
1 parent eb86335 commit f5fbacd
Show file tree
Hide file tree
Showing 32 changed files with 1,493 additions and 484 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-icons-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@yeger/streams': minor
---

implement streams package
5 changes: 5 additions & 0 deletions .changeset/gentle-foxes-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@yeger/debounce': minor
---

add optional args to callback
6 changes: 6 additions & 0 deletions .changeset/slimy-countries-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@yeger/turbo-graph-ui': major
'@yeger/turbo-graph': major
---

re-implement visualization
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"bundlesize": "nr turbo run bundlesize",
"changeset": "changeset",
"ci": "cross-env COVERAGE=true nr turbo run build bundlesize generate lint test check:publish check:tsc check:vue --output-logs=errors-only",
"clean": "rimraf -g **/.tsbuildinfo **/tsconfig.tsbuildinfo",
"dev": "nr turbo run dev --parallel",
"fix": "nr turbo run lint lint:root -- --fix",
"codegen": "nr turbo run codegen",
Expand Down Expand Up @@ -48,6 +49,7 @@
"husky": "8.0.3",
"lint-staged": "13.2.3",
"publint": "0.2.0",
"rimraf": "5.0.1",
"syncpack": "10.9.3",
"turbo": "1.10.12",
"vercel": "31.2.3",
Expand Down
9 changes: 6 additions & 3 deletions packages/debounce/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
* @param delay - A delay after which the callback will be invoked.
* @returns The debounced callback.
*/
export function debounce(cb: () => void, delay?: number) {
export function debounce<Args extends any[]>(
cb: (...args: Args) => void,
delay?: number,
) {
let timeout: any
return () => {
return (...args: Args) => {
if (timeout !== undefined) {
clearTimeout(timeout)
}
timeout = setTimeout(() => cb(), delay)
timeout = setTimeout(() => cb(...args), delay)
}
}
13 changes: 9 additions & 4 deletions packages/streams/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
"sideEffects": false,
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"require": "./dist/index.umd.js",
"import": "./dist/index.mjs"
"import": {
"types": "./dist/types/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/types/index.d.ts",
"default": "./dist/index.umd.js"
}
}
},
"main": "dist/index.umd.js",
Expand All @@ -38,7 +43,7 @@
"devDependencies": {
"@yeger/tsconfig": "workspace:*",
"typescript": "5.1.6",
"vite": "4.4.4",
"vite": "4.4.9",
"vite-plugin-lib": "workspace:*"
},
"publishConfig": {
Expand Down
7 changes: 5 additions & 2 deletions packages/streams/src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ export abstract class Stream<T> implements Iterable<T> {
return new Map(stream)
}

public toRecord(fn: Processor<T, string>): Record<string, T> {
return Object.fromEntries(this.map((x) => [fn(x), x] as const))
public toRecord<U>(
key: Processor<T, string>,
value: Processor<T, U>,
): Record<string, U> {
return Object.fromEntries(this.map((x) => [key(x), value?.(x)] as const))
}

public abstract [Symbol.iterator](): IterableIterator<T>
Expand Down
2 changes: 2 additions & 0 deletions packages/streams/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import process from 'node:process'

import { defineConfig } from 'vite'
import { library } from 'vite-plugin-lib'

Expand Down
1 change: 1 addition & 0 deletions packages/tsconfig/cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"declaration": false,
"module": "CommonJS",
"noEmit": false,
"sourceMap": false
}
}
3 changes: 2 additions & 1 deletion packages/tsconfig/next.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./web.json",
"compilerOptions": {
"noEmit": true,
"incremental": true
"incremental": true,
"plugins": [{ "name": "next" }]
}
}
120 changes: 120 additions & 0 deletions packages/turbo-graph-ui/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 0 0% 4.9%;

--card: 0 0% 100%;
--card-foreground: 0 0% 4.9%;

--popover: 0 0% 100%;
--popover-foreground: 0 0% 4.9%;

--primary: 0 0% 11.2%;
--primary-foreground: 0 0% 98%;

--secondary: 0 0% 96.1%;
--secondary-foreground: 0 0% 11.2%;

--muted: 0 0% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;

--accent: 0 0% 96.1%;
--accent-foreground: 0 0% 11.2%;

--destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 98%;

--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 0 0% 4.9%;

--radius: 0.5rem;
}

.dark {
--background: 0 0% 0%;
--foreground: 0 0% 98%;

--card: 0 0% 4.9%;
--card-foreground: 0 0% 98%;

--popover: 0 0% 4.9%;
--popover-foreground: 0 0% 98%;

--primary: 0 0% 98%;
--primary-foreground: 0 0% 11.2%;

--secondary: 0 0% 17.5%;
--secondary-foreground: 0 0% 98%;

--muted: 0 0% 17.5%;
--muted-foreground: 0 0% 65.1%;

--accent: 0 0% 17.5%;
--accent-foreground: 0 0% 98%;

--destructive: 0 0% 30.6%;
--destructive-foreground: 0 0% 98%;

--border: 0 0% 17.5%;
--input: 0 0% 17.5%;
--ring: hsl(212.7, 0%, 83.9);
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}

.react-flow__edge {
pointer-events: none !important;
}

.react-flow__controls button {
background-color: var(--bg-color);
color: var(--text-color);
border: 1px solid hsl(var(--foreground));
border-bottom: none;
}

.react-flow__controls button:hover {
background-color: hsl(var(--secondary));
}

.react-flow__controls button:first-child {
border-radius: 5px 5px 0 0;
}

.react-flow__controls button:last-child {
border-bottom: 1px solid hsl(var(--foreground));
border-radius: 0 0 5px 5px;
}

.react-flow__controls button path {
fill: hsl(var(--foreground));
}

.react-flow__controls button:disabled path {
fill: hsl(var(--muted-foreground));
}

.react-flow__attribution {
background: hsl(var(--background)) !important;
}

.react-flow__attribution a {
color: hsl(var(--muted-foreground)) !important;
}

.react-flow__minimap {
background: hsl(var(--background)) !important;
}
24 changes: 24 additions & 0 deletions packages/turbo-graph-ui/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { FilterInput, TaskInput } from '../components/GraphInputs'
import './globals.css'

export default function RootLayout({
// Layouts must accept a children prop.
// This will be populated with nested layouts or pages
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en" className="dark h-full w-full">
<body className="m-0 h-full w-full">
<main className="relative flex h-full w-full flex-col">
<div className="absolute left-0 top-0 z-10 flex w-96 max-w-full flex-col gap-2 p-2">
<TaskInput defaultValue="build" />
<FilterInput />
</div>
{children}
</main>
</body>
</html>
)
}
27 changes: 27 additions & 0 deletions packages/turbo-graph-ui/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Metadata } from 'next'

import { Graph } from '../components/Graph'

export const metadata: Metadata = {
title: 'Turbo Graph',
description: 'Interactive visualization of Turborepo task graphs.',
icons: ['/favicon.ico'],
}

export default async function Home({
searchParams,
}: {
searchParams?: { [key: string]: string | string[] | undefined }
}) {
const rawTasks = searchParams?.tasks
const tasks = Array.isArray(rawTasks)
? rawTasks
: rawTasks?.replaceAll(',', ' ')?.split(' ') ?? ['build']
const filter = searchParams?.filter

if (filter && Array.isArray(filter)) {
throw new Error(`Unsupported filter ${filter}`)
}

return <Graph tasks={tasks} filter={filter} />
}
Loading

0 comments on commit f5fbacd

Please sign in to comment.