Skip to content

Use relative paths to handle component icons - #823

Open
piotr-cz wants to merge 3 commits into
agentejo:nextfrom
piotr-cz:cs/component-icons-path
Open

Use relative paths to handle component icons#823
piotr-cz wants to merge 3 commits into
agentejo:nextfrom
piotr-cz:cs/component-icons-path

Conversation

@piotr-cz

@piotr-cz piotr-cz commented Jul 20, 2018

Copy link
Copy Markdown
Contributor

This makes components use base name as an icon, instead of full URL.
Required for agentejo/LayoutComponents#1

@aheinze

aheinze commented Jul 23, 2018

Copy link
Copy Markdown
Member

I'm not sure about that. this PR would limit the ability to use custom icons 🤔

@piotr-cz

piotr-cz commented Jul 24, 2018

Copy link
Copy Markdown
Contributor Author

Actually it unlocks the ability to use custom icons by ability to define icon base name (ie.business.svg)
instead of absolut url which is required at the moment (/path/to/cockpit/assets/app/media/icon/business.svg).

However developer won't be able to define custom icons which are outside /path/to/cockpit/assets/app/media/icon/ directory.
Compromise would be ability to define icon file as relative url to cockpit base url (./assets/app/media/icon/business.svg)

@aheinze

aheinze commented Jul 24, 2018

Copy link
Copy Markdown
Member

I think a compromise would be to introduce a pattern like icons:code.svg for icons located in /assets/app/media/icons/ otherwise handle it as a link.

@piotr-cz

Copy link
Copy Markdown
Contributor Author

You mean by adding a system path, that would be used as icons directory?

$app->path('#icons', COCKPIT_DIR . '/assets/app/media/icons');

@piotr-cz

piotr-cz commented Jul 25, 2018

Copy link
Copy Markdown
Contributor Author

I think adding new path for icons (so it's possile to use icons from outside of /assets/app/media/icons) other feature out of scope of this PR, there would have to be changes in any module that uses icons (collection, forms, singletons).

In latest commit I've changed paths handling so it's working with icons in similar way how collection module is:

App.base('/assets/media/icons' + icon) -> '@url('assets:app/media/icons/')' + icon.


Update: Ah, I forgot that the @url expression is not available in frontend, so reverting latest commit

@aheinze How can one use custom icons now? I didn't know it's possible.
Actually I created this PR use custom icons for layout component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants