@bliss-design-system/icon
v2.6.0
Published
Bliss Design Sytem icon web component, consumes icons from Bliss Iconsets toolkit
Downloads
26
Readme
<bliss-icon>
<bliss-icon>
renders an icon to the page. This web component has been designed to render the icons from the Bliss Iconsets toolkit. Every icon component needs to have a name
attribute.
By design, icons can only be rendered at 24x24 px (medium
) or 48x48 px (large
).
📦 Installation
⚠️ You'll need the Iconsets toolkit installed in order to use this component. You can find the installation instructions here.
To install this component, run:
yarn add @bliss-design-system/icon
🏎 Usage
To use this component, you'll need to register the component to the window
's Custom Elements Registry. In order to achieve that, you'll want to call this function within your application's client-facing entry file:
import { blissRegisterIcon } from '@bliss-design-system/icon';
blissRegisterIcon(); // Registers <bliss-icon>
That will make the component available in your application and you can use it like this:
<!-- Render trash icon at medium size -->
<bliss-icon name="trash"></bliss-icon>
Properties
The component accepts the following properties:
| Property | Type | Description | Default | Required | Options |
| --------------- |:--------------:| :-------------------------:|:-------:|:--------:|:-------:|
| name | String | Size of the icon component | | true | Available icons
| size | String | Size of the icon component | medium
| false | medium
or large
Styling
The <bliss-icon>
component doesn't have any explicit styles. If you want to change the size
of the component, you need to use the size
attribute.
<!-- Render trash icon at large size -->
<bliss-icon name="trash" size="large"></bliss-icon>
By default, the icon will inherit its parent element color
property. This means that if you are using a <bliss-icon>
component inside a button and the text color is red, the icon will inherit this color value and will be red. However, if you wish to color the icon differently you can do so by doing the following:
bliss-icon {
color: blue;
}
You can also use the pattern above to apply any other CSS properties to the bliss-icon
element, but keep in mind that this won't change the svg
inside the <bliss-icon>
, it only affects the element itself.
🫕 Contributing
If you'd like to contribute, please open an issue with your suggested change on our Proposal Board. Once that is accepted, either the Bliss team will work on it or you can make changes locally by doing the following:
# Clone this repository
git clone https://gitlab.com/bliss-design-system/components.git
# Move into the icon package
cd components/packages/icon
# Install the dependencies
yarn
Demoing with Storybook
You can see all of your changes as you make them on Storybook.
To run a local instance of Storybook for this component, run:
yarn storybook
Testing
If you want to test as you develop, run:
yarn test
Please note that the build pipeline will fail if coverage drops by more than 5%.
Committing
We follow the Conventional Commits specification, meaning that you'll be prompted to fill out a descriptive message when you commit. We also use these commits to manage our releases, so we appreciate details.
As a guideline for this component, we use:
fix
for bug fixes, minor stylistic improvements, etc.feat
for any backward compatible API changes.
For anything that breaks backwards compatibility or introduces significant changes that require a major version change, please get in touch with the team.
Opening a merge request
When you're ready to open a merge request, please use a descriptive title and fill out the provided template.
The team will be notified, but it helps to post your merge request in #bliss_support.
🙃 Troubleshooting
We'll fill this section out as we go and as issues are raised. But if you haven't found what you're looking for, get in touch via [email protected] or via the #bliss_support Slack channel ✨.