1.0.10 • Published 6 months ago

@pixel-forge/cosmo-icons v1.0.10

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
6 months ago

cosmo-icons npm version

Cosmo Icons is a tool that provides common icons in animatable SVG format as react components.

Why?

The point is to provide commonly used icons in a logically structured way inside your project without downloading svg files from other sources. cosmo-icons provides a focused group of icons including classed elements for ease of element targeting and predefined animations for your use.

Installation

via npm:

npm i @pixel-forge/cosmo-icons

Icon Types

There are 3 types of icons:

RegularSolidOutline

Using the icon is done in this manner:

//Call Structure
<CosmoIcons.icon-name.icon-type {props}/>

//Example
<CosmoIcons.gears.solid className={'custom-class'}/>

Structure

icons are wrapped by a "div" element with a class "cosmo-icon" combined with the optional class passed by the user:

const className = `cosmo-icon ${props.className ?? ''}`.trim();
return <div className={className}>
  // SVG element here
</div>

This makes it easier to position icons inside other flows (mainly flex) without affecting the sizing of the icon itself and without adding unnecessary paddings or margins.

SVG elements are prefixed by ci (Cosmo Icons) and follow the double underscore rule, e.g.(gears icon):

return <div className={'cosmo-icon'}>
  //Outer svg element with the encompasing class
  <svg className={'ci__gears'}>
    //Inner path elements following the class rules
    <path d={'...'} className={'ci__gears__gear'}/>
    <path d={'...'} className={'ci__gears__gear'}/>
  </svg>
</div>

Cosmo-icons uses this naming convention for 2 reasons:

  • Consistent structuring makes it easy for the user to target parts of the icon for styling and animating.
  • Cosmo-icons uses these classes to provide pre-made animations.

SVG Custom Attributes

Cosmo-icons uses SASS functions to target specific parts of svg elements and decides whether to apply certain css attributes by the attribute values on the element, in order to apply color more easily. e.g: A path element that looks like this:

<path data-ci-fill="false"/>

Will not be targeted by Cosmo-icons created sass functions that set the css "fill" attribute.

Attributevaluesdescription
data-ci-typesolid, outlineFlags the type of the icon
data-ci-filltrue, falseFlags whether an SVG element should be affected by the css "fill" attribute
data-ci-stroketrue, falseFlags whether an SVG element should be affected by the css "stroke" attribute

License and Copyright

This package is released under the terms of the Apache-2.0 license All the icons in this package are created by us.

1.0.10

6 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago