NPM Resource Changed ? ? Pending

User tests: Successful: Unsuccessful:

avatar dgrammatiko
dgrammatiko
20 Nov 2020

Pull Request for Issue # .

Summary of Changes

There are 2 things done in this PR:

  • The code for autogenerating the favicon link is moved to the renderer
  • Both templates moved to using SVG favicons
The code for autogenerating the favicon link is moved to the renderer

Why?
The code used to live in the Document function _loadTemplate and would always ran when parsing the template index (or whatever was instructed to use as index). The proposed change here moves the responsibility to the MetasRenderer because the code spits out a head link and all other headlinks are handled by this renderer. Also the code will never run if a favicon has already been set, meaning it's more efficient (and we like efficiency, right?)!

Both templates moved to using SVG favicons

Why?
Sort answer: because it's 2020. Longer version:
According to https://caniuse.com/link-icon-svg 89.21% of the Browsers already support SVG favicons. Also there's a fallback so in our case it's always 100%.
SVG icons are vector based, meaning they will always look sharp!
SVG icons support light/dark themes
Usually they're lighter than the .ico

Testing Instructions

  • Check the browser tab icon for both the cassiopeia and Atum templates.
  • Open templates/cassiopeia/index.php and delete or mute these lines (40-44)
// Browsers support SVG favicons
$this->addHeadLink(HTMLHelper::image('joomla-favicon.svg', '', [], true, 1),'icon', 'rel', ['type' => 'image/svg+xml']);
$this->addHeadLink(HTMLHelper::image('favicon.ico', '', [], true, 1), 'alternate icon', 'rel', ['type' => 'image/vnd.microsoft.icon']);
$this->addHeadLink(HTMLHelper::image('joomla-favicon-pinned.svg', '', [], true, 1),'mask-icon', 'rel', ['color' => '#000']);
  • copy the file templates/cassiopeia/images/favicon.ico to templates/cassiopeia/favicon.ico and check that you get an icon in the front-page

Actual result BEFORE applying this Pull Request

Expected result AFTER applying this Pull Request

Dark Mode
Screenshot 2020-11-20 at 14 30 46
Light Mode
Screenshot 2020-11-20 at 14 31 44
Safari Pin tab icon
Screenshot 2020-11-20 at 14 30 30

Documentation Changes Required

IDK but there are some great articles out there for the svg favicons, eg https://css-tricks.com/svg-favicons-and-all-the-fun-things-we-can-do-with-them/

avatar dgrammatiko dgrammatiko - open - 20 Nov 2020
avatar dgrammatiko dgrammatiko - change - 20 Nov 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 20 Nov 2020
Category Administration Templates (admin) Libraries Front End Templates (site)
avatar dgrammatiko dgrammatiko - change - 20 Nov 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 20 Nov 2020
Category Administration Templates (admin) Libraries Front End Templates (site) Administration Templates (admin) Repository NPM Change Libraries Front End Templates (site)
ca7e3d7 20 Nov 2020 avatar dgrammatiko CS
avatar dgrammatiko dgrammatiko - change - 20 Nov 2020
Labels Added: NPM Resource Changed
avatar Quy
Quy - comment - 20 Nov 2020

Notice: Undefined index: type in \libraries\src\Document\Renderer\Html\MetasRenderer.php on line 120

avatar Quy
Quy - comment - 20 Nov 2020

Left tab = black favicon with PR
Right tab = color favicon without PR

Expected result?

favicon

avatar dgrammatiko
dgrammatiko - comment - 20 Nov 2020

Expected result?

Yes

avatar N6REJ
N6REJ - comment - 20 Nov 2020

Left tab = black favicon with PR
Right tab = color favicon without PR

Expected result?

favicon

there is a color svg icon available for Joomla logo

avatar dgrammatiko
dgrammatiko - comment - 21 Nov 2020

there is a color svg icon available for Joomla logo

I know but this PR is providing the base functional code for favicons that are adapting depending on the os display settings (dark or light theme) so the coloured svg is irrelevant

avatar ceford
ceford - comment - 21 Nov 2020

I am confused by the testing instructions. My Cssiopeia index.php does not have the lines to be muted/deleted. I have pulled the latest origin from github into my clone and checked the origin does not have those lines either. I my be doing something wrong but I can't think what.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31436.

avatar dgrammatiko
dgrammatiko - comment - 21 Nov 2020

I have pulled the latest origin from github into my clone and checked the origin does not have those lines either.

Probably you need to download the test package from the GitHub PR's page or https://ci.joomla.org/artifacts/joomla/joomla-cms/4.0-dev/31436/downloads/37672/

avatar ceford
ceford - comment - 21 Nov 2020

Sorry - I am a complete idiot! Looking at my previous install for testing and my current install in Eclipse.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31436.

avatar ceford
ceford - comment - 21 Nov 2020

Sorry - I am a complete idiot! Looking at my previous install for testing and my current install in Eclipse.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31436.

avatar ceford
ceford - comment - 21 Nov 2020

Commenting out the given lines and copying favicon.ico results in no favicon. I see this in the source:
<link href="/joomla-cms-4templates/cassiopeia/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
Missing / before templates.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31436.

avatar dgrammatiko
dgrammatiko - comment - 21 Nov 2020

Commenting out the given lines and copying favicon.ico results in no favico

You are right, the logic wasn't right. Please try again, also try to repeat the same muting in the administrator/atum/login.php copying again the favicon.ico from the images subfolder to the atum root (assuming you are logged out of the admin area).

