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

EZP-29998 As a developer, I want to define icons for Content Types #520

Merged
merged 5 commits into from
Feb 1, 2019

Conversation

MagdalenaZuba
Copy link
Contributor

Question Answer
JIRA Ticket ezsystems/ezplatform-admin-ui#804 (comment)
Versions master

Copy link
Member

@adamwojs adamwojs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two missing notes:

  • Icons should be in SVG format (at least for the admin siteaccesses)
  • Configuration is siteaccess aware


### Configuration

A configuration of the default icon for Content Type is possible via default-config key.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A configuration of the default icon for Content Type is possible via default-config key.
A configuration of the default icon for Content Type is possible via `default-config` key.

thumbnail: '/assets/images/mydefaulticon.svg'
```

Configuration of a custom icon will be exactly the same, you just need to replace default-config key with a custom one.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Configuration of a custom icon will be exactly the same, you just need to replace default-config key with a custom one.
Configuration of a custom icon will be exactly the same, you just need to replace default-config key with a content type identifier.

### Custom icons in Twig templates

Content Type icons are accessible in Twig templates via `ez_content_type_icon` function.
It requires Content Type or Content Type Identifier as an argument. Function returns path to a Content Type icon.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It requires Content Type or Content Type Identifier as an argument. Function returns path to a Content Type icon.
It requires Content Type Identifier as an argument. Function returns path to a Content Type icon.

</svg>
```

If the icon for given Content Type is not specified in the configuration then path to the default icon will be returned.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If the icon for given Content Type is not specified in the configuration then path to the default icon will be returned.
If the icon for given Content Type is not specified in the configuration then default icon will be returned.

system:
default:
content_type:
default-config:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default-config:
article:

@adamwojs adamwojs requested a review from tischsoic January 30, 2019 20:06
<use xlinkHref={contentTypeIcon} />
</svg>
);
```
Copy link
Contributor

@tischsoic tischsoic Jan 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rewrite this part to something like:
(more or less, I'm bad writer, so you can change if you feel that something is not smooth :) )

Content Types icons configuration is stored in global object: eZ.adminUiConfig.contentTypes.

You can easily retrieve icon url with helper function getContentTypeIconUrl(contentTypeIdentifier), set on global object eZ.helpers.contentType. It takes Content Type Identifier as an argument and returns url of given content type's icon or null in case there is no content type with given identifier.

Example:

const contentTypeIconUrl = eZ.helpers.contentType.getContentTypeIconUrl(contentTypeIdentifier);
return (
   <svg className="ez-icon">
       <use xlinkHref={contentTypeIconUrl} />
   </svg>
);

@@ -503,6 +503,70 @@ class OrderedTabSubscriber implements EventSubscriberInterface
}
```

## Custom Content Type icons

To add custom icons for existing Content Types or custom Content Types in eZ Platform follow below instruction.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To add custom icons for existing Content Types or custom Content Types in eZ Platform follow below instruction.
To add custom icons for existing Content Types or custom Content Types in eZ Platform follow the instructions below.

thumbnail: '/assets/images/mydefaulticon.svg'
```

Configuration of a custom icon will be exactly the same, you just need to replace default-config key with a Content Type identifier.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Configuration of a custom icon will be exactly the same, you just need to replace default-config key with a Content Type identifier.
Configuration of a custom icon will be exactly the same, you just need to replace the `default-config` key with a Content Type identifier.

### Custom icons in Twig templates

Content Type icons are accessible in Twig templates via `ez_content_type_icon` function.
It requires Content Type identifier as an argument. Function returns path to a Content Type icon.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It requires Content Type identifier as an argument. Function returns path to a Content Type icon.
It requires Content Type identifier as an argument. The function returns the path to a Content Type icon.


Example with `getContentTypeIcon`:

```React JSX
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React jsx is not recognised as a language and breaks rendering. jsx might work.

@MagdalenaZuba MagdalenaZuba merged commit 99f21b0 into master Feb 1, 2019
@MagdalenaZuba MagdalenaZuba deleted the custom_content_type_icons branch February 1, 2019 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants