Code Monkey home page Code Monkey logo

svelte-heroicons's Introduction

svelte-heroicons

License: MIT

Svelte component for Heroicons.

Install

npm i -S @martinse/svelte-heroicons

Usage


<script>
    import Heroicon from '@martinse/svelte-heroicons';
    import {heart as solidHeart} from '@martinse/svelte-heroicons/dist/solid';
    import {heart as outlineHeart} from '@martinse/svelte-heroicons/dist/outline';
</script>


<Heroicon icon={outlineHeart}/>
<Heroicon icon={outlineHeart} size="2em"/>
<Heroicon icon={solidHeart} size="3em" class="red"/>


<style>
    :global(.red) {
        color: red;
    }
</style>

Will render:

output

Build / development

In order to build new versions of this package, there some prerequisites to be installed, and some commands to execute. The build process is executed within a Docker container.

Prerequisites

Building the Docker container

task build

Building the package

Building the package is composed of two stes:

  1. Download and generate icon data from a specific Heroicons version
  2. Build the NPM package
task generate-icon-data
task build-npm-dist

Publish to NPM

  • Update the version in package.json
  • Tag and push to GitHub
  • Publish to NPM:
task publish

Update Heroicons version

Update the HEROICONS_VERSION variable in Taskfile.yml and rebuild the Docker container + build/publish the NPM package.

Improvements

  • Avoid the /dist path when importing solid or outline
  • Investigate using this package with Svelte + Snowpack (or SvelteKit) as there seems to be an issue with the Rollup configuration
  • Add tests
  • Add linting
  • Create a proper demo page + figure out how to publish a Svelte app to GitHub pages
  • Sync version in Taskfile.yml and package.json automatically
  • Implement task publish
  • Add git tags for published versions
  • Probably a lot more, feel free to create issues on what can be improved!

License

MIT

svelte-heroicons's People

Contributors

martinse avatar

Stargazers

Henri avatar Sean Fulmer avatar Brian Ketelsen avatar Ben Woodward avatar Rafael Ferreira avatar Hung Vu avatar Neil Jagdish Patel avatar Nik Myers avatar  avatar jET avatar Marian Meres avatar Denis Donici avatar  avatar Tane Piper avatar

Watchers

James Cloos avatar  avatar

svelte-heroicons's Issues

Cannot read properties of undefined (reading 'svg')

500 error trying to use this library with SvelteKit 1.0.0-next.251.

My component:

<script>
  import Icon from '@martinse/svelte-heroicons';
  import { heart } from '@martinse/svelte-heroicons/dist/outline';
</script>
<Icon icon={outlineHeart} size="2em" />

The error:

Cannot read properties of undefined (reading 'svg')
TypeError: Cannot read properties of undefined (reading 'svg')
    at Heroicon.svelte:7:20
    at Object.$$render (/home/user/repo/node_modules/.pnpm/[email protected]/node_modules/svelte/internal/index.js:1745:22)
    at index.svelte:91:12
    at Object.$$render (/home/user/repo/node_modules/.pnpm/[email protected]/node_modules/svelte/internal/index.js:1745:22)
    at Object.default (root.svelte:38:47)
    at eval (/src/routes/__layout.svelte:36:38)
    at Object.$$render (/home/user/repo/node_modules/.pnpm/[email protected]/node_modules/svelte/internal/index.js:1745:22)
    at root.svelte:32:45
    at $$render (/home/user/repo/node_modules/.pnpm/[email protected]/node_modules/svelte/internal/index.js:1745:22)

Looks like icon is undefined in Heroicon svelte when attempting to assign to svgProps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.