Thanks for testing

avatar richard67
richard67 - comment - 21 Nov 2020

@SniperSister Any idea why the analysis4x step in drone systematically fails for this PR? Maybe it doesn't like the SVG?

avatar ceford ceford - test_item - 21 Nov 2020 - Tested successfully
avatar ceford
ceford - comment - 21 Nov 2020

I have tested this item successfully on 58dd542

I checked Cassiopeia, Atum and Atum login. It was handy to have favicon.ico in colour and favicon.svg in mono - easy to see the change.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31436.

avatar gostn gostn - test_item - 22 Nov 2020 - Tested successfully
avatar gostn
gostn - comment - 22 Nov 2020

I have tested this item successfully on 58dd542


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31436.

avatar bembelimen
bembelimen - comment - 22 Nov 2020

Nice PR ?
Could you please use HTMLHelper::_('image', ....) (instead of HTMLHelper::image to enable the overriding of the method?

avatar dgrammatiko dgrammatiko - change - 22 Nov 2020
Labels Added: ?
avatar richard67
richard67 - comment - 22 Nov 2020

The last commit was not a functional change, so previous tests are still valid, and that last change is good for me by code review.

I'll restore the test results and set RTC.

avatar richard67 richard67 - alter_testresult - 22 Nov 2020 - ceford: Tested successfully
avatar richard67 richard67 - alter_testresult - 22 Nov 2020 - gostn: Tested successfully
avatar richard67 richard67 - change - 22 Nov 2020
Status Pending Ready to Commit
avatar richard67
richard67 - comment - 22 Nov 2020

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31436.

avatar richard67
richard67 - comment - 22 Nov 2020

@zero-24 Could you check analysis4x in drone? It's systematically failing here, but it's very likely a false report.

avatar wilsonge wilsonge - close - 24 Nov 2020
avatar wilsonge wilsonge - merge - 24 Nov 2020
avatar wilsonge wilsonge - change - 24 Nov 2020
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-11-24 12:52:56
Closed_By wilsonge
Labels Added: ?
Removed: ?
avatar wilsonge
wilsonge - comment - 24 Nov 2020

Nice improvement - thanks!

avatar N6REJ
N6REJ - comment - 25 Nov 2020

@dgrammatiko PLEASE write up documentation on this. You've got 4 separate files ( why not a param? ) with nothing explaining how/why 3 favicons, what the values do and their alternatives.

// Browsers support SVG favicons
$this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon.svg', '', [], true, 1), 'icon', 'rel', ['type' => 'image/svg+xml']);
$this->addHeadLink(HTMLHelper::_('image', 'favicon.ico', '', [], true, 1), 'alternate icon', 'rel', ['type' => 'image/vnd.microsoft.icon']);
$this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon-pinned.svg', '', [], true, 1), 'mask-icon', 'rel', ['color' => '#000']);
avatar dgrammatiko
dgrammatiko - comment - 25 Nov 2020
avatar brianteeman
brianteeman - comment - 7 Dec 2020

I miss the colour favicon :(

avatar dgrammatiko
dgrammatiko - comment - 7 Dec 2020

I miss the colour favicon :(

Just switch the svg inner code, but then the dark/light css will have zero effect (btw the code is the same as the rest logos it's just missing the hardcoded fill attributes).
Honestly, I think is way more valuable to have a modern base to build upon rather than having something that we were just used to. Things evolve and dark/light themes are kinda expected for any modern website nowadays...

avatar HLeithner
HLeithner - comment - 7 Dec 2020

So adding the joomla colors to the svg image should fix it? I mean our logo as colors and I miss them too ;-)

avatar dgrammatiko
dgrammatiko - comment - 7 Dec 2020

So adding the joomla colors to the svg image should fix it? I mean our logo as colors and I miss them too ;-)

I think both of you are missing the point here. The codebase as is right now it's a very solid foundation for favicons that adapt according to the user's OS preferences for dark or light theme. If you hardcode the colours then this whole concept goes away and basically, imo, it's a step backward. The code is there to help users/template authors to achieve great results with less effort, not to present the Joomla logo with colour accuracy

avatar HLeithner
HLeithner - comment - 7 Dec 2020

I think you miss the point, the Joomla logo has colors and people creating websites shouldn't use the joomla logo. If we ship a non colored version I'm fine with it but the default logo should have colors.

avatar dgrammatiko
dgrammatiko - comment - 7 Dec 2020

the default logo should have colors.

  • I would agree that preferably wherever the logo is used should be the coloured version.
  • Also I'm in favour of the core showcasing best practices.

Problem is that these two cannot happen simultaneously. I made the call for best practices over colour accuracy of the logo (explained it my reasoning in the comment above).
Of course you can revert that if you think that the colours of the Joomla tiny logo on the favicon is way more important than some code that is self explaining how to be replicated to have adaptive favicon for any logo. As I said you can restore the fill attribute in the elements...

avatar N6REJ
N6REJ - comment - 8 Dec 2020

All the documentation you need is here: https://css-tricks.com/svg-favicons-and-all-the-fun-things-we-can-do-with-them/

says absolutely nothing about how joomla is creating the favicon nor what the params mean/do. Please don't be lazy.

avatar dgrammatiko
dgrammatiko - comment - 8 Dec 2020

@N6REJ check the description of #31512 although really there’s nothing magic here the code is using 2 well documented APIs

Add a Comment

Login with GitHub to post a comment