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

@ecss/vue-adapter

v0.2.0

Published

ECSS Vue adapter — generates Vue 3 components from ECSS blocks.

Readme

<script setup lang="ts">
import { EButton } from './Button.ecss';
</script>

<template>
  <EButton as="button" :params="{ variant: 'primary' }" @click="onClick">
    Нажми меня
  </EButton>
</template>

📦 Установка

npm i -D @ecss/vue-adapter
pnpm add -D @ecss/vue-adapter
yarn add -D @ecss/vue-adapter

Требуется установленный vue версии 3.3 или выше.


🚀 Подключение

Адаптер регистрируется в ecss.config.ts через defineConfig из @ecss/config — конфиг не привязан к конкретному сборщику, его читает ECSS-плагин вашего бандлера (@ecss/vite-plugin и др.). defaultAdapter указывает, какой адаптер применяется к .ecss-файлам по умолчанию; id Vue-адаптера — 'vue':

// ecss.config.ts
import { defineConfig } from '@ecss/config';
import { vueAdapter } from '@ecss/vue-adapter';

export default defineConfig({
  adapters: [vueAdapter()],
  defaultAdapter: 'vue',
});

🛠 Использование

Каждый @block превращается в функциональный компонент Vue 3, который импортируется напрямую из .ecss-файла:

<script setup lang="ts">
import { EButton } from './Button.ecss';
</script>

<template>
  <EButton as="button" :params="{ variant: 'primary' }"> Нажми меня </EButton>
</template>

Имя компонента — это префикс + имя блока: @block ButtonEButton, @block CardECard. Содержимое компонента передаётся через слот по умолчанию (всё, что между тегами).

Проп params

Параметры блока передаются единственным пропом params (в шаблоне — через привязку :params). TypeScript знает их типы из сгенерированного интерфейса {Block}Params (например ButtonParams), поэтому передать несуществующее значение enum не получится.

params обязателен ровно тогда, когда у блока есть хотя бы один обязательный @param (без ?). Если все параметры опциональны или их нет вовсе — проп можно не передавать.

<!-- у Button есть обязательный @param variant → params обязателен -->
<EButton :params="{ variant: 'primary' }" />

<!-- у Card все параметры опциональны → params можно опустить -->
<ECard />

Проп as

По умолчанию компонент рендерится как <div>. Проп as принимает любой HTML-тег и меняет корневой элемент. Компонент типизирован generic-параметром по выбранному тегу (через IntrinsicElementAttributes), поэтому набор допустимых HTML-атрибутов сужается автоматически:

<EButton
  as="button"
  type="submit"
  :params="{ variant: 'primary' }"
>Отправить</EButton>

<EButton as="a" href="/about" :params="{ variant: 'ghost' }">Ссылка</EButton>

При as="a" становятся доступны href, target и прочие атрибуты <a>; при as="button"type, disabled и т.д.

class, style и атрибуты

ECSS задаёт корневому элементу класс блока, CSS-переменные из params и data-атрибуты. Всё, что передаёт потребитель, прокидывается на корневой элемент через стандартный механизм проброса атрибутов Vue (inheritAttrs):

  • class — потребительский класс умно объединяется с классом блока, не затирая его;
  • style — мёрджится поверх CSS-переменных, сгенерированных из params;
  • остальные атрибуты и обработчики (id, aria-*, data-*, @click, …) попадают на корневой элемент как есть.

🧩 Суб-компоненты (@element)

Если в @block объявлены @element, они становятся вложенными компонентами через статические свойства корневого компонента и доступны в шаблоне через точечную нотацию:

<EButton :params="{ withIcon: true }">
  <EButton.Icon>
    <svg><!-- … --></svg>
  </EButton.Icon>
  <EButton.Text>Нажми меня</EButton.Text>
</EButton>

Суб-компоненты поддерживают тот же проп as (по умолчанию <div>), но не принимают params.


⚙️ Опции

vueAdapter({
  componentNamePrefix: 'E', // по умолчанию 'E'
});

| Опция | Тип | По умолчанию | Описание | | --------------------- | -------- | ------------ | ------------------------------------------------------------------------------ | | componentNamePrefix | string | 'E' | Префикс имени компонента. Первый символ — [A-Z], остальные — [a-zA-Z0-9_]. |

vueAdapter({ componentNamePrefix: 'My' }); // → MyButton, MyCard

Некорректный префикс (не подходящий под /^[A-Z][a-zA-Z0-9_]*$/) приводит к ошибке на этапе сборки.


🟢 Требования

Адаптер генерирует функциональные компоненты Vue 3. Требуется Vue 3.3 или выше: типизация опирается на IntrinsicElementAttributes и обобщённую сигнатуру функционального компонента, которые vue-tsc корректно разрешает в шаблонах начиная с версии 3.3.


👨‍💻 Автор

Разработка и поддержка: Руслан Мартынов

Если нашёл баг или есть предложение — открывай issue или отправляй pull request.


📄 Лицензия

Распространяется под лицензией MIT.