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

Navbar-brand: define classes for the logo and name #1190

Merged
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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
cSpell:ignore deining docsy gtag
cSpell:ignore deining docsy gtag lookandfeel
-->

# Changelog
Expand Down Expand Up @@ -29,6 +29,10 @@ notes][0.5.0]. **BREAKING CHANGES** are documented below.
- **[Upgraded FontAwesome][]** to v6.1.2 from v5. While many icons were renamed,
the v5 names will still work. For details about icon renames and more, see
[What's changed][].
- **Display logo by default**. Most projects show their logo in the navbar. In
support of this majority, Docsy now displays a logo by default. For details on
how to hide the logo (or your brand name), see [Styling your project logo and
name][].
- **Navbar search-box** width is narrower, as a result of the FontAwesome (FA)
upgrade. You might notice other width changes of elements using FA icons and
the FA font.
Expand All @@ -43,6 +47,8 @@ notes][0.5.0]. **BREAKING CHANGES** are documented below.
[docsy as an npm package]:
https://www.docsy.dev/docs/get-started/other-options/#option-3-docsy-as-an-npm-package
[gtag.js]: https://support.google.com/analytics/answer/10220869
[styling your project logo and name]:
https://www.docsy.dev/docs/adding-content/lookandfeel/#styling-your-project-logo-and-name
[upgraded fontawesome]: https://fontawesome.com/docs/web/setup/upgrade/
[what's changed]: https://fontawesome.com/docs/web/setup/upgrade/whats-changed

Expand Down
5 changes: 2 additions & 3 deletions assets/scss/_nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@
text-transform: none;
text-align: middle;

.nav-link {
display: inline-block;
margin-right: -30px;
Comment on lines -44 to -46
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't have .nav-links inside .navbar-brand and never did as far back as I could search, so I'm deleting this styel

&__name {
font-weight: $font-weight-bold;
}

svg {
Expand Down
10 changes: 5 additions & 5 deletions layouts/partials/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
(not .Site.Params.ui.navbar_translucent_over_cover_disable)
-}}

<nav
class="js-navbar-scroll navbar navbar-expand navbar-dark {{ if $cover }}td-navbar-cover{{ end }} flex-column flex-md-row td-navbar">
<nav class="js-navbar-scroll navbar navbar-expand navbar-dark
{{- if $cover }} td-navbar-cover {{- end }} flex-column flex-md-row td-navbar">
<a class="navbar-brand" href="{{ .Site.Home.RelPermalink }}">
{{- /**/ -}}
<span class="navbar-logo">
{{- if .Site.Params.ui.navbar_logo -}}
<span class="navbar-brand__logo navbar-logo">
{{- if ne .Site.Params.ui.navbar_logo false -}}
{{ with resources.Get "icons/logo.svg" -}}
{{ ( . | minify).Content | safeHTML -}}
{{ end -}}
{{ end -}}
</span>
{{- /**/ -}}
<span class="font-weight-bold">
<span class="navbar-brand__name">
{{- .Site.Title -}}
</span>
{{- /**/ -}}
Expand Down
1 change: 0 additions & 1 deletion userguide/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ params:
sidebar_cache_limit: 10
breadcrumb_disable: false
sidebar_search_disable: false
navbar_logo: true
feedback:
enable: true
'yes': >-
Expand Down
46 changes: 12 additions & 34 deletions userguide/content/en/docs/adding-content/iconsimages.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
---
title: "Logos and Images"
linkTitle: "Logos and Images"
title: Logos and Images
date: 2017-01-05
weight: 6
description: >
Add and customize logos, icons, and images in your project.
description: Add and customize logos, icons, and images in your project.
---

## Add your logo

Add your project logo as `assets/icons/logo.svg` in your project. This overrides the default Docsy logo in the theme. If you don't want a project logo, set `navbar_logo` to `false` (or delete the variable) in your `config.toml`/`config.yaml`/`config.json`:
By default, Docsy shows a site logo at the start of the navbar, that is, at the
extreme left. Place your project's SVG logo in `assets/icons/logo.svg`. This
overrides the default Docsy logo in the theme.

If you don't want a logo to appear in the navbar, then set `navbar_logo` to
`false` in your project's config:

{{< tabpane persistLang=false >}}
{{< tab header="Configuration file:" disabled=true />}}
Expand All @@ -26,35 +29,10 @@ navbar_logo: false
{{< /tab >}}
{{< /tabpane >}}

If you decide at a later stage that you'd like to add a logo to your navbar, you can set the parameter to `true`:

{{< tabpane persistLang=false >}}
{{< tab header="config.toml" lang="toml" >}}
navbar_logo = true
{{< /tab >}}
{{< tab header="config.yaml" lang="yaml" >}}
navbar_logo: true
{{< /tab >}}
{{< tab header="config.json" lang="json" >}}
{
"navbar_logo": true
}
{{< /tab >}}
{{< /tabpane >}}

{{% alert title="Tip" %}}
Your logo is included in the default Docsy navbar as an inline SVG with the following CSS styling (from [`_nav.scss`](https://github.com/google/docsy/blob/main/assets/scss/_nav.scss)):

```
svg {
display: inline-block;
margin: 0 10px;
height: 30px;
}
```
For information about styling your logo, see [Styling your project logo and
name][].

To ensure your logo displays correctly, you may want to resize it, ensure it doesn't have height and width attributes so that its size is fully responsive, or override the default styling with your own CSS.
{{% /alert %}}
[Styling your project logo and name]: /docs/adding-content/lookandfeel/#styling-your-project-logo-and-name

## Add your favicons

Expand All @@ -70,7 +48,7 @@ If you have special favicon requirements, you can create your own `layouts/parti

Docsy's [`blocks/cover` shortcode](/docs/adding-content/shortcodes/#blockscover) make it easy to add large cover images to your landing pages. The shortcode looks for an image with the word "background" in the name inside the landing page's [Page Bundle](https://gohugo.io/content-management/page-bundles/) - so, for example, if you've copied the example site, the landing page image in `content/en/_index.html` is `content/en/featured-background.jpg`.

You specify the preferred display height of a cover block container (and hence its image) using the block's `height` parameter. For a full viewport height, use `full`:
You specify the preferred display height of a cover block container (and hence its image) using the block's `height` parameter. For a full viewport height, use `full`:

```html
{{</* blocks/cover title="Welcome to the Docsy Example Project!" image_anchor="top" height="full" color="orange" */>}}
Expand Down
28 changes: 28 additions & 0 deletions userguide/content/en/docs/adding-content/lookandfeel.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Look and Feel
date: 2017-01-05
weight: 2
description: Customize colors, fonts, code highlighting, and more for your site.
spelling: cSpell:ignore wordmark docsy
---

By default, a site using Docsy has the theme's default fonts, colors, and general look and feel. However, if you want your own color scheme (and you probably will!) you can very easily override the theme defaults with your own project-specific values - Hugo will look in your project files first when looking for information to build your site. And because Docsy uses Bootstrap 4 and SCSS for styling, you can override just single values (such as project colors and fonts) in its special SCSS project variables file, or do more serious customization by creating your own styles.
Expand Down Expand Up @@ -213,7 +214,34 @@ site's [configuration file][].
[configuration file]: https://gohugo.io/getting-started/configuration/#configuration-file
[primary color]: #site-colors

### Styling your project logo and name

The default Docsy navbar (`.td-navbar`) displays your site identity, consisting
of the following:

1. [Your logo][], which is included in the navbar as an inline SVG, styled by
`.td-navbar .navbar-brand svg`. For the style details, see [_nav.scss][].

To ensure your logo displays correctly, you may want to resize it and ensure
that it doesn't have height and width attributes so that its size is fully
responsive. [Override the default styling][project-styles] of `.td-navbar
.navbar-brand svg` or (equivalently) `.td-navbar .navbar-brand__logo` as
needed.
2. Your project name, which is the site `title`. If you don't want your project
name to appear (for example, because your logo is or contains a
[wordmark][]), then add the following custom styling to your [project's
styles][project-styles]:

```css
.td-navbar .navbar-brand__name {
display: none;
}
```

[_nav.scss]: https://github.com/google/docsy/blob/main/assets/scss/_nav.scss
[project-styles]: /docs/adding-content/lookandfeel/#project-style-files
[wordmark]: https://en.wikipedia.org/wiki/Wordmark
[your logo]: /docs/adding-content/iconsimages/#add-your-logo

## Customizing templates

Expand Down