npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pie-players/pie-tool-toolbar

v0.1.5

Published

Tool panel toolbar for PIE assessment player - displays and manages tool buttons

Downloads

391

Readme

Tool Toolbar (<pie-tool-toolbar>)

A self-contained tool management component that handles everything: instantiates tools, manages their state, and renders the toolbar UI. Clients can drop it in without any setup.

Overview

The Tool Toolbar is a complete tool orchestration system that:

  • Instantiates all configured tool components
  • Manages tool visibility via toolCoordinator store
  • Renders toolbar UI with buttons
  • Handles annotation toolbar (text selection tools)
  • Coordinates z-index and tool lifecycle

Zero-Setup Usage

Minimal Example

<pie-tool-toolbar></pie-tool-toolbar>

That's it! This gives you all tools with default configuration.

Custom Tool Selection

<pie-tool-toolbar tools="protractor,ruler,graph"></pie-tool-toolbar>

As Svelte Component

<script>
  import ToolToolbar from '$lib/tags/tool-toolbar';

  function handleDictionary(detail) {
    console.log('Dictionary lookup:', detail.text);
  }
</script>

<ToolToolbar
  tools="protractor,ruler,lineReader,graph,periodicTable"
  position="right"
  ondictionarylookup={handleDictionary}
/>

What It Includes

The toolbar automatically manages these tools:

Tier 1 Tools (Measurement & Visualization)

  • Protractor - Angle measurement
  • Ruler - Length measurement
  • Line Reader - Reading guide overlay
  • Graph - Coordinate plane with graphing
  • Periodic Table - Element reference

Tier 2 Tools (Text Annotation)

  • Annotation Toolbar - Appears on text selection
    • Dictionary lookup
    • Translation request
    • Picture dictionary

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | tools | String | All tools | Comma-separated tool IDs to enable | | disabled | Boolean | false | Disables all buttons | | position | 'left' \| 'right' | 'right' | Toolbar placement | | showLabels | Boolean | false | Show text labels under icons |

Event Callbacks (Annotation Toolbar)

| Callback | Type | Description | |----------|------|-------------| | ondictionarylookup | (detail: {text}) => void | Fired when user selects dictionary | | ontranslationrequest | (detail: {text}) => void | Fired when user requests translation | | onpicturedictionarylookup | (detail: {text}) => void | Fired for picture dictionary |

Available Tools

Tool IDs you can use in the tools prop:

  • protractor - Angle measuring tool ✅
  • ruler - Length measuring tool ✅
  • lineReader - Reading guide overlay ✅
  • graph - Coordinate plane ✅
  • periodicTable - Element reference ✅
  • calculator - Basic calculator ⚠️ Not yet implemented
  • highlighter - Text highlighting ⚠️ Not yet implemented (use annotation toolbar instead)

Note: Text-to-Speech is integrated into the annotation toolbar (shown when text is selected), not as a standalone tool.

Architecture

┌──────────────────────────────────┐
│ <pie-tool-toolbar>               │
│  Self-Contained Component        │
├──────────────────────────────────┤
│ ┌──────────────┐ ┌─────────────┐ │
│ │ Toolbar UI   │ │ Tool Store  │ │
│ │ - Buttons    │ │ (Reactive)  │ │
│ │ - State      │←┤             │ │
│ └──────────────┘ └─────────────┘ │
│                                   │
│ ┌─────────────────────────────┐  │
│ │ Tool Instances              │  │
│ │ <ToolProtractor />          │  │
│ │ <ToolRuler />               │  │
│ │ <ToolGraph />               │  │
│ │ ...                         │  │
│ └─────────────────────────────┘  │
│                                   │
│ ┌─────────────────────────────┐  │
│ │ <AnnotationToolbar />       │  │
│ │ (Text selection tools)      │  │
│ └─────────────────────────────┘  │
└──────────────────────────────────┘

No External Dependencies

Unlike typical toolbars, you don't need:

  • ❌ Separate tool manager component
  • ❌ Manual tool instantiation
  • ❌ State management setup
  • ❌ Event wiring

Everything is built-in!

Styling

The toolbar uses CSS custom properties:

--tool-toolbar-bg
--tool-toolbar-border
--tool-toolbar-button-bg
--tool-toolbar-button-hover-bg
--tool-toolbar-button-active-bg
--tool-toolbar-focus-color

How It Works

  1. Parse tools prop → Determines which tools to enable
  2. Subscribe to toolCoordinator → Reactive state management
  3. Build button config → Icons, names, toggle functions
  4. Render toolbar UI → Buttons with active states
  5. Instantiate tools → Only render visible tool components
  6. Handle events → Forward annotation toolbar events

Real-World Example

<!-- Assessment Player -->
<script>
  import ToolToolbar from '$lib/tags/tool-toolbar';

  let showDictionaryModal = false;
  let selectedText = '';

  function openDictionary(detail) {
    selectedText = detail.text;
    showDictionaryModal = true;
  }
</script>

<div class="assessment-layout">
  <main>
    <!-- Question content -->
  </main>

  <ToolToolbar
    tools="protractor,ruler,graph"
    ondictionarylookup={openDictionary}
  />
</div>

{#if showDictionaryModal}
  <DictionaryModal {selectedText} />
{/if}

Browser-Only

This component requires browser APIs and will not render during SSR. It's wrapped in {#if browser} internally.

Custom Element Tag

<pie-tool-toolbar>

  • Compiled with shadow: 'none' for Light DOM rendering
  • Works in any framework or vanilla JS
  • Manages all tool lifecycle internally