1.0.4 • Published 4 years ago

@psff/cmp-icon v1.0.4

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

@psff/cmp-icon psff-icon

Component to show icons from an svg sprite file.

Getting started

  1. Setup the package as a dependencie.

    yarn add @psff/cmp-icon
  2. Create an svg sprite file and add to the project. For example, create the file src/assets/svg/sprite.svg with this content:

    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
      <defs>
        <symbol id="circle" viewBox="0 0 129 129">
          <circle cx="50%" cy="50%" r="50%" />
        </symbol>
        (...)
      </defs>
    </svg>
  3. Add the plugin to the Vue instance, set the path to the svg sprite file.

    import SvgSpritePlugin from '@psff/cmp-icon';
    
    Vue.use(
      SvgSpritePlugin,
      {
        svgSpriteFile: require('@/assets/svg/sprite.svg'),
      }
    );
  4. Use the component ''.

    .my-icon {
      --psff-icon-stroke: #000;
      --psff-icon-height: 1rem;
      --psff-icon-width: 1rem;
    
      &.big {
        --psff-icon-height: 5rem;
        --psff-icon-width: 5rem;
      }
    }
    <psff-icon class="my-icon" name="circle" />
    <psff-icon class="my-icon big" name="circle" />

Specifications

Plugin SvgSpritePlugin

This plugin register <psff-icon> component and set the default properties.

Options are:

  • svgSpriteFile (string, optional): url to the svg sprite file

Parameters:

  • svgSpriteFile (string, required): url to the svg sprite file. Not required if you use the plugin specifying a sprite file
  • name (string, required): icon name (defined in the svg sprite)
  • title (string, optional): icon title
  • description (string, optional): icon description

Custom propperties:

  • --psff-icon-display (default inline)
  • --psff-icon-fill (default none)
  • --psff-icon-stroke (default currentColor)
  • --psff-icon-stroke-linecap (default round)
  • --psff-icon-stroke-linejoin (default round)
  • --psff-icon-stroke-width (default 2)
  • --psff-icon-height (default 1em)
  • --psff-icon-width (default 1em)
1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago