### Access Basic Example
Source: https://github.com/rough-stuff/wired-elements/wiki/Dev-Environment
Navigate to this URL in your browser to view the basic example page after starting the dev server.
```bash
http://127.0.0.1:8000/examples/basic.html
```
--------------------------------
### Start Wired Elements Dev Server
Source: https://github.com/rough-stuff/wired-elements/wiki/Dev-Environment
Starts a local server to serve all packages with resolved relative paths. Use the outputted host URL to access examples in your browser.
```bash
npm run dev
```
--------------------------------
### Install wired-mat-icon
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-mat-icon/README.md
Install the wired-mat-icon package using npm.
```bash
npm i wired-mat-icon
```
--------------------------------
### Install Wired Elements
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-divider.md
Install the wired-elements package using npm. This is the first step to using any wired-element in your project.
```bash
npm i wired-elements
```
--------------------------------
### Bootstrap Wired Elements Packages
Source: https://github.com/rough-stuff/wired-elements/wiki/Dev-Environment
Run this command after cloning the repository to install all npm dependencies and hoist individual packages using Lerna.
```bash
npm run bootstrap
```
--------------------------------
### Install wired-icon via npm
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-icon/README.md
Install the wired-icon package using npm. This is the first step to include the component in your project.
```bash
npm i wired-icon
```
--------------------------------
### Control Wired Progress Ring with JavaScript
Source: https://github.com/rough-stuff/wired-elements/blob/master/examples/progress-ring.html
Use JavaScript to control the progress of the wired-progress-ring. This example shows how to start, stop, and reset the progress value.
```javascript
const prog = document.getElementById('progress')
let timer = 0;
document.getElementById('btns').addEventListener('click', () => {
if (timer) {
window.clearInterval(timer);
}
timer = window.setInterval(() => {
if (prog.value >= 100) {
prog.value = 0;
} else {
prog.value = prog.value + 1;
}
}, 100);
});
document.getElementById('btnr').addEventListener('click', () => {
if (timer) {
window.clearInterval(timer);
timer = 0;
}
prog.value = 0;
});
```
--------------------------------
### Basic wired-input Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-input.md
Use the wired-input component in your HTML. Examples include a basic input, one with a placeholder, a password input, and a disabled input.
```html
```
--------------------------------
### Basic HTML Usage of WiredRadio
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-radio.md
Use the wired-radio component in your HTML markup. Examples include a default state, a pre-checked state, and a disabled state.
```html
Radio OneRadio TwoDisabled Radio
```
--------------------------------
### Get Icon Path Function
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/iconset-generator.html
Retrieves an icon path from the global ICON_SET based on an input value. Displays 'No path found.' if the path does not exist.
```javascript
function getPath() {
const input = document.getElementById('input');
const result = document.getElementById('result');
const path = window.ICON_SET[input.value];
result.innerHTML = path || 'No path found.';
}
```
--------------------------------
### Basic Wired Checkbox Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-checkbox.md
Use the wired-checkbox component in your HTML markup. Examples include a default checkbox, a pre-checked one, and a disabled one.
```html
Checkbox OneCheckbox TwoDisabled checkbox
```
--------------------------------
### Invalid Light DOM - Missing SVG Wrapper
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-icon/README.md
Elements must be wrapped in an SVG tag. This example is invalid because the circle element is not enclosed within an SVG.
```html
```
--------------------------------
### Wired Icon with Accessibility Attributes
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-icon/README.md
Shows how to add ARIA attributes and a title to an SVG within a wired-icon for improved accessibility. This example uses specific configuration for the wired-icon.
```html
```
--------------------------------
### Generate Iconset
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-mat-icon/CONTRIBUTING.md
Run this command in the generate folder to launch a web server for generating the iconset-full.ts file. Access the web interface at http://localhost:5000.
```bash
npm run generate
```
--------------------------------
### Load Wired Elements via ES Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/README.md
Alternatively, load the ES module directly through unpkg. This method is useful for quick testing or when not using a module bundler.
```html
```
--------------------------------
### Import wired-radio-group and wired-radio
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-radio-group.md
Import the necessary components into your JavaScript code.
```javascript
import { WiredRadioGroup, WiredRadio } from 'wired-elements';
// or
import { WiredRadioGroup } from 'wired-elements/lib/wired-radio-group.js';
```
--------------------------------
### Import WiredSearchInput Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-search-input.md
Import the WiredSearchInput component into your JavaScript project.
```javascript
import { WiredSearchInput } from 'wired-elements';
// or
import { WiredSearchInput } from 'wired-elements/lib/wired-search-input.js';
```
--------------------------------
### Load WiredCombo via CDN
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-combo.md
Load the WiredCombo component directly into your HTML page using a CDN. Ensure you include the 'module' parameter for proper loading.
```html
```
--------------------------------
### Material Look Configuration
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-mat-icon/README.md
Define a configuration object for a material look with transparent stroke and solid fill.
```javascript
const matConfig = {stroke: "transparent", fill: "black", fillStyle: "solid"};
```
```html
```
--------------------------------
### WiredProgress with Min and Max Values
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-progress.md
Configure the minimum and maximum values for the progress bar using 'min' and 'max' attributes. This allows for custom ranges beyond the default 0-100.
```html
```
--------------------------------
### Import WiredVideo Component (ES Module)
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-video.md
Import the WiredVideo component into your JavaScript code using ES module syntax. This allows you to use the component programmatically.
```javascript
import { WiredVideo } from 'wired-elements';
// or
import { WiredVideo } from 'wired-elements/lib/wired-video.js';
```
--------------------------------
### Import WiredRadio Module (JavaScript)
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-radio.md
Import the WiredRadio component into your JavaScript project.
```javascript
import { WiredRadio } from 'wired-elements';
// or
import { WiredRadio } from 'wired-elements/lib/wired-radio.js';
```
--------------------------------
### Load Wired FAB via HTML Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-fab.md
Alternatively, load the Wired FAB component directly into your HTML page using a script tag pointing to the unpkg CDN.
```html
```
--------------------------------
### Import WiredInput Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-input.md
Import the WiredInput component into your JavaScript code. You can use the main module or a specific file path.
```javascript
import { WiredInput } from 'wired-elements';
// or
import { WiredInput } from 'wired-elements/lib/wired-input.js';
```
--------------------------------
### Basic WiredProgress Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-progress.md
Use the wired-progress element in your HTML. Set the 'value' attribute to control the progress.
```html
```
--------------------------------
### Import Wired FAB Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-fab.md
Import the Wired FAB component into your JavaScript project. You can use the main module or a specific file path.
```javascript
import { WiredFab } from 'wired-elements';
// or
import { WiredFab } from 'wired-elements/lib/wired-fab.js';
```
--------------------------------
### Basic CSS for wired-card
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/iconset-generator.html
Basic styling for the wired-card element, setting display, width, and margin.
```css
wired-card {
display: block;
width: 80%;
margin: 1em;
}
```
--------------------------------
### WiredCard Properties and Methods
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-card.md
This snippet outlines the configurable properties and available methods for the wired-card component.
```APIDOC
## WiredCard
### Description
A container for other web elements with a hand-drawn, wireframe-like appearance.
### Properties
- **elevation** (number) - Optional - Sets the elevation of the card. Numerical number between 1-5 (inclusive). Defaults to 1.
- **fill** (color) - Optional - A color to fill the background of the card in a sketchy format.
### Methods
- **requestUpdate()** - When dynamically adding content to the card, call this method to recompute the boundaries of the card.
### Usage Example
```html
Content inside the card
```
```javascript
const card = document.querySelector('wired-card');
// To recompute boundaries after dynamic content change:
card.requestUpdate();
```
```
--------------------------------
### Import WiredCombo in JavaScript
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-combo.md
Import the WiredCombo component into your JavaScript project. You can import the entire module or a specific file.
```javascript
import { WiredCombo } from 'wired-elements';
// or
import { WiredCombo } from 'wired-elements/lib/wired-combo.js';
```
--------------------------------
### Import WiredToggle Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-toggle.md
Import the WiredToggle class into your JavaScript project. You can use the main module or a specific file path.
```javascript
import { WiredToggle } from 'wired-elements';
// or
import { WiredToggle } from 'wired-elements/lib/wired-toggle.js';
```
--------------------------------
### Import wired-image Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-image.md
Import the WiredImage component into your JavaScript code. You can use the main import or a specific path.
```javascript
import { WiredImage } from 'wired-elements';
// or
import { WiredImage } from 'wired-elements/lib/wired-image.js';
```
--------------------------------
### Import wired-icon definition in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-icon/README.md
Include the wired-icon script in your HTML file to make the custom element available.
```html
```
--------------------------------
### Load WiredSearchInput Directly
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-search-input.md
Load the WiredSearchInput component directly into your HTML page using a script tag.
```html
```
--------------------------------
### Basic Wired Tabs Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-tabs.md
Implement wired-tabs in your HTML by creating a wired-tabs element and nesting wired-tab elements within it. Each wired-tab requires a unique 'name' attribute.
```html
Card 1
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Card 2
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Card 3
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
```
--------------------------------
### Use wired-icon with SVG and configuration
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-icon/README.md
Render a wired-icon component by embedding an SVG and applying a configuration object for styling. The 'config' attribute accepts roughjs options.
```html
```
--------------------------------
### Load WiredVideo Component via Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-video.md
Load the WiredVideo component directly into your HTML page using a script tag from a CDN. This is a convenient way to include the component without a build process.
```html
```
--------------------------------
### Import WiredProgress Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-progress.md
Import the WiredProgress component into your JavaScript code. You can use the main module or a specific path.
```javascript
import { WiredProgress } from 'wired-elements';
// or
import { WiredProgress } from 'wired-elements/lib/wired-progress.js';
```
--------------------------------
### Import WiredCard Module (JavaScript)
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-card.md
Import the WiredCard component into your JavaScript project.
```javascript
import { WiredCard } from 'wired-elements';
// or
import { WiredCard } from 'wired-elements/lib/wired-card.js';
```
--------------------------------
### Basic wired-card Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-card.md
Use the wired-card component in your HTML with default and custom elevation.
```html
Elevation: 1
Elevation: 3
```
--------------------------------
### Import WiredLink Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-link.md
Import the WiredLink component into your JavaScript project. You can import the entire module or a specific file.
```javascript
import { WiredLink } from 'wired-elements';
// or
import { WiredLink } from 'wired-elements/lib/wired-link.js';
```
--------------------------------
### Import and Export ICON_SET
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/iconset-generator.html
Imports the ICON_SET from the specified module and makes it globally accessible.
```javascript
import {ICON_SET} from "../packages/wired-mat-icon/lib/iconset/iconset-full.js";
window.ICON_SET = ICON_SET;
```
--------------------------------
### Basic Usage of wired-mat-icon
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-mat-icon/README.md
Use the wired-mat-icon component in your web page, specifying the icon and optional configuration.
```html
```
--------------------------------
### Import Wired Tabs Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-tabs.md
Import the WiredTabs and WiredTab components into your JavaScript code. You can import the entire module or a specific file.
```javascript
import { WiredTabs, WiredTab } from 'wired-elements';
// or
import { WiredTabs, WiredTab } from 'wired-elements/lib/wired-tabs.js';
```
--------------------------------
### WiredLink with Elevation and Target
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-link.md
Configure the wired-link component with an elevation property for a thicker underline and a target attribute to specify the link's behavior in a new tab.
```html
Elevation
```
--------------------------------
### Import WiredSpinner Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-spinner.md
Import the WiredSpinner module into your JavaScript project.
```javascript
import { WiredSpinner } from 'wired-elements';
// or
import { WiredSpinner } from 'wired-elements/lib/wired-spinner.js';
```
--------------------------------
### Basic WiredProgressRing Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-progress-ring.md
Use the wired-progress-ring component in your HTML by adding the custom element tag. Set the 'value' property to control the progress.
```html
```
--------------------------------
### Import WiredButton Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-button.md
Import the WiredButton component into your JavaScript project.
```javascript
import { WiredButton } from 'wired-elements';
// or
import { WiredButton } from 'wired-elements/lib/wired-button.js';
```
--------------------------------
### Load WiredProgressRing via HTML Script
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-progress-ring.md
Alternatively, load the WiredProgressRing component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Load WiredInput via HTML Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-input.md
Alternatively, load the WiredInput component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Basic wired-combo Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-combo.md
Use the wired-combo element in your HTML, specifying an ID and a default selected item. Include wired-item elements for the options.
```html
Number OneNumber TwoNumber Three
```
--------------------------------
### Import WiredCheckbox in JavaScript
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-checkbox.md
Import the WiredCheckbox component into your JavaScript code. You can use the main module or a specific file path.
```javascript
import { WiredCheckbox } from 'wired-elements';
// or
import { WiredCheckbox } from 'wired-elements/lib/wired-checkbox.js';
```
--------------------------------
### Import WiredProgressRing Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-progress-ring.md
Import the WiredProgressRing component into your JavaScript code. You can import the entire module or a specific component.
```javascript
import { WiredProgressRing } from 'wired-elements';
// or
import { WiredProgressRing } from 'wired-elements/lib/wired-progress-ring.js';
```
--------------------------------
### Open wired-dialog with JavaScript
Source: https://github.com/rough-stuff/wired-elements/blob/master/examples/dialog.html
Use this code to open a wired-dialog when an element is clicked. Ensure the dialog element has the ID 'wired-dialog'.
```javascript
document.getElementById('openDialog').addEventListener('click', () => { document.querySelector('wired-dialog').open = true; });
```
--------------------------------
### Import WiredTextarea Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-textarea.md
Import the WiredTextarea component into your JavaScript code. Two import paths are provided for flexibility.
```javascript
import { WiredTextarea } from 'wired-elements';
// or
import { WiredTextarea } from 'wired-elements/lib/wired-textarea.js';
```
--------------------------------
### Programmatic Control of wired-mat-icon
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-mat-icon/README.md
Control wired-mat-icon properties like 'icon' and 'config' programmatically using JavaScript after the custom element is defined.
```html
```
```javascript
customElements.whenDefined('wired-mat-icon').then(() => {
const wiredMatIcon = document.getElementById('modifyme');
wiredMatIcon.icon = 'flash_on';
wiredMatIcon.config = {fill: 'red', fillWeight: 1};
});
```
--------------------------------
### Load WiredCheckbox in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-checkbox.md
Load the wired-checkbox component directly into your HTML page using a script tag from a CDN. Ensure to include the 'module' parameter.
```html
```
--------------------------------
### Import WiredDialog Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-dialog.md
Import the WiredDialog component into your JavaScript project. You can use the main module or a specific file path.
```javascript
import { WiredDialog } from 'wired-elements';
// or
import { WiredDialog } from 'wired-elements/lib/wired-dialog.js';
```
--------------------------------
### Import WiredDivider Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-divider.md
Import the WiredDivider class into your JavaScript project. You can import the entire library or the specific module.
```javascript
import { WiredDivider } from 'wired-elements';
// or
import { WiredDivider } from 'wired-elements/lib/wired-divider.js';
```
--------------------------------
### Import wired-mat-icon definition
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-mat-icon/README.md
Import the wired-mat-icon definition into your HTML page or module script.
```html
```
```javascript
import "wired-mat-icon";
```
--------------------------------
### Load WiredCard via HTML Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-card.md
Include the WiredCard component directly in your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Basic wired-combo HTML Structure
Source: https://github.com/rough-stuff/wired-elements/blob/master/examples/combo.html
This snippet shows the basic HTML structure for a wired-combo element with several options. It includes a disabled option to demonstrate functionality.
```html
Number oneNumber twoNumber threeNumber fourDisabledNumber two DisabledNumber two
```
--------------------------------
### Use wired-video in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-video.md
Include the wired-video custom element in your HTML markup. Specify the video source and other attributes like autoplay, muted, and loop.
```html
```
--------------------------------
### Load Wired Tabs via HTML Script
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-tabs.md
Alternatively, load the WiredTabs and WiredTab components directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Import WiredListbox Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-listbox.md
Import the WiredListbox component into your JavaScript code. You can use the main package import or a specific module path.
```javascript
import { WiredListbox } from 'wired-elements';
// or
import { WiredListbox } from 'wired-elements/lib/wired-listbox.js';
```
--------------------------------
### Load WiredToggle via HTML Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-toggle.md
Alternatively, load the WiredToggle component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Compile TypeScript to JavaScript
Source: https://github.com/rough-stuff/wired-elements/wiki/Dev-Environment
Execute this command to compile all TypeScript code into JavaScript. The compiled output will be placed in each package's 'lib' folder.
```bash
npm run tsc
```
--------------------------------
### Load WiredDivider via HTML Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-divider.md
Alternatively, load the WiredDivider element directly into your HTML page using a script tag from a CDN. Ensure to use the 'module' parameter.
```html
```
--------------------------------
### Load WiredProgress via HTML Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-progress.md
Alternatively, load the WiredProgress component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Load WiredDialog via Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-dialog.md
Alternatively, load the WiredDialog component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Load WiredListbox via Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-listbox.md
Alternatively, load the WiredListbox component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Basic WiredLink Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-link.md
Use the wired-link component in your HTML by providing an href attribute. This creates a hand-drawn link.
```html
Learn more
```
--------------------------------
### Load WiredButton via HTML Script
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-button.md
Load the WiredButton component directly into your HTML page using a script tag.
```html
```
--------------------------------
### Load WiredRadio via HTML Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-radio.md
Load the WiredRadio component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Wired Calendar with JavaScript Interactions
Source: https://github.com/rough-stuff/wired-elements/blob/master/examples/calendar.html
This snippet demonstrates how to interact with the wired-calendar component using JavaScript. It includes event listeners for date selection and button clicks to update the calendar's date.
```javascript
const myCalendar4 = document.getElementById('calendar4');
const myCalendar4result = document.getElementById('calendar4-result');
const myCalendar4update = document.getElementById('calendar4-update');
document.getElementById('btn-update').addEventListener('click', () => {
const today = new Date();
const time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
const updateTimeLeyend = ' Updated at:' + time + '';
const selectedObject = myCalendar4.value;
if (selectedObject && selectedObject.date) {
myCalendar4update.innerHTML = selectedObject.date.toLocaleDateString() + updateTimeLeyend;
} else {
myCalendar4update.innerHTML = 'No date selected yet.' + updateTimeLeyend;
}
});
document.getElementById('btn-today').addEventListener('click', () => {
let today = new Date();
// Sample using optional internal date formatter
formatedDate = myCalendar4.format(today);
console.log('Set date to today = ', formatedDate);
// Set selected date using any format accepted by javascript Date object
myCalendar4.setSelectedDate(formatedDate);
});
myCalendar4.addEventListener('selected', () => {
let selectedObject = myCalendar4.value;
// `selectedObject.date` is a javascript Date object
// `selectedObject.text` is the formated text of the date
let formatedDate = selectedObject.text;
myCalendar4result.innerHTML = formatedDate + ' Note: Internal date handling not affected by locale.';
});
```
--------------------------------
### Import wired-icon definition in module script
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-icon/README.md
Import the wired-icon custom element into your JavaScript module.
```javascript
import "wired-icon";
```
--------------------------------
### Basic Wired Button Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-button.md
Use the wired-button custom element in your HTML.
```html
Click MeDisabledElevation
```
--------------------------------
### Load WiredLink via HTML Script
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-link.md
Alternatively, load the WiredLink component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Use WiredSearchInput in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-search-input.md
Add the wired-search-input element to your HTML markup. You can set a placeholder attribute.
```html
```
--------------------------------
### JavaScript to Log Selected Combo Box Values
Source: https://github.com/rough-stuff/wired-elements/blob/master/examples/combo.html
This JavaScript code listens for a button click and logs the selected value of all 'wired-combo' elements on the page to the console. Ensure the button and combo boxes are present in the DOM before running.
```javascript
document.querySelector('button').addEventListener('click', () => {
const combos = document.querySelectorAll('wired-combo');
combos.forEach((c) => {
console.log(c, c.selected);
});
});
```
--------------------------------
### Load wired-image via HTML Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-image.md
Alternatively, load the wired-image component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Use Wired Icon inside Wired Button
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-icon/README.md
Demonstrates nesting a wired-icon within a wired-button. Custom styles can be applied to the icon.
```html
```
--------------------------------
### Valid Light DOM Structure for wired-icon
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-icon/README.md
Provide elements within a single-level SVG tag for correct transformation. Ensure only one level of depth inside the SVG.
```html
```
--------------------------------
### Use WiredDialog in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-dialog.md
Integrate the WiredDialog component into your HTML structure. Content can be placed inside the dialog, and a close button can be added.
```html
Dialog content here
Close dialog
```
--------------------------------
### Basic Wired Toggle Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-toggle.md
Use the wired-toggle custom element in your HTML. You can set the 'checked' attribute to make it initially selected.
```html
```
--------------------------------
### Import WiredSlider Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-slider.md
Import the WiredSlider component into your JavaScript code. You can import the entire module or a specific file path.
```javascript
import { WiredSlider } from 'wired-elements';
// or
import { WiredSlider } from 'wired-elements/lib/wired-slider.js';
```
--------------------------------
### Import Wired Elements Components
Source: https://github.com/rough-stuff/wired-elements/blob/master/README.md
Import specific wired elements into your module script. This allows you to use them programmatically in your JavaScript code.
```javascript
import { WiredButton, WiredInput } from "wired-elements"
```
```javascript
import { WiredButton } from 'wired-elements/lib/wired-button.js';
import { WiredInput } from 'wired-elements/lib/wired-input.js';
```
--------------------------------
### Use Wired Calendar in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-calendar.md
Include the wired-calendar component in your HTML markup. The 'selected' attribute can pre-select a date.
```html
```
--------------------------------
### Basic Wired Listbox Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-listbox.md
Use the wired-listbox element in your HTML with wired-item children. The 'selected' attribute pre-selects an item by its value.
```html
Number OneNumber TwoNumber Three
```
--------------------------------
### Basic wired-radio-group HTML structure
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-radio-group.md
Use wired-radio-group in your HTML to create a selectable group of radio buttons. The 'selected' attribute pre-selects an option.
```html
OneTwoThreeFour
```
--------------------------------
### Load WiredSpinner via HTML Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-spinner.md
Load the WiredSpinner component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Import WiredCalendar Module
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-calendar.md
Import the WiredCalendar module into your JavaScript project. This makes the component available for use.
```javascript
import { WiredCalendar } from 'wired-elements/lib/wired-calendar.js';
```
--------------------------------
### Using wired-mat-icon inside wired-button
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-mat-icon/README.md
Embed a wired-mat-icon within a wired-icon-button for interactive elements.
```html
```
--------------------------------
### Use Wired FAB in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-fab.md
Add the Wired FAB component to your HTML markup. You can include child elements like icons within the FAB.
```html
favoriteclose
```
--------------------------------
### Load WiredTextarea via HTML Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-textarea.md
Alternatively, load the WiredTextarea component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Use WiredTextarea in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-textarea.md
Include the wired-textarea custom element in your HTML markup. Basic attributes like 'placeholder' and 'rows' can be set directly.
```html
```
--------------------------------
### Load WiredIconButton in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-icon-button.md
Load the WiredIconButton component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Use Wired Elements in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/README.md
Integrate wired elements directly into your HTML markup. These custom elements can be used like any other HTML tag.
```html
Click Me
```
--------------------------------
### Basic Wired Spinner Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-spinner.md
Use the wired-spinner element in your HTML. The 'spinning' property controls the animation, and 'duration' sets the spin speed in milliseconds.
```html
```
--------------------------------
### Import WiredIconButton in JavaScript
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-icon-button.md
Import the WiredIconButton module in your JavaScript code. You can import the entire library or the specific component.
```javascript
import { WiredIconButton } from 'wired-elements';
// or
import { WiredIconButton } from 'wired-elements/lib/wired-icon-button.js';
```
--------------------------------
### Horizontal Wired Listbox with Custom Styling
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-listbox.md
Configure the listbox to be horizontal and apply custom CSS variables for the selected item's background and text color.
```html
Number OneNumber TwoNumber Three
```
--------------------------------
### Use wired-image in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-image.md
Incorporate the wired-image custom element into your HTML. Specify the image source using the 'src' attribute. You can also set an 'elevation' for a card-like appearance.
```html
```
--------------------------------
### Use WiredIconButton in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-icon-button.md
Add wired-icon-button elements to your HTML. You can include an mwc-icon or any other image inside the button.
```html
favoritefavorite
```
--------------------------------
### Load WiredSlider via HTML Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-slider.md
Alternatively, load the WiredSlider component directly into your HTML page using a script tag with a module type.
```html
```
--------------------------------
### Generate SvgIconSet from HTML Object Tags
Source: https://github.com/rough-stuff/wired-elements/blob/master/experimental/wired-mat-icon/generate/index.html
This script extracts SVG path data from multiple HTML object elements and formats it into a TypeScript SvgIconSet. It listens for the 'load' event on each object to ensure content is available before processing.
```javascript
const resultArea = document.getElementById('result');
resultArea.value = "import { SvgIconSet } from './index';export const ICON_SET: SvgIconSet = {";
const source = document.getElementsByTagName('object');
let counter = 0;
const retrievePaths = function(object) {
counter++;
const icons = object.contentDocument.firstElementChild.getElementsByTagName('svg');
// All the id in the doc follow this format
const regex = /ic_(.*)_24px/;
// We want to retrieve the following attributes from the svg
// The viewBox attribute is (*almost*)
// always "0 0 24 24" so we don't take it
// Width and height are always 24 so we don't take them
// x and y attributes are not interesting...
// So finally all we want is the path :)
const result = {};
for (icon of icons) {
const id = regex.exec(icon.getAttribute('id'))[1];
result[id] = icon.lastElementChild.getAttribute('d');
}
let stringValue = JSON.stringify(result);
stringValue = stringValue.substring(1, stringValue.length -1);
if (counter === source.length) {
stringValue += '};';
} else {
stringValue += ',';
}
resultArea.value += stringValue;
}
for (let object of source) {
object.addEventListener('load', () => retrievePaths(object))
}
```
--------------------------------
### Basic Wired Slider Usage
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-slider.md
Use the wired-slider component in your HTML. You can render a default slider, a disabled slider, or a slider with custom initial values.
```html
```
--------------------------------
### Use WiredDivider in HTML
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-divider.md
Add the wired-divider custom element to your HTML to display a sketchy line between content sections. It can be used like any other HTML element.
```html
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
```
--------------------------------
### Toggle Wired Spinner State
Source: https://github.com/rough-stuff/wired-elements/blob/master/examples/spinner.html
Attaches an event listener to a button to toggle the spinning state of a wired-spinner element. Ensure the spinner has the ID 'sp'.
```javascript
document.querySelector('wired-button').addEventListener('click', () => {
const sp = document.getElementById('sp');
sp.spinning = !sp.spinning;
});
```
--------------------------------
### Load WiredCalendar via HTML Script Tag
Source: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-calendar.md
Alternatively, load the WiredCalendar component directly into your HTML page using a script tag from a CDN.
```html
```
--------------------------------
### Close wired-dialog with JavaScript
Source: https://github.com/rough-stuff/wired-elements/blob/master/examples/dialog.html
Use this code to close a wired-dialog when an element is clicked. Ensure the dialog element has the ID 'wired-dialog'.
```javascript
document.getElementById('closeDialog').addEventListener('click', () => { document.querySelector('wired-dialog').open = false; });
```