0.1.16 • Published 10 months ago

@pixelmakers/elements v0.1.16

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

PXM Elements

npm version License: MIT

Modern, accessible web components for everyone. From no-code builders to seasoned developers.

Philosophy

PXM Elements is built on three core principles:

šŸŽÆ Universal Compatibility - Works everywhere: Webflow, Shopify, Astro, vanilla HTML, or any framework
🪶 Lightweight & Simple - Each component does one thing exceptionally well
šŸŽØ Unstyled by Design - You control the look, we handle the behavior and accessibility

Quick Start

For No-Code/Low-Code Users (CDN)

Drop this into your HTML and start using components immediately:

<!DOCTYPE html>
<html>
<head>
    <title>My Project</title>
</head>
<body>
    <!-- 1. Add component -->
    <pxm-accordion>
        <pxm-accordion-item>
            <pxm-accordion-trigger>Click me!</pxm-accordion-trigger>
            <pxm-accordion-content>This content toggles!</pxm-accordion-content>
        </pxm-accordion-item>
    </pxm-accordion>

    <!-- 2. Include script (loads automatically) -->
    <script src="https://cdn.jsdelivr.net/npm/@pixelmakers/elements/dist/umd/accordion.js"></script>
</body>
</html>

For Developers (NPM)

Install and import only what you need:

npm install @pixelmakers/elements
// Import individual components for optimal tree-shaking
import '@pixelmakers/elements/accordion';
import '@pixelmakers/elements/tabs';

// Or with TypeScript support
import { PxmAccordion } from '@pixelmakers/elements/accordion';

Why PXM Elements?

šŸš€ Zero Configuration

  • CDN: Works immediately, no build tools required
  • NPM: Tree-shakable imports, TypeScript support included

šŸ“± Accessibility First

  • Full keyboard navigation
  • Screen reader support
  • ARIA attributes handled automatically
  • Follows WCAG guidelines

šŸŽØ Your Design, Our Behavior

  • No imposed styling - use your CSS framework
  • Semantic HTML structure
  • CSS custom properties for easy theming
  • Works with Tailwind, Bootstrap, or custom CSS

šŸŒ Universal Platform Support

  • Webflow: Drop in custom code blocks
  • Shopify: Works in Liquid templates
  • Astro: Server-side rendering compatible
  • React/Vue: Framework adapters available
  • WordPress: Plugin-friendly

Components

ComponentSize (UMD)Size (ESM)Description
Accordion5.6KB5.9KBCollapsible content sections
Tabs4.7KB4.3KBTabbed interface navigation
Toggle2.7KB2.8KBBoolean switch/checkbox
Number Input4.1KB3.7KBEnhanced number input with controls
Video11.5KB16.3KBMulti-platform video player
Phone Input3.2KB*1.4KB*International phone number input
Lightbox67.5KB*91.8KB*Image/media gallery with zoom

Sizes marked with use external dependencies (loaded separately for NPM)

Usage Patterns

CDN Usage (Recommended for Webflow, Shopify, etc.)

Each component is self-contained and can be loaded independently:

<!-- Load only the components you need -->
<script src="https://cdn.jsdelivr.net/npm/@pixelmakers/elements/dist/umd/accordion.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@pixelmakers/elements/dist/umd/tabs.js"></script>

<!-- Use immediately -->
<pxm-accordion allow-multiple="true">
    <pxm-accordion-item>
        <pxm-accordion-trigger>Section 1</pxm-accordion-trigger>
        <pxm-accordion-content>Content 1</pxm-accordion-content>
    </pxm-accordion-item>
</pxm-accordion>

NPM Usage (Recommended for Applications)

Tree-shakable imports ensure optimal bundle sizes:

// Individual imports (recommended)
import '@pixelmakers/elements/accordion';
import '@pixelmakers/elements/tabs';

// Dynamic imports for code splitting
const loadLightbox = async () => {
    await import('@pixelmakers/elements/lightbox');
    // Component is now available
};

// TypeScript usage
import type { PxmAccordion } from '@pixelmakers/elements/accordion';

const accordion = document.querySelector('pxm-accordion') as PxmAccordion;
accordion.setAttribute('allow-multiple', 'true');

Styling Guide

PXM Elements provides zero styling - you're in complete control. Here are common patterns:

CSS Custom Properties

/* Define your design tokens */
:root {
    --border-radius: 8px;
    --transition-speed: 200ms;
    --primary-color: #3b82f6;
}

/* Style components using data attributes and CSS selectors */
pxm-accordion-trigger {
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: var(--border-radius);
    background: white;
    transition: all var(--transition-speed);
}

pxm-accordion-trigger:hover {
    background: #f9fafb;
}

