3.0.0 • Published 5 months ago

@odx/pictograms v3.0.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
-
Last release
5 months ago

@odx/pictograms

A lightweight library for displaying pictograms as custom elements. This package provides flexible imports, allowing you to include only what you need to optimize your project.

Installation (npm)

Install the library via npm:

npm i @odx/pictograms

Usage

The library provides a custom custom element <odx-pictogram> to display pictograms. You can choose between different sets or import individual pictograms to reduce your bundle size.

We rely on the esm module behavior in order to keep a global state. If you load an asset from a CDN ensure that the same module of @odx/assets-utils is used throughout your application. One common technique is the usage of an import map (<script type="importmap">).

Import custom element:

import '@odx/pictograms';

Import specific pictogram sets

To optimize your bundle, you can import only the specific pictogram set you need:

// All pictogram sets
import '@odx/pictograms/all';

// Default pictograms (default set)
import '@odx/pictograms/default';

Import individual pictograms

To optimize your bundle, you can import only the specific pictograms you need:

import '@odx/pictograms/default/user';

Example Usage

Element API

  • name: string - <set-name>::<name> or <name> with default set (core)
  • set: string - <set-name>

CSS Property API

  • --color: string - default: currentColor
  • --size: string - default: 1em

HTML Example

<script type="module">
  import '@odx/pictograms';
  import '@odx/pictograms/default';
</script>

<!-- default set: core -->
<odx-pictogram name="<name>"></odx-pictogram>
<odx-pictogram name="<set-name>::<name>"></odx-pictogram>
<odx-pictogram name="<set-name>::<name>"></odx-pictogram>

CDN

<script src="https://esm.sh/@odx/pictograms" type="module"></script>
<script src="https://esm.sh/@odx/pictograms/<set-name>" type="module"></script>

JavaScript Example

// Import the default pictogram set
import '@odx/pictograms/default';

// Create a pictogram dynamically
const pictogram = document.createElement('odx-pictogram');
pictogram.name = 'default::user';

document.body.appendChild(pictogram);

CDN

import loadPictograms from '@odx/pictograms/loader';

/*
interface AssetLoaderOptions {
  cdn?: string; // default: 'https://esm.sh'
  loadCustomElement?: boolean; // default: false
  loadMetadata?: boolean; // default: false
}
*/
loadPictograms('<set-name>', options);

Browser Support

This library leverages modern web technologies such as Shadow DOM for encapsulation and CSSStyleSheet.replaceSync() for efficient stylesheet updates. It targets the ES2022 specification, taking advantage of the latest JavaScript features. These technologies are widely supported in most modern browsers.

Supported Browsers:

  • Chrome 97+
  • Edge 97+
  • Firefox 104+
  • Safari 14+
  • Opera 83+

Live demo ⭐

For a overview of all available assets please refer to our Asset Viewer.

3.0.0

5 months ago

2.6.0

6 months ago

2.5.0

6 months ago

2.4.0

6 months ago

2.3.0

6 months ago

2.2.0

6 months ago

2.1.2

7 months ago

2.1.1

7 months ago

2.1.0

7 months ago

2.0.4

7 months ago

2.0.3

7 months ago

2.0.2

7 months ago

2.0.1

7 months ago

2.0.0

7 months ago

1.2.0

7 months ago

1.1.4

7 months ago

1.1.3

8 months ago

1.1.2

8 months ago

1.1.1

8 months ago

1.1.0

8 months ago

1.0.0

8 months ago

1.0.0-rc.11

9 months ago

1.0.0-rc.10

9 months ago

1.0.0-rc.9

10 months ago

1.0.0-rc.8

10 months ago

1.0.0-rc.7

10 months ago

1.0.0-rc.6

10 months ago

1.0.0-rc.5

10 months ago

1.0.0-rc.4

10 months ago

1.0.0-rc.3

10 months ago

1.0.0-rc.2

10 months ago

1.0.0-rc.1

10 months ago