1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

fix logo file & width parameter handling

This commit is contained in:
checktheroads
2020-03-25 11:23:45 -07:00
parent d0451fd7af
commit 33dc790137
6 changed files with 28 additions and 19 deletions

View File

@@ -158,17 +158,17 @@ By default, no Opengraph image is set. If you define one with `image`, hyperglas
| `query_vrf` | String | `'Routing Table'` | Query VRF form label. |
| `subtitle` | String | `'AS{primary_asn}'` | Subtitle text. `{primary_asn}` will be replaced with the <PageLink to="/docs/configuration#global-settings"><Code>primary_asn</Code></PageLink> value. |
| `title` | String | `'hyperglass'` | Title text. |
| `title_mode` | String | `'text_only'` | Set the title mode. <MiniNote>Must be <Code>text_only</Code>, <Code>logo_only</Code>, <Code>logo_title</Code>, or <Code>all</Code></MiniNote> |
| `title_mode` | String | `'text_only'` | Set the title mode. <MiniNote>Must be <Code>text_only</Code>, <Code>logo_only</Code>, <Code>logo_subtitle</Code>, or <Code>all</Code></MiniNote> |
:::important Title Mode
:::note Title Mode
The `title_mode` parameter behaves in the following manner:
| Mode | Behavior |
| ------------ | ------------------------------------------------------------------ |
| `text_only` | Shows the `title` and `subtitle` only. |
| `logo_only` | Shows the <Link to="#logo">`logo`</Link> only. |
| `logo_title` | Shows the <Link to="#logo">`logo`</Link> and `title` only. |
| `all` | Shows the <Link to="#logo">`logo`</Link>, `title`, and `subtitle`. |
| Mode | Behavior |
| --------------- | ------------------------------------------------------------------ |
| `text_only` | Shows the `title` and `subtitle` only. |
| `logo_only` | Shows the <Link to="#logo">`logo`</Link> only. |
| `logo_subtitle` | Shows the <Link to="#logo">`logo`</Link> and `subtitle` only. |
| `all` | Shows the <Link to="#logo">`logo`</Link>, `title`, and `subtitle`. |
:::

View File

@@ -1,7 +1,7 @@
"""Validate branding configuration variables."""
# Standard Library
from typing import Optional
from typing import Optional, Union
# Third Party
from pydantic import (
@@ -92,8 +92,8 @@ class Logo(HyperglassLevel3):
light: StrictStr = "images/hyperglass-light.png"
dark: StrictStr = "images/hyperglass-dark.png"
width: StrictInt = 384
height: Optional[StrictInt]
width: Optional[Union[StrictInt, constr(regex=r"^([1-9][0-9]?|100)\%$")]] = "80%"
height: Optional[Union[StrictInt, constr(regex=r"^([1-9][0-9]?|100)\%$")]]
favicons: StrictStr = "ui/images/favicons/"
@validator("favicons")
@@ -133,7 +133,9 @@ class Terms(HyperglassLevel3):
class Text(HyperglassLevel3):
"""Validation model for params.branding.text."""
title_mode: constr(regex=("logo_only|text_only|logo_title|all")) = "logo_only"
title_mode: constr(
regex=("logo_only|text_only|logo_title|logo_subtitle|all")
) = "logo_only"
title: StrictStr = "hyperglass"
subtitle: StrictStr = "AS{primary_asn}"
query_location: StrictStr = "Location"
@@ -143,6 +145,13 @@ class Text(HyperglassLevel3):
fqdn_tooltip: StrictStr = "Use {protocol}" # Formatted by Javascript
cache: StrictStr = "Results will be cached for {timeout} {period}."
@validator("title_mode")
def validate_title_mode(cls, value):
"""Set legacy logo_title to logo_subtitle."""
if value == "logo_title":
value = "logo_subtitle"
return value
class ThemeColors(HyperglassLevel4):
"""Validation model for theme colors."""

View File

@@ -4,7 +4,7 @@ import sys
from datetime import datetime
__name__ = "hyperglass"
__version__ = "1.0.0-beta.12"
__version__ = "1.0.0-beta.13"
__author__ = "Matt Love"
__copyright__ = f"Copyright {datetime.now().year} Matthew Love"
__license__ = "BSD 3-Clause Clear License"

View File

@@ -46,10 +46,10 @@ const Logo = ({ text, logo }) => {
const { colorMode } = useColorMode();
const logoColor = { light: logo.dark, dark: logo.light };
const logoPath = logoColor[colorMode];
return <Image src={logoPath} alt={text.title} />;
return <Image src={logoPath} alt={text.title} width={logo.width ?? "auto"} />;
};
const LogoTitle = ({ text, logo, showSubtitle }) => (
const LogoSubtitle = ({ text, logo, showSubtitle }) => (
<>
<Logo text={text} logo={logo} />
<AnimatePresence>
@@ -67,11 +67,11 @@ const All = ({ text, logo, mediaSize, showSubtitle }) => (
</>
);
const modeMap = { text_only: TextOnly, logo_only: Logo, logo_title: LogoTitle, all: All };
const modeMap = { text_only: TextOnly, logo_only: Logo, logo_subtitle: LogoSubtitle, all: All };
const widthMap = {
text_only: "100%",
logo_only: ["90%", "90%", "25%", "25%"],
logo_title: ["90%", "90%", "25%", "25%"],
logo_subtitle: ["90%", "90%", "25%", "25%"],
all: ["90%", "90%", "25%", "25%"]
};

View File

@@ -2,7 +2,7 @@
set -e
HYPERGLASS_VERSION="1.0.0b12"
HYPERGLASS_VERSION="1.0.0b13"
MIN_PYTHON_MAJOR="3"
MIN_PYTHON_MINOR="6"

View File

@@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api"
[tool.poetry]
name = "hyperglass"
version = "1.0.0-beta.12"
version = "1.0.0-beta.13"
description = "hyperglass is the modern network looking glass that tries to make the internet better."
authors = ["Matt Love <matt@hyperglass.io>"]
readme = "README.md"