Skip to content

Commit

Permalink
add github badge to landing page and a example button (#16)
Browse files Browse the repository at this point in the history
* remove package and add github with star count

* remove package and add github with star count
  • Loading branch information
Anshgrover23 authored Jan 30, 2025
1 parent 4dcd178 commit bcd6dab
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 10 deletions.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,36 @@ const graphicsObjects = getGraphicsObjectsFromLogString(logString)
// Array<GraphicsObject>
```

### Example Graphics JSON

An example graphics JSON file is provided in the repository to help you get started quickly.

You can find the example file at [`site/examples/exampleGraphics.json`](site/examples/exampleGraphics.json). This file contains a sample graphics object that you can use to test the functionality of the `graphics-debug` module.

Here is the content of the `exampleGraphics.json` file:

```JSON
{
"title": "Example Usage",
"rects": [
{
"center": { "x": 0, "y": 0 },
"width": 100,
"height": 100,
"fill": "green"
}
],
"points": [
{
"x": 50,
"y": 50,
"color": "red",
"label": "Test Output!"
}
]
}
```

```
You can load this example into the application to visualize the graphics objects and understand how the `graphics-debug` module works.


19 changes: 19 additions & 0 deletions site/examples/exampleGraphics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"title": "Example Usage",
"rects": [
{
"center": { "x": 0, "y": 0 },
"width": 100,
"height": 100,
"fill": "green"
}
],
"points": [
{
"x": 50,
"y": 50,
"color": "red",
"label": "Test Output!"
}
]
}
29 changes: 20 additions & 9 deletions site/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from "react"
import exampleGraphicsJson from "../examples/exampleGraphics.json"
import {
getSvgsFromLogString,
getGraphicsObjectsFromLogString,
Expand Down Expand Up @@ -39,9 +40,21 @@ export default function Home() {

return (
<div className="space-y-8">
<div className="prose">
<h1>Graphics Debug Viewer</h1>
<p>Paste your debug output below to visualize graphics objects.</p>
<div className="flex justify-between items-start">
<div className="prose">
<h1>Graphics Debug Viewer</h1>
<p>Paste your debug output below to visualize graphics objects.</p>
</div>
<a
href="https://github.com/tscircuit/graphics-debug"
target="_blank"
rel="noopener noreferrer"
>
<img
src="https://img.shields.io/github/stars/tscircuit/graphics-debug?style=social"
alt="GitHub stars"
/>
</a>
</div>
<form onSubmit={handleSubmit} className="space-y-4">
<textarea
Expand All @@ -63,14 +76,12 @@ export default function Home() {
</button>
<button
type="button"
onClick={() => {
setInput(
`:graphics {"title":"Example Usage","rects":[{"center":{"x":0,"y":0},"width":100,"height":100,"color":"green"}],"points":[{"x":50,"y":50,"color":"red","label":"Test Output!"}]} :graphics {"title":"More Example Usage","lines":[{"points":[{"x":0,"y":0},{"x":5,"y":5}]}],"circles":[{"center":{"x":2.5,"y":2.5},"radius":2.5,"color":"blue"}],"points":[{"x":10,"y":10,"color":"red","label":"B"}]}`,
)
}}
onClick={() =>
setInput(`:graphics ${JSON.stringify(exampleGraphicsJson)}`)
}
className="px-4 py-2 bg-gray-600 text-white rounded hover:bg-gray-700"
>
See Example
Load Example
</button>
</div>
</form>
Expand Down

0 comments on commit bcd6dab

Please sign in to comment.