Skip to content

Commit 069d1ff

Browse files
authored
Detailed icon functions and icon sets usages (#3027)
1 parent 06389a3 commit 069d1ff

2 files changed

Lines changed: 39 additions & 12 deletions

File tree

docs/administration/back_office/back_office_elements/custom_icons.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ ibexa:
1515
content_type:
1616
article:
1717
thumbnail: /assets/images/custom_icon.svg#custom
18+
category:
19+
thumbnail: /bundles/ibexaadminuiassets/vendors/ids-assets/dist/img/all-icons.svg#folder
1820
```
1921
2022
Place the icon in `public/assets/images` and run `yarn encore <dev|prod>` after adding it.
@@ -23,13 +25,15 @@ Place the icon in `public/assets/images` and run `yarn encore <dev|prod>` after
2325

2426
To ensure proper display in the back office, all icons should have SVG format with `symbol`.
2527

26-
If you want to configure icons per SiteAccess, see [Icon sets](#icon-sets).
28+
Use the [scope](multisite_configuration.md#scope) if you want different icons for different SiteAccesses.
2729

28-
To see more configuration options, see [the icon reference](icon_twig_functions.md).
30+
To see more Admin UI's `ids-assets` icons, see [the icon reference](icon_twig_functions.md#icons-reference).
2931

3032
### Access icons in Twig templates
3133

32-
Content type icons are accessible in Twig templates via the `ibexa_content_type_icon` function.
34+
#### Content type icons
35+
36+
Content type icons are accessible in Twig templates via the [`ibexa_content_type_icon()` function](icon_twig_functions.md#ibexa_content_type_icon).
3337
It requires content type identifier as an argument. The function returns the path to a content type icon.
3438

3539
```twig
@@ -38,6 +42,10 @@ It requires content type identifier as an argument. The function returns the pat
3842
</svg>
3943
```
4044

45+
#### UI Icons
46+
47+
User interface icons are accessible with [`ibexa_icon_path()` function](icon_twig_functions.md#ibexa_icon_path). The function returns a path from an icon identifier and an [icon set](#icon-sets) identifier arguments.
48+
4149
### Access icons in JavaScript
4250

4351
Content types icons configuration is stored in a global object: `ibexa.adminUiConfig.contentTypes`.
@@ -89,7 +97,9 @@ The following example from the `alert.js` file shows configuration for icons in
8997
- `name` - the path is generated inside the component provided you use icon from the system
9098
- `extraClasses` - additional CSS classes, use to set for example, icon size.
9199

92-
## Icon sets
100+
## Customize UI icons
101+
102+
### Icon sets
93103

94104
You can configure icon sets to be used per SiteAccess:
95105

@@ -103,3 +113,11 @@ ibexa:
103113
additional_icons: /assets/images/icons/additional_icons.svg
104114
default_icon_set: my_icons
105115
```
116+
117+
The icon sets are used by [`ibexa_icon_path()` Twig function](icon_twig_functions.md#ibexa_icon_path).
118+
119+
- If you change the `default_icon_set` from one SiteAccess to another, `ibexa_icon_path(icon)` without `set` argument targets icons from different set files
120+
- If you change the file path of an icon set from one SiteAccess to another, `ibexa_icon_path(icon, set)` with the same `set` argument targets icons from different set files
121+
122+
The built-in default icon set is `ids-assets` (corresponding to `/bundles/ibexaadminuiassets/vendors/ids-assets/dist/img/all-icons.svg`).
123+
To see the icons available in this set, see [the icon reference](icon_twig_functions.md#icons-reference).

docs/templating/twig_function_reference/icon_twig_functions.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ month_change: false
66

77
# Icon Twig functions
88

9-
### `ibexa_icon_path()`
9+
## `ibexa_icon_path()`
1010

1111
`ibexa_icon_path()` generates a path to the selected icon from an [icon set](custom_icons.md#icon-sets).
1212

13-
|Argument|Type|Description|
14-
|------|------|------|
15-
|`icon`|`string`|Identifier of an icon in the icon set.|
16-
|`set`|`string`|Identifier of the configured icon set. If empty, the default icon set is used.|
13+
| Argument | Type | Description |
14+
|----------|----------|--------------------------------------------------------------------------------|
15+
| `icon` | `string` | Identifier of an icon in the icon set. |
16+
| `set` | `string` | Identifier of the configured icon set. If empty, the default icon set is used. |
1717

1818
```html+twig
1919
<svg class="ibexa-icon ibexa-icon--medium ibexa-icon--light">
@@ -23,7 +23,7 @@ month_change: false
2323

2424
The icons can be displayed in different colors and sizes.
2525

26-
#### Icon color variants
26+
### Icon color variants
2727

2828
By default, the icon inherits the [`fill`](https://developer.mozilla.org/en-US/docs/Web/CSS/fill) attribute from the parent element.
2929
You can change it by using one of the available CSS modifiers:
@@ -42,7 +42,7 @@ You can change it by using one of the available CSS modifiers:
4242
</svg>
4343
```
4444

45-
#### Icon size variants
45+
### Icon size variants
4646

4747
The default icon size in the back office is `32px`.
4848
To change the default size, in the template add the modifier to the class name.
@@ -66,7 +66,7 @@ The list of available icon sizes:
6666
|`--large`|`48px`|
6767
|`--extra-large`|`64px`|
6868

69-
#### Icons reference
69+
### Icons reference
7070

7171
The following icons are available out-of-the-box:
7272

@@ -604,3 +604,12 @@ The following icons are available out-of-the-box:
604604
| ![zoom-in](img/icons/zoom-in.svg.png) | `zoom-in` |
605605
| ![zoom-out](img/icons/zoom-out.svg.png) | `zoom-out` |
606606

607+
## `ibexa_content_type_icon()`
608+
609+
`ibexa_content_type_icon()` generates a path to a content type icon.
610+
611+
| Argument | Type | Description |
612+
|----------------|----------|--------------------------|
613+
| `content_type` | `string` | Content type identifier. |
614+
615+
See [Customize content type icons](custom_icons.md#customize-content-type-icons) to associate icons to content types.

0 commit comments

Comments
 (0)