egraphs-good / egglog

egraphs + datalog!
https://egraphs-good.github.io/egglog/
MIT License
458 stars 54 forks source link

Add support for the interactive visualizer #426

Closed saulshanabrook closed 1 month ago

saulshanabrook commented 2 months ago

This PR adds the ability to try the new interactive visualizer in the web editor. I still kept the original graphviz visualizer as default, while this while let you switch between them:

https://github.com/user-attachments/assets/820529fe-d56c-46f7-a5bc-34b5f157b1a3

The new visualizer includes the following features compared to the existing editor:

Moreover, it can serve as a base to build future interactive features that would be helpful.

saulshanabrook commented 1 month ago

I have updated this PR to support transitioning between multiple e-graphs, the last thing I wanted to add before calling the visualizer good for now!

https://github.com/user-attachments/assets/561cd4a0-7f49-46ba-a10f-8c24381d24ed

If anyone could try this locally and make sure it works, then we can get this in. Thanks!

yihozhang commented 1 month ago

This PR seems to make some unintended style changes to the entire web demo (font, font size, alignments, button styles, etc).

Before:

image

After:

image
saulshanabrook commented 1 month ago

Yes, it does! I thought they mainly were fine, except it's just not great when the buttons wrap. That's based on your screen size and the addition of the extra toggle.

I think the changes are from using tailwindcss to style the visualizer and it pulls in some "pre-flight" styles:

Built on top of modern-normalize, Preflight is a set of base styles for Tailwind projects that are designed to smooth over cross-browser inconsistencies and make it easier for you to work within the constraints of your design system.

yihozhang commented 1 month ago

@saulshanabrook I see! Thanks for the explanation. Some differences I noticed

  1. Font size increases a bit in general
  2. The font weight used in the code editor is lighter
  3. Spacing between lines in the code editor is wider
  4. The buttons and dropdown menus are less recognizable (e.g., no background, no border)
  5. The button wraps at the end (although this goes away if I further zoom out).

1 and 2 seem fine, I'm not sure about 3 (the original spacing looks slightly more natural), and I think we should fix 4 and 5. What do you think?

saulshanabrook commented 1 month ago

Thanks @yihozhang!

I published a new version that limited the preflight styles to just my component (using this) and I think it fixed it?

Screenshot 2024-10-16 at 9 09 36 PM

For reference I had to purge the JS cache of these two URLs after publishing to load the new one:

https://cdn.jsdelivr.net/npm/egraph-visualizer@2/dist/style.css
https://cdn.jsdelivr.net/npm/egraph-visualizer@2/+esm
yihozhang commented 1 month ago

Yes, thank you!! @saulshanabrook