Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(icon): Webtools icons - FRONT-4688 #3736

Open
wants to merge 18 commits into
base: v4-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test data
  • Loading branch information
emeryro committed Nov 26, 2024
commit 4e730af5da1693e8abfdcc2db850025c7b494fdc
44 changes: 27 additions & 17 deletions src/implementations/twig/components/icon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,34 @@ npm install --save @ecl/twig-component-icon

### Parameters

- **"icon"** (associative array) (default: 'predefined structure below')
- "path" (string) (default: '') - path/url to general icon file (eg. /path-to-icon/icon.svg)
- "name" (string) (default: '') - name of icon, eg. 'facebook', 'twitter'.
- "size" (string) (default: 'm') size of icon. Available sizes are 'xs','s','m','l','xl','2xl','fluid'
- "transform" (string) (default: '') Transformation of icon. Available transformations are 'rotate-0', 'rotate-90', 'rotate-180', 'rotate-270', 'flip-horizontal', 'flip-vertical')
- "color" (string) (default: '') Color of icon. Available colors are 'default', 'inverted', 'primary'
- "title": '' (string) (default: '') Additional title for the icon; shortcut for extra accessibility title
- **"as_image"**: (boolean) (default: false) Whether the icon is used as an image
- **"icon"** (associative array) (default: predefined structure):
{
path (string) (default: ''): path to the icon file,
name (string) (default: ''): name of the icon,
size (string) (default: 'm'): icon size (available options: '2xs', 'xs','s','m','l','xl','2xl','fluid'),
transform (string) (default: ''): icon transformation (available options: 'rotate-0', 'rotate-90', 'rotate-180', 'rotate-270', 'flip-horizontal', 'flip-vertical'),
color (string) (default: ''): icon color (available options: 'default', 'inverted', 'primary')
title (string) (default: ''): additional title for the icon; shortcut for extra accessibility title parameter
}
- **"as_image"** (boolean) (default: false): should the icon be dipslayed as an image?
- **"wt_markup"** (boolean) (default: false): should the icon use the Webtools markup?
- **"extra_accessibility"** (optional) (object) Extra tags for accessibility when used as an image
- description: '' (desc tag)
- description_id: '' (desc tag id)
- title: '' (title tag)
- title_id: '' (title tag id)
- **"extra_classes"** (optional) (string) (default: '') Extra classes (space separated)
- **"extra_attributes"** (optional) (array) (default: []) Extra attributes
- "name" (string) Attribute name, eg. 'data-test'
- "value" (string) Attribute value, eg: 'data-test-1'
- **"extra_accessibility"** (associative array) (default: {}):
{
description (string) (default: ''): additional description
description_id (string) (default: ''): unique id for the description
title (string) (default: ''): additional title
title_id (string) (default: ''): unique id for the title
role (string) (default: ''): role attribute
}
- **"extra_classes"** (string) (default: ''): additional classes (space separated)
- **"extra_attributes"** (array) (default: []):
[
{
name (string) (default: ''),
value (string) (default: ''),
}
...
],

### Example:

