7.22.1 • Published 8 days ago

@astrouxds/astro-web-components v7.22.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 days ago

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/@astrouxds/astro-web-components/dist/astro-web-components/astro-web-components.css"
/>
<script
    type="module"
    src="https://unpkg.com/@astrouxds/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 @astrouxds/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/@astrouxds/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 '@astrouxds/astro-web-components/dist/astro-web-components/astro-web-components.css'
import {
    applyPolyfills,
    defineCustomElements,
} from '@astrouxds/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 '@astrouxds/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 '@astrouxds/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 '@astrouxds/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 '@astrouxds/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.

7.22.1

8 days ago

7.22.0

25 days ago

7.21.0

2 months ago

7.20.0

5 months ago

7.18.0

6 months ago

7.19.1

6 months ago

7.19.0

6 months ago

7.15.1

10 months ago

7.17.0

8 months ago

7.15.2

9 months ago

7.15.0

10 months ago

7.17.1

7 months ago

7.16.0

9 months ago

7.14.0

10 months ago

7.13.0

11 months ago

7.12.0

11 months ago

7.11.0

12 months ago

7.9.3

1 year ago

7.10.0

1 year ago

7.8.0

1 year ago

7.9.2

1 year ago

7.9.1

1 year ago

7.9.0

1 year ago

7.6.0

1 year ago

7.7.0

1 year ago

7.5.0

1 year ago

7.3.0

1 year ago

7.1.1

2 years ago

7.1.0

2 years ago

7.4.0

1 year ago

7.2.0

1 year ago

7.0.0-rc.2

2 years ago

7.0.0

2 years ago

7.0.2

2 years ago

7.0.1

2 years ago

6.14.0

2 years ago

6.13.1

2 years ago

6.13.0

2 years ago

7.0.0-rc.1

2 years ago

6.12.1

2 years ago

6.12.0

2 years ago

6.11.0

2 years ago

6.10.0

2 years ago

6.9.0

2 years ago

6.8.0

2 years ago

6.9.1

2 years ago

7.0.0-beta.2

2 years ago

7.0.0-beta.3

2 years ago

7.0.0-beta.1

2 years ago

6.7.0

2 years ago

6.6.0

2 years ago

7.0.0-beta.0

2 years ago

6.5.0

2 years ago

6.4.0

2 years ago

6.5.1

2 years ago

6.3.0

2 years ago

6.1.0

2 years ago

6.2.0

2 years ago

6.0.5

2 years ago

6.0.3

2 years ago

6.0.2

2 years ago

6.0.4

2 years ago

6.0.1

3 years ago

6.0.0

3 years ago

4.4.5

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago