Skip to content

Commit 8ae65e9

Browse files
authored
🔀 Merge pull request #105 from Lissy93/FEATURE/104_add-image-to-header
[FEATURE] Add option for image in header. Fixes #104. Suggested by @Docrom. To use, set `pageInfo.logo` to the path of image.
2 parents 245be50 + 91ededa commit 8ae65e9

File tree

7 files changed

+38
-7
lines changed

7 files changed

+38
-7
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ Custom links for the navigation menu are defined under [`pageInfo.navLinks`](htt
345345

346346
You can display either custom text or HTML in the footer, using the `pageInfo.footerText` attribute.
347347

348+
To display a logo or image asset next to the title, set `pageInfo.logo` to the path to your picture (either local or remote).
349+
348350
It's also possible to hide parts of the page that you do not need (e.g. navbar, footer, search, heading, etc). This is done using the [`appConfig.hideComponents`](https://github.com/Lissy93/dashy/blob/master/docs/configuring.md#appconfighidecomponents-optional) attribute.
349351

350352
For example, a `pageInfo` section might look something like this:

docs/configuring.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ To disallow any changes from being written to disk via the UI config editor, set
3838
**`description`** | `string` | _Optional_ | Description of your dashboard, also displayed as a subtitle
3939
**`navLinks`** | `array` | _Optional_ | Optional list of a maximum of 6 links, which will be displayed in the navigation bar. See [`navLinks`](#pageinfonavlinks-optional)
4040
**`footerText`** | `string` | _Optional_ | Text to display in the footer (note that this will override the default footer content). This can also include HTML and inline CSS
41+
**`logo`** | `string` | _Optional_ | The path to an image to display in the header (to the right of the title). This can be either local, where `/` is the root of `./public`, or any remote image, such as `https://i.ibb.co/yhbt6CY/dashy.png`. It's recommended to scale your image down, so that it doesn't impact load times
4142

4243
**[⬆️ Back to Top](#configuring)**
4344

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Dashy",
3-
"version": "1.4.4",
3+
"version": "1.4.5",
44
"license": "MIT",
55
"main": "server",
66
"scripts": {

src/components/PageStrcture/Header.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<template>
22
<header>
3-
<PageTitle v-if="titleVisible" :title="pageInfo.title" :description="pageInfo.description" />
3+
<PageTitle
4+
v-if="titleVisible"
5+
:title="pageInfo.title"
6+
:description="pageInfo.description"
7+
:logo="pageInfo.logo"
8+
/>
49
<Nav v-if="navVisible" :links="pageInfo.navLinks" class="nav" />
510
</header>
611
</template>

src/components/PageStrcture/PageTitle.vue

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<template>
22
<router-link to="/" class="page-titles">
3+
<img v-if="logo" :src="logo" class="site-logo" />
4+
<div class="text">
35
<h1>{{ title }}</h1>
46
<span class="subtitle">{{ description }}</span>
7+
</div>
58
</router-link>
69
</template>
710

@@ -11,6 +14,7 @@ export default {
1114
props: {
1215
title: String,
1316
description: String,
17+
logo: String,
1418
},
1519
};
1620
</script>
@@ -20,7 +24,9 @@ export default {
2024
2125
.page-titles {
2226
display: flex;
23-
flex-direction: column;
27+
flex-wrap: wrap;
28+
flex-direction: row;
29+
align-items: center;
2430
text-decoration: none;
2531
h1 {
2632
color: var(--heading-text-color);
@@ -33,7 +39,13 @@ export default {
3339
text-shadow: 1px 1px 2px #130f23;
3440
opacity: var(--dimming-factor);
3541
}
42+
img.site-logo {
43+
margin: 0.2rem 0.5rem 0.2rem 0;
44+
max-width: 3.5rem;
45+
height: fit-content;
46+
}
3647
@include phone {
48+
flex-direction: column;
3749
text-align: center;
3850
padding: 0.25rem 0;
3951
}

src/utils/ConfigAccumalator.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ export default class ConfigAccumulator {
4848
} catch (e) {
4949
localPageInfo = {};
5050
}
51+
const filePageInfo = this.conf.pageInfo || {};
5152
const pi = this.conf.pageInfo || defaults; // The page info object to return
52-
pi.title = localPageInfo.title || conf.pageInfo.title || defaults.title;
53-
pi.description = localPageInfo.description || conf.pageInfo.description || defaults.description;
54-
pi.navLinks = localPageInfo.navLinks || conf.pageInfo.navLinks || defaults.navLinks;
55-
pi.footerText = localPageInfo.footerText || conf.pageInfo.footerText || defaults.footerText;
53+
pi.title = localPageInfo.title || filePageInfo.title || defaults.title;
54+
pi.logo = localPageInfo.logo || filePageInfo.logo || defaults.logo;
55+
pi.description = localPageInfo.description || filePageInfo.description || defaults.description;
56+
pi.navLinks = localPageInfo.navLinks || filePageInfo.navLinks || defaults.navLinks;
57+
pi.footerText = localPageInfo.footerText || filePageInfo.footerText || defaults.footerText;
5658
return pi;
5759
}
5860

src/utils/ConfigSchema.json

+9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@
3939
},
4040
"footerText": {
4141
"type": "string"
42+
},
43+
"logo": {
44+
"type": "string",
45+
"description": "Path to an optional image asset, to be displayed in the header",
46+
"pattern": "^(http|\/)",
47+
"examples": [
48+
"/web-icons/dashy-logo.png",
49+
"https://i.ibb.co/yhbt6CY/dashy.png"
50+
]
4251
}
4352
},
4453
"required": [

0 commit comments

Comments
 (0)