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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rocketmark/astro-web-components

v7.15.0

Published

Astro Web Components

Downloads

171

Readme

Installation

Quick Start

To get up and running quickly, Astro web components are available via a CDN. Add the following to your <head>

<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
    href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap"
    rel="stylesheet"
/>
<link
    rel="stylesheet"
    href="https://unpkg.com/@rocketmark/astro-web-components/dist/astro-web-components/astro-web-components.css"
/>
<script
    type="module"
    src="https://unpkg.com/@rocketmark/astro-web-components/dist/astro-web-components/astro-web-components.esm.js"
></script>

Astro components are now available anywhere in your app.

<body>
    <rux-button>Hello World</rux-button>
</body>

Integrations

  1. Install npm i @rocketmark/astro-web-components

  2. Import Astro's Fonts

<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
    href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap"
    rel="stylesheet"
/>

Roboto is used for the font. We recommend using Google's CDN; however, you can also pull down and serve your own copy of the font.

  1. Bootstrap Your Application

Static HTML (w/ ESM Modules)

// Import Astro's base styles
<link
    rel="stylesheet"
    href="/node_modules/@rocketmark/astro-web-components/dist/astro-web-components/astro-web-components.css"
/>
<script type="module">
    import { defineCustomElements } from '/node_modules/astro-web-components/loader'
    defineCustomElements()
</script>

Generic Framework

// Import Astro's base styles
import 'astro-web-components/dist/astro-web-components/astro-web-components.css'
import {
    applyPolyfills,
    defineCustomElements,
} from 'astro-web-components/loader'

applyPolyfills().then(() => {
    defineCustomElements()
})

Vue

import Vue from 'vue'
import App from './App.vue'

// Import Astro's base styles
import '@rocketmark/astro-web-components/dist/astro-web-components/astro-web-components.css'
import {
    applyPolyfills,
    defineCustomElements,
} from '@rocketmark/astro-web-components/loader'

Vue.config.productionTip = false

// Tell Vue to ignore all components defined in the astro-web-components package
Vue.config.ignoredElements = [/rux-\w*/]

// Bind the custom elements to the window object
applyPolyfills().then(() => {
    defineCustomElements()
})

new Vue({
    render: (h) => h(App),
}).$mount('#app')

Angular

  1. Include the AstroComponentsModule in any module that uses an Astro component.
import { BrowserModule } from '@angular/platform-browser'
import { NgModule } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { AstroComponentsModule } from '@rocketmark/angular'

import { AppComponent } from './app.component'

@NgModule({
    declarations: [AppComponent],
    imports: [BrowserModule, FormsModule, AstroComponentsModule],
    bootstrap: [AppComponent],
})
export class AppModule {}

Or, Define your Custom Elements in main.ts

import { enableProdMode } from '@angular/core'
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'

import { AppModule } from './app/app.module'
import { environment } from './environments/environment'

// Note: loader import location set using "esmLoaderPath" within the output target config
import { defineCustomElements } from '@rocketmark/astro-web-components/loader'

if (environment.production) {
    enableProdMode()
}

platformBrowserDynamic()
    .bootstrapModule(AppModule)
    .catch((err) => console.log(err))
defineCustomElements()
  1. Setting dynamic data in for loop
<rux-classification-marking *ngFor="let type of types" [attr.classification]="type"></rux-classification-marking>

React

import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
import registerServiceWorker from './registerServiceWorker'

import {
    applyPolyfills,
    defineCustomElements,
} from '@rocketmark/astro-web-components/loader'

ReactDOM.render(<App />, document.getElementById('root'))
registerServiceWorker()

applyPolyfills().then(() => {
    defineCustomElements()
})

Tree Shaking + Bundlers

Astro ships with a convenient lazy-loader, but if you'd rather more control over your build process and are using an existing bundler that supports tree shaking, you can also cherry-pick only the components you actually use. For example:

import { RuxClock } from '@rocketmark/astro-web-components/dist/components/rux-clock.js'
customElements.define('rux-clock', RuxClock)

NOTE: You will need to manually call customElements.define for every component you wish to use and their dependencies. Refer to each component's documentation to see their dependencies at a glance.