@leapdev/gui-icons
v3.0.114
Published
LEAP GUI Icons
Maintainers
Readme
LEAP GUI Icons
Quick Start
- Install Node.js & NPM
- Install Project Dependencies
npm install - Run
npm linkin Terminal to symlink the project folder. For more Info, visit npm-link - Run
npm run buildin Terminal to build GUI - Run
npm run startin Terminal to run GUI
Installing
npm install @leapdev/gui-iconsUsage
After installing the package, you can include the icons in your application.
SVG sprites
Here's an example of how to use a single icon from our SVG sprites in a web application:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>LEAP GUI Icons Example</title>
</head>
<body>
<!-- First, include the sprite file -->
<div style="display: none">
<object
id="sprite"
type="image/svg+xml"
data="node_modules/@leapdev/gui-icons/dist/icons/sprite-desktop.svg"
></object>
</div>
<!-- Then, use the icon -->
<svg width="16" height="16">
<use xlink:href="#desktop-Pin"></use>
</svg>
</body>
</html>This example demonstrates how to use the 'desktop-Pin' icon from the desktop sprite. Here's what's happening:
- We include the sprite file using an
<object>tag. This loads the SVG sprite into the document. - We create an
<svg>element and use the<use>tag to reference the specific icon from the sprite. - The
xlink:hrefattribute points to the id of the icon in the sprite (#desktop-Pin).
To use a different icon, simply change the id in the xlink:href attribute. For example, to use a 'Preview' icon, you might use #desktop-Preview.
Remember to adjust the sprite file path according to your project structure. You may also need to change sprite-desktop.svg to the appropriate sprite file for the icon category you're using.
To use different icon sizes, you can adjust the width and height attributes of the <svg> element:
<svg width="24" height="24">
<use xlink:href="#desktop-Pin"></use>
</svg>Make sure to import the necessary sprite files in your application before using the icons: This is handled automatically by including the <object> tag in the example above. The <object> tag will load the sprite file asynchronously. The Javascript ensures that the icon is only used after the sprite has loaded.
Run the SVG sprites example on Stackblitz
Here is how you can run the example above on Stackblitz (https://stackblitz.com):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LEAP GUI Icons Example</title>
</head>
<body>
<div id="icon-container"></div>
<script type="module">
async function loadIcon() {
// Fetch the SVG sprite file
const response = await fetch('https://unpkg.com/@leapdev/[email protected]/dist/icons/sprite-desktop.svg');
const svgText = await response.text();
// Add the SVG sprite to the document
const div = document.createElement('div');
div.style.display = 'none';
div.innerHTML = svgText;
document.body.appendChild(div);
// Create and add the icon
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.setAttribute('width', '16');
svg.setAttribute('height', '16');
const use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#desktop-Pin');
svg.appendChild(use);
document.getElementById('icon-container').appendChild(svg);
}
loadIcon();
</script>
</body>
</html>As individual SVGs - React Example
Here's an example of how to use individual SVG icons in a React application:
import React from 'react';
import { FilledHistory, DesktopPin, DoctypeAudio } from '@leapdev/gui-icons';
export default function IconExample() {
return (
<div>
<h1>LEAP GUI Icons Example</h1>
<div style={{ display: 'flex', gap: '20px', alignItems: 'center' }}>
<FilledHistory />
<DesktopPin width={24} height={24} />
<DoctypeAudio width={32} height={32} />
</div>
);
}In this example:
- Import the icons from the
@leapdev/gui-iconspackage. - Use the icons as React components in your JSX.
- Adjust the size of icons using the
widthandheightprops.
Package updates
Refer to the CHANGELOG.md for a detailed update on the icons covered by this package
Releasing
See RELEASING.md for how to publish a new version.
