開発者ツール2024

React UI Component Browser

自動インポート付きのワンクリックコンポーネント挿入、ライブプレビュー、整理されたカテゴリ閲覧を実現。

rohith-a.me/projects/proj-4
01

課題

開発者がエディタを離れずにReact UIコンポーネントを素早く検索・プレビュー・挿入したい。

02

アプローチ

ツリービューブラウザ、ライブWebviewプレビュー、クイック挿入、設定可能なパスからのコンポーネント自動検出を備えたVS Code拡張機能を作成。

システム設計

React UI Component Browser の構成

技術アーキテクチャの説明は英語です。

A VS Code extension that indexes a component folder on disk, previews components in a webview and writes import-aware code into the active editor.

commands
7
tree views + 1 webview
2

01 · VS Code UI

client

Components tree

tree view

client

Quick Snippets

tree view

client

Preview panel

webview

02 · Extension host

gateway

Extension host

7 commands

service

Component scanner

glob + prop parsing

service

Component inserter

merges imports

03 · Workspace

object store

Component folder

set in settings

client

Active editor

clientgatewayserviceobject store

8 connections

  • Components tree→Extension hostselect
  • Quick Snippets→Extension hostinsert snippet
  • Preview panel→Extension hostinsert · copy
  • Extension host→Preview panelrender · async
  • Extension host→Component scanner
  • Component scanner→Component folderglob · read
  • Extension host→Component inserter
  • Component inserter→Active editoredit + import

Request flow · Browsing and inserting a component

  1. 1The scanner globs the configured folder and parses each file’s props into the tree.
  2. 2Selecting a component opens the webview preview with its variants.
  3. 3Insert posts back to the host; the inserter adds the usage at the cursor and merges the import into an existing one when present.

Design decisions

Props from source
Props are parsed from the component files themselves, so the browser stays accurate without a separate manifest.
Import merging
Inserting a second component from the same module extends the existing import instead of adding a duplicate line.

Trade-offs & known limits

  • Prop parsing is pattern-based rather than a full TypeScript AST, so unusual prop declarations may be missed.

同じようなプロジェクトをお考えですか?

フリーランス・業務委託のご依頼を受け付けています。お気軽にご相談ください。