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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@sketchmonk/floating-comment-vue

v0.1.0-alpha.6

Published

A headless component for building figma like floating comments in Vue 3

Readme

FloatingComments Component

The FloatingComments component allows users to add and view comments on specific positions within a container. It provides a dialog for adding comments and displays comments at their respective positions.

Props

  • width: The width of the container.
  • height: The height of the container.

Slots

  • default: The default slot for the content inside the container.
  • dialog: Slot for the dialog that appears when adding a comment.
  • comment: Slot for displaying individual comments.
  • comment-expanded: Slot for displaying an expanded view of a comment.

Example Usage

<template>
  <FloatingComments v-bind="props" v-model:comments="comments">
      <template #default>
          <div class="w-full h-full bg-background">
          </div>
      </template>
      <template #dialog="{ actions, position }">
          <div class="dialog">
              <div class="dialog__title">Add Comment</div>
              <div class="dialog__content">
                  <textarea @keyup.enter="addComment(position); actions.closeDialog()" v-model="content" class="dialog__textarea"></textarea>
              </div>
          </div>
      </template>
      <template #comment="{ comment, actions }">
          <div @click="actions.openComment(comment.id)" class="comment">
              <div class="comment__avatar">
                  {{ comment.data.user.username.charAt(0) }}
              </div>
          </div>
      </template>
      <template #comment-expanded="{ comment }">
          <div class="dialog">
              <div class="dialog__title">{{ comment.data.user.username }}</div>
              <div class="dialog__content">
                  <div class="dialog__description">{{ comment.data.content }}</div>
              </div>
          </div>
      </template>
  </FloatingComments>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { FloatingComments } from 'floating-comment-vue';

const comments = ref([]);
const content = ref('');

const addComment = (position: { x: number, y: number }) => {
    comments.value = [
      ...comments.value,
      {
        id: Math.random().toString(36).substring(7),
        data: {
          user: {
            username: "User",
            profileUrl: "https://avatars.githubusercontent.com/u/1?v=4",
          },
          content: content.value,
          timestamp: new Date().toISOString(),
        },
        position,
      },
    ];
}
</script>

<style lang="css">
* {
    font-family: monospace;
}

:root {
    --background: #defaultd4a373;
    --surface: #fefae0 ;
}

.w-full {
    width: 100%;
}
.h-full {
    height: 100%;
}
.bg-surface {
    background-color: var(--surface);
}
.box {
    border: 3px solid #000;
    box-shadow: 3px 3px 0 #000;
}
.m-4 {
    margin: 1rem;
}

.dialog {
    background-color: var(--surface);
    border: 3px solid #000;
    border-radius: 4px;
    width: 200px;
    box-sizing: border-box;
    box-shadow: 4px 4px 0 #000;
}

.dialog__title {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 8px;
    padding: 0.5rem 1rem;
    border-bottom: 3px solid #000;
    text-align: center;
}

.dialog__content {
    padding: 1rem;
    box-sizing: border-box;
}

.dialog__textarea {
    width: 100%;
    height: 100px;
    padding: 0.5rem;
    box-sizing: border-box;
    font-size: 1rem;
    border: 3px solid #000;
    border-radius: 4px;
}

.dialog__description {
    font-size: 0.875rem;
    opacity: 0.75;
}

.comment {
    width: 40px;
    height: 40px;
    background-color: var(--surface);
    border: 2px solid #000;
    box-shadow: 2px 2px 0 #000;
    border-radius: 50rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.comment::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-top: 2px solid #000;
    border-left: 2px solid #000;
    background-color: var(--surface);
    top: -2px;
    left: -2px;
    z-index: 1;
}

.comment__avatar {
    width: 28px;
    height: 28px;
    font-size: 1rem;
    font-weight: bold;
    background-color: #000;
    color: var(--surface);
    border-radius: 50rem;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
}
</style>