Expand Down
64 changes: 44 additions & 20 deletions src/implementations/twig/components/icon/icon.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,31 @@
{#
Parameters:
- "icon" (associative array) (default: predefined structure): format:
{
path (string) (default: ''): path to the icon file,
name (string) (default: ''): name of the icon,
size (string) (default: 'm'): icon size (available options: '2xs', 'xs','s','m','l','xl','2xl','fluid'),
transform (string) (default: ''): icon transformation (available options: 'rotate-0', 'rotate-90', 'rotate-180', 'rotate-270', 'flip-horizontal', 'flip-vertical'),
color (string) (default: ''): icon color (available options: 'default', 'inverted', 'primary')
title (string) (default: ''): additional title for the icon; shortcut for extra accessibility title parameter
}
- "as_image" (boolean) (default: false): should the icon be dipslayed as an image?
- "wt_markup" (boolean) (default: false): should the icon use the Webtools markup?
- "extra_accessibility" (associative array) (default: {}):
{
description (string) (default: ''): additional description
description_id (string) (default: ''): unique id for the description
title (string) (default: ''): additional title
title_id (string) (default: ''): unique id for the title
role (string) (default: ''): role attribute
}
- "extra_classes" (string) (default: ''): additional classes (space separated)
- "extra_attributes" (array) (default: []):
[
{
path: '/static/media/icons.cbfd6efe.svg',
name: '',
size: 'm' (available options: 'xs','s','m','l','xl','2xl','fluid'),
transform: 'rotate-0' (available options: 'rotate-0', 'rotate-90', 'rotate-180', 'rotate-270', 'flip-horizontal', 'flip-vertical'),
color: 'default' (available options: 'default', 'inverted', 'primary')
title: '' (additional title for the icon; shortcut for extra accessibility title)
name (string) (default: ''),
value (string) (default: ''),
}
- "as_image": false,
- "wt_markup" (bool) (default: false): should the icon use the Webtools markup?
- "extra_accessibility" : {
description: '' (desc tag)
description_id: '' (desc tag id)
title: '' (title tag)
title_id: '' (title tag id)
role: 'image' (role attribute)
}
- "extra_classes" (string) (default: '')
- "extra_attributes" (array) (default: []): format: [
{
"name" (string) (default: ''),
"value" (optional) (string)
...
],
#}
Expand Down Expand Up @@ -115,9 +118,30 @@
focusable="false"
aria-hidden="{{ _aria_hidden }}"
{{ _extra_attributes|raw }}>

{% if _extra_accessibility.title is not empty %}
<title
{% if _extra_accessibility.title_id is not empty %}
id="{{ _extra_accessibility.title_id }}"
{% endif %}
>
{{- _extra_accessibility.title -}}
</title>
{% endif %}
{% if _extra_accessibility.description is not empty %}
<desc
{% if _extra_accessibility.description_id is not empty %}
id="{{ _extra_accessibility.description_id }}"
{% endif %}
>
{{- _extra_accessibility.description -}}
</desc>
{% endif %}

</span>

{% else %}

<svg
class="{{ _css_class }}"
focusable="false"
Expand Down
5 changes: 4 additions & 1 deletion src/implementations/twig/components/icon/icon.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ const prepareData = (data, args) => {
data.icon.name = args.name;
data.icon.size = args.size;
data.icon.color = args.color;
data.extra_classes = data.icon.color === 'inverted' ? 'ecl-u-bg-dark' : '';
data.extra_classes =
data.icon.color === 'inverted'
? `ecl-u-bg-dark ${data.extra_classes}`
: data.extra_classes;
data.icon.transform = args.transform;
return data;
};
Expand Down
4 changes: 4 additions & 0 deletions src/implementations/vanilla/components/icon/icon-print.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ $theme: null !default;
fill: map.get($theme, 'color', 'white');
}

.ecl-icon--rotate-0 {
transform: rotateZ(0deg);
}

.ecl-icon--rotate-90 {
transform: rotateZ(90deg);
}
Expand Down
4 changes: 4 additions & 0 deletions src/implementations/vanilla/components/icon/icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ $icons: null !default;
fill: map.get($theme, 'color', 'white');
}

.ecl-icon--rotate-0 {
transform: rotateZ(0deg);
}

.ecl-icon--rotate-90 {
transform: rotateZ(90deg);
}
Expand Down
14 changes: 14 additions & 0 deletions src/specs/components/icon/demo/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,18 @@ module.exports = {
name: 'audio',
size: 'm',
},
wt_markup: true,
extra_classes: 'test',
extra_attributes: [
{
name: 'id',
value: 'test',
},
],
extra_accessibility: {
title: 'title',
title_id: 'title-id',
description: 'additional description',
description_id: 'desc-id',
},
};
Loading