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

UHF-4571: Hel.fi favicons #432

Merged
merged 9 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
Binary file removed favicon.ico
Binary file not shown.
5 changes: 5 additions & 0 deletions hdbt.theme
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ function hdbt_preprocess_html(&$variables) {
else {
$variables['#attached']['library'][] = 'hdbt/nav-local';
}

// Add theme path to as variable.
$variables['theme_path'] = '/' . \Drupal::service('theme_handler')
->getTheme('hdbt')
->getPath();
}

/**
Expand Down
42 changes: 42 additions & 0 deletions modules/hdbt_content/hdbt_content.install
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,45 @@ function hdbt_content_install_block_translations(array $translations, string $bl
->save();
}
}

/**
* Manually update HDBT and HDBT Subtheme favicon settings.
*/
function hdbt_content_update_9006() {
$theme_handler = Drupal::service('theme_handler');
$config_factory = \Drupal::configFactory();

// Handle HDBT theme.
if ($theme_handler->themeExists('hdbt')) {

// Update HDBT favicon settings.
$hdbt = $config_factory->getEditable('hdbt.settings');
$hdbt_data = $hdbt->getRawData();
if (!empty($hdbt_data)) {
$hdbt_data['favicon']['path'] = '';
$hdbt_data['favicon']['use_default'] = 0;
$hdbt->setData($hdbt_data)->save(TRUE);
}
}

// Handle HDBT Subtheme.
if ($theme_handler->themeExists('hdbt_subtheme')) {

// Update HDBT favicon settings.
$hdbt_subtheme = $config_factory->getEditable('hdbt_subtheme.settings');
$hdbt_subtheme_data = $hdbt_subtheme->getRawData();
if (!empty($hdbt_subtheme_data)) {
$hdbt_subtheme_data['favicon']['path'] = '';
$hdbt_subtheme_data['favicon']['use_default'] = 0;
}
else {
$hdbt_subtheme_data = [
'favicon' => [
'use_default' => 0,
'path' => '',
],
];
}
$hdbt_subtheme->setData($hdbt_subtheme_data)->save(TRUE);
}
}
1 change: 1 addition & 0 deletions src/images/favicon/LICENCE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This work is lisenced under CC BY 4.0, except where otherwise stated. The City of Helsinki logo is a registered trademark. The Helsinki Grotesk Typeface is a proprietary typeface licensed by Camelot Typefaces.
26 changes: 26 additions & 0 deletions src/images/favicon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# HDS Favicon kit

Here are the favicons to be used on desktop and mobile web browsers. If you need the Helsinki-logo for general use instead it is available on [the Helsinki brand site](https://brand.hel.fi/tunnus/).

The favicons are available in the following sizes and formats:

* favicon-32x32.ico (32x32px)

* favicon.svg (512x512px, dark mode support)

* apple-touch-icon.png (180x180px)

* favicon-192x192.png (192x192px, webmanifest)

* favicon-512x512.png (512x512px, webmanifest)

#### How to use favicons

1. Deploy the favicon image and manifest files to your CDN.

2. Add the tags to your index.html between the <head> tags and update image file paths if needed.

<link rel="icon" href="./favicon-32x32.ico" sizes="any">
<link rel="icon" href="./favicon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="./apple-touch-icon.png">
<link rel="manifest" href="./manifest.webmanifest">
Binary file added src/images/favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/favicon/favicon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/favicon/favicon-32x32.ico
Binary file not shown.
Binary file added src/images/favicon/favicon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/images/favicon/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/images/favicon/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"short_name": "hel.fi",
"name": "Helsingin kaupunki",
"icons": [
{ "src": "/favicon-192x192.png", "type": "image/png", "sizes": "192x192" },
{ "src": "/favicon-512x512.png", "type": "image/png", "sizes": "512x512" }
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "browser"
}
4 changes: 4 additions & 0 deletions templates/layout/html.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<head>
<head-placeholder token="{{ placeholder_token }}">
<title>{{ head_title|safe_join(' | ') }}</title>
<link rel="icon" href="{{ theme_path }}/src/images/favicon/favicon-32x32.ico" sizes="any">
<link rel="icon" href="{{ theme_path }}/src/images/favicon/favicon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="{{ theme_path }}/src/images/favicon/apple-touch-icon.png">
<link rel="manifest" href="{{ theme_path }}/src/images/favicon/manifest.webmanifest">
<css-placeholder token="{{ placeholder_token }}">
<js-placeholder token="{{ placeholder_token }}">
</head>
Expand Down