-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(web-twig): Introduce Icon component #DS-288
Add Icons and svg extension to docker and tests
- Loading branch information
Showing
8 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{# API #} | ||
{%- set _class = props.class | default(null) -%} | ||
{%- set _name = props.name -%} | ||
{%- set _title = props.title | default(null) -%} | ||
|
||
{# Class names #} | ||
{%- set _rootClassName = _spiritClassPrefix ~ 'Icon' -%} | ||
|
||
{# Miscellaneous #} | ||
{%- set _classNames = [ _rootClassName, _class ] -%} | ||
|
||
{{ inlineSvg('@icons-assets/' ~ _name[:1]|upper ~ _name[1:] ~ '.svg', { class: _classNames|join(' '), title: _title }) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Icon | ||
|
||
This is Twig implementation of the [Icon] component. | ||
|
||
Icon component uses inlineSVG extension, so don't forget to add icons path in the configuration | ||
as seen in [inlineSVG docs]. | ||
|
||
Basic example usage: | ||
|
||
```html | ||
<Icon name="warning" /> | ||
``` | ||
|
||
Advanced example usage: | ||
|
||
```html | ||
<Icon name="warning" title="This is warning!" /> | ||
``` | ||
|
||
Without lexer: | ||
|
||
```twig | ||
{% embed "@spirit/icon.twig" with { props: { | ||
name: 'warning' | ||
}} %}{% endembed %} | ||
``` | ||
|
||
## API | ||
|
||
| Prop name | Type | Default | Required | Description | | ||
| --------- | -------- | ------- | -------- | ---------------------------------- | | ||
| `class` | `string` | `null` | no | Custom CSS class | | ||
| `name` | `string` | — | yes | Name of the icon | | ||
| `title` | `string` | `null` | no | Optional title to display on hover | | ||
|
||
Get list of `name` options in the [Icon package] or your source of icons. | ||
|
||
[icon]: https://github.com/lmc-eu/spirit-design-system/tree/main/packages/web/src/components/Icon | ||
[inlinesvg docs]: https://github.com/lmc-eu/spirit-design-system/tree/main/packages/web-twig/docs/inlineSVG.md | ||
[icon package]: https://github.com/lmc-eu/spirit-design-system/tree/main/packages/icons |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{% extends '@spirit/Icon/Icon.twig' %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...g/tests/__snapshots__/ComponentsSnapshotTest__test with data set iconDefault.twig__1.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html><body> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24" fill="none" id="6fccd577f30e270369fb8c9841ad3a1c" class="Icon "> | ||
<path d="M2.72992 21.0001H21.2599C22.0299 21.0001 22.5099 20.1701 22.1299 19.5001L12.8599 3.50006C12.4699 2.83006 11.5099 2.83006 11.1299 3.50006L1.85992 19.5001C1.47992 20.1701 1.95992 21.0001 2.72992 21.0001ZM12.9999 18.0001H10.9999V16.0001H12.9999V18.0001ZM11.9999 14.0001C11.4499 14.0001 10.9999 13.5501 10.9999 13.0001V11.0001C10.9999 10.4501 11.4499 10.0001 11.9999 10.0001C12.5499 10.0001 12.9999 10.4501 12.9999 11.0001V13.0001C12.9999 13.5501 12.5499 14.0001 11.9999 14.0001Z" fill="#132930"></path> | ||
</svg> | ||
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24" fill="none" id="4aadb2a38541dea84df107350619c669" class="Icon "> | ||
<path d="M2.72992 21.0001H21.2599C22.0299 21.0001 22.5099 20.1701 22.1299 19.5001L12.8599 3.50006C12.4699 2.83006 11.5099 2.83006 11.1299 3.50006L1.85992 19.5001C1.47992 20.1701 1.95992 21.0001 2.72992 21.0001ZM12.9999 18.0001H10.9999V16.0001H12.9999V18.0001ZM11.9999 14.0001C11.4499 14.0001 10.9999 13.5501 10.9999 13.0001V11.0001C10.9999 10.4501 11.4499 10.0001 11.9999 10.0001C12.5499 10.0001 12.9999 10.4501 12.9999 11.0001V13.0001C12.9999 13.5501 12.5499 14.0001 11.9999 14.0001Z" fill="#132930"></path> | ||
<title>This is warning!</title></svg> | ||
|
||
</body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<Icon name="warning" /> | ||
<Icon name="warning" title="This is warning!" /> |