derpycoder
I didn’t think I could do it, but after getting the hang of the Hooks, I have created a tool that I really needed in front-end web development space.
I can barely remember what I worked on today, let alone the file I worked on. So when I get thrown into a project or get asked to work on a web component that was built by my colleagues, I get lost in the labyrinthian code.
Here’s my best attempt at solving that issue:

The tooltip has 2 icons, 1 that leads to the source code, and the other will lead to the Storybook components page. Which I haven’t implemented yet.
Also, this is currently restricted to dev, but I wish to enable it for prod as well. We can enable the inspector like we enable latency sim, and clicking on the show source would open up GitHub/Storybook.
And it works everywhere, see:
P.S. Just stuck figuring out a way to add multiple JS Hook. (I found out a post on Elixir Forum, by someone who figured it out and even did lazy loaded Hook!)
P.P.S. It’s not a library, just changes made across several places. I can paste the whole thing if people want. Took me a while to get the popup to work, but it was worth it.
Inspired by: https://bit.dev (Toggle the inspect button in the top right to hover over each element and see their names and link!)
I suggested this to many people, I really want this to be part of LiveView, or Storybook, or both. (See: Add dev config for injecting HTML comments around function components)
P.S. Here’s the full source code:
Trending in Discussions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
This is fantastic. I really really like this.
I do wonder if there is a way to sort of “layer” this on top of LiveView instead of requiring each component to pass this stuff in.
derpycoder
Exactly my thought.
That’s why I suggested the same in this Git issue: Add dev config for injecting HTML comments around function components
derpycoder
Here’s the code, so others can play around with it, till the Phoenix team adds it to Phoenix 2.0!
Usage
JavaScript Side
source_inspector.jsapp.jsN.B. Don’t forget to add this in the environment variable:
export ELIXIR_EDITOR="code --goto __FILE__:__LINE__"This way, the Beam instance will know to open the VS Code editor!
P.S. I used float-ui, which is the next iteration of Popper.js, for the tooltip.
Just download the ESM files from JS Delivr, i.e.
D4no0
Love the approach! I think that you are into something great, as I think that we failed as developers to find a human-compatible way to build complex systems.
I always loved things like scratch, they present building blocks that are very similar to the way we write code, capable of building complex tings, and it can be operated by a 8 year old kid.
derpycoder
That, plus I have a major qualm with the current state of Web Development:
I wanted to quit this field. But decided to stick around because of Elixir, Phoenix & Live View.
Hope it pans out.
linusdm
This makes me think of a feature that is also in the Smalltalk webframework seaside.st. There it’s called a halo decoration there. You can see it in action here: https://book.seaside.st/book/fundamentals/rendering-components/fun-with-canvas#scrap2
I can remember it was a really nice workflow to be able to toggle between a render mode and source mode. I think one of the buttons also brought you straight to the implementation of the component (in this case, inside the smalltalk image, which is another beast entirely, but it could also work to bring you to the correct file inside your IDE).
In any case, it also made clear how your components were nested, and what the structure was of your entire page.
D4no0
This is something that is present in a lot of google products, one that I closely hate is the native android development.
Sometimes I have a feeling that all the new features and ways to write code are designed in an agile system, kind of a innovation with timelines, witch is not only stupid sounding, but impossible to achieve.
derpycoder
That’s awesome.
Being able to toggle the editor view and the rendered view. (Kind of like LiveBook 2.0.)
So, we see the components we build, then inline make the change to the code, and then render and the source code is replaced with the rendered view.
Then all the changes we make in the browser-based IDE are written back to the file. So we won’t even have to jump back to the VS Code or any other external IDE.
Just REPL it directly on the browser.
linusdm
It’s closely related to what’s called REPL-driven-development. I don’t know if Elixir is capable of what’s being described in that article (e.g. with the breakloop) and can stand next to Smalltalk and lisp/Clojure in that regard.
derpycoder
Actually, Jose Valim intends to build real-time code, REPL-based development. See:
https://github.com/livebook-dev/livebook/issues/1351