Skip to content

A Chromium browser plugin to inspect rendered React components and find the associated code!

Notifications You must be signed in to change notification settings

dankoster/figment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Figment

Figment is a developer tool to inspect rendered React components and find the related sorce code!

It lets you inspect the UI to quickly figure out what code is rendering what you see. You can just click the provided link to open the source in VS Code.

Get it from the chrome web store!

figment.0.5.demo.mov

This tool has no dependencies. It's all browser APIs and Vanilla JavaScript with TypeScript to help keep things on the rails. Every bit of functionality was written by me because I'm just tinkering, it's just for fun, and I learn best by making something I find useful. If you would like a feature that doesn't exist, just let me know and I'll take a look. Or you can submit a PR.

I'm currently tinkering with a Figma integration to help correlate React components with Figma designs.

Usage

  1. Open a page on localhost that is using a dev build of React or React Native. Production React will likely be minified and not include source file mappings. I am currently limiting this tool (in the manifest) to only function for localhost.
  2. Toggle enabled/disabled
    • Use the hotkey ALT-f (⌥-f on Mac) (configure here: chrome://extensions/shortcuts)
    • OR click the Figment toolbar icon
    • OR chose "Toggle DOM Inspection" from the browser context menu
  3. Mouse over the page to see elements and components highlighted with a red outline
  4. Click the red outline's label to get the context menu

The context menu that pops up will show you the element/component you are inspecting as well as all of it's parent element/components. A link to the source code will be provided for each element/component where React has provided that information.

Recent & upcoming work

Screen.Recording.2024-03-29.at.5.17.27_PM.mov

Sidepanel stuff

  • Figma integration (wip)
    • Keep Figma API key in local storage (prompt for key if missing)
    • Load Figma data into local storage when visiting a Figma page
    • Get Figma images
    • Keep Figma data synchronized
    • Drag Figma image onto localhost page
    • Manage local Figma docs (list, add, delete)
    • Separate sidepanel pages for managing and using Figma data
    • Functionality to link Figma designs to React components
    • Full text search
    • Favorites/bookmarks?
    • Filter by "Ready for Dev"
    • Filter by designs relevant to the current page?
  • CSS styles for everything
  • Sidepanel Header/Tabs
  • Sidepanel toggle logic
  • React sidepanel
    • List all react components on the page with vsCode links
    • Functionality to link React components to Figma designs
  • Configuration options sidepanel

Menu stuff

  • Menu toolbar
    • option to stop inspecting the DOM
    • option to open/close the sidebar
  • Add Submenus
  • Submenu open/close css animations
  • Scroll behavior
    • Move the menu with the page
    • Move submenus with their parent menu items when scrolling inside the menu
    • Programmatically adjust menu max-height to avoid scrolling for less than a minimum number of items
  • Submenu positioning
    • Slide submenus left to prevent overflowing the right side of the page
    • Make submenus appear on the left of their parents if they would overlap the main menu enough to cover other functionality
  • Submenu mouse interaction refinement
    • allow "shortcutting" over other menu items if the mouse is headed toward an open submenu

Other

  • Display other react info for selected components
  • Custom browser protocols for opening files (currently only suppoprts vscode://file:line:character)

Install (for development)

We're keeping it simple and using just JavaScript, HTML, and CSS. I have intentionally avoided dependencies except for git and TypeScript. We really don't need a package manager or build tool for a project of this size.

  1. Clone the repo locally: git clone https://github.com/dankoster/figment.git
  2. Navigate to the folder that was created by git: cd figment
  3. Run the terminal command: mkdir -p dist && cp -rv ./assets/* ./dist && tsc
    • mkdir -p dist makes the dist folder
    • cp -rv ./assets/* ./dist verbosely copies the contents of the assets folder into dist
    • tsc compiles the typescript to the dist folder
  4. Open chrome://extensions/ in your chromium browser
  5. Turn on "Developer Mode"
  6. Click the "Load unpacked" button
  7. Choose the figment/dist folder
  8. Find the figment extension in your browser extensions toolbar and pin it
  9. Have fun hacking!
    • Use tsc -w to watch for changes while working
    • Use cp -rv ./assets/* ./dist to copy asset files into dist (or use the included Deno script to watch and copy those asset files when they change... deno run --allow-read --allow-write watchAndCopy.ts ./assets ./dist)

About

A Chromium browser plugin to inspect rendered React components and find the associated code!

Resources

Stars

Watchers

Forks

Releases

No releases published