pxm-accordion-item[active="true"] pxm-accordion-trigger {
    background: var(--primary-color);
    color: white;
}

Tailwind CSS

<pxm-toggle class="relative inline-block w-12 h-6 bg-gray-300 rounded-full transition-colors duration-200 ease-in-out data-[state=checked]:bg-blue-500">
    <span class="block w-5 h-5 bg-white rounded-full shadow transform transition-transform duration-200 ease-in-out translate-x-0.5 data-[state=checked]:translate-x-6"></span>
</pxm-toggle>

CSS-in-JS / Styled Components

const StyledAccordion = styled(PxmAccordion)`
    border: 1px solid ${props => props.theme.colors.border};
    border-radius: ${props => props.theme.radii.md};
    
    pxm-accordion-trigger {
        padding: ${props => props.theme.space[4]};
        background: ${props => props.theme.colors.surface};
        
        &:hover {
            background: ${props => props.theme.colors.surfaceHover};
        }
    }
`;

Platform Integration

Webflow

  1. Add a Custom Code block to your page
  2. Include the component script
  3. Add HTML structure in an Embed block
<!-- In Custom Code (Head) -->
<script src="https://cdn.jsdelivr.net/npm/@pixelmakers/elements/dist/umd/accordion.js"></script>

<!-- In Embed block -->
<pxm-accordion>
    <pxm-accordion-item>
        <pxm-accordion-trigger>FAQ Question</pxm-accordion-trigger>
        <pxm-accordion-content>Answer content here</pxm-accordion-content>
    </pxm-accordion-item>
</pxm-accordion>

Shopify Liquid

<!-- In theme.liquid -->
<script src="https://cdn.jsdelivr.net/npm/@pixelmakers/elements/dist/umd/tabs.js"></script>

<!-- In template -->
<pxm-tabs>
    <pxm-triggers>
        {% for variant in product.variants %}
            <button data-tab="variant-{{ variant.id }}">{{ variant.title }}</button>
        {% endfor %}
    </pxm-triggers>
    
    {% for variant in product.variants %}
        <pxm-panel data-tab="variant-{{ variant.id }}">
            {{ variant.price | money }}
        </pxm-panel>
    {% endfor %}
</pxm-tabs>

Astro

---
// Component works server-side
---

<script>
    import '@pixelmakers/elements/accordion';
</script>

<pxm-accordion>
    <pxm-accordion-item>
        <pxm-accordion-trigger>Server-rendered content</pxm-accordion-trigger>
        <pxm-accordion-content>
            This works with SSR!
        </pxm-accordion-content>
    </pxm-accordion-item>
</pxm-accordion>

Browser Support

  • Chrome 90+ āœ…
  • Firefox 90+ āœ…
  • Safari 14+ āœ…
  • Edge 90+ āœ…

All components use modern Web Components APIs with graceful degradation.

TypeScript Support

Full TypeScript support with exported types:

import type { 
    PxmAccordion, 
    AccordionConfig,
    PxmTabs,
    TabsConfig 
} from '@pixelmakers/elements';

// Type-safe component usage
const accordion = document.querySelector('pxm-accordion') as PxmAccordion;
const config: AccordionConfig = {
    allowMultiple: true,
    animationDuration: 300
};

Performance

Bundle Sizes

  • CDN: Self-contained, cacheable across sites
  • NPM: Tree-shakable, only bundle what you use
  • Dependencies: Heavy deps (Swiper, intl-tel-input) are external for NPM builds

Loading Strategy

<!-- Preload critical components -->
<link rel="preload" href="https://cdn.jsdelivr.net/npm/@pixelmakers/elements/dist/umd/accordion.js" as="script">

<!-- Load non-critical components lazily -->
<script>
    // Load lightbox only when needed
    document.addEventListener('click', async (e) => {
        if (e.target.matches('[data-lightbox]')) {
            await import('https://cdn.jsdelivr.net/npm/@pixelmakers/elements/dist/umd/lightbox.js');
        }
    }, { once: true });
</script>

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development

# Install dependencies
npm install

# Start development server
npm run dev

# Run tests
npm run test

# Build library
npm run build

Examples

License

MIT Ā© PixelMakers


Built with ā¤ļø for the web community

Report Issues • Discussions • Twitter

0.1.16

10 months ago

0.1.15

10 months ago

0.1.14

10 months ago

0.1.13

10 months ago

0.1.12

10 months ago

0.1.11

10 months ago

0.1.10

10 months ago

0.1.9

10 months ago

0.1.8

10 months ago

0.1.7

10 months ago

0.1.6

10 months ago

0.1.5

11 months ago

0.1.4

11 months ago

0.1.3

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago