From 0a74122bb21d376f721f38c9212e03fe6475f1e2 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 31 Dec 2019 12:37:11 -0700 Subject: [PATCH] add font-size variable --- hooks.sh | 24 ++++++++++++++++----- hyperglass/__init__.py | 2 +- hyperglass/configuration/models/branding.py | 17 +++++++++++++-- hyperglass/render/templates/theme.sass.j2 | 9 ++++++-- hyperglass/render/webassets.py | 4 ++-- hyperglass/static/src/sass/overrides.sass | 6 ++++-- line_count.svg | 4 ++-- 7 files changed, 50 insertions(+), 16 deletions(-) diff --git a/hooks.sh b/hooks.sh index 050cf95..ea9bcba 100755 --- a/hooks.sh +++ b/hooks.sh @@ -1,10 +1,24 @@ #!/usr/bin/env bash -LC=$(./manage.py line-count-badge) +function make_badge () { + ./manage.py line-count-badge + if [[ ! $? == 0 ]]; then + exit 1 + fi +} -echo $LC +function isort_all () { + isort -y hyperglass/*.py + if [[ ! $? == 0 ]]; then + exit 1 + fi + isort -y hyperglass/**/*.py + if [[ ! $? == 0 ]]; then + exit 1 + fi +} + +make_badge +# isort_all -if [[ ! $? == 0 ]]; then - exit 1 -fi exit 0 \ No newline at end of file diff --git a/hyperglass/__init__.py b/hyperglass/__init__.py index 2118959..9518138 100644 --- a/hyperglass/__init__.py +++ b/hyperglass/__init__.py @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. """ # Standard Library Imports -from datetime import datetime import sys +from datetime import datetime # Third Party Imports import stackprinter diff --git a/hyperglass/configuration/models/branding.py b/hyperglass/configuration/models/branding.py index 80ea351..14be41f 100644 --- a/hyperglass/configuration/models/branding.py +++ b/hyperglass/configuration/models/branding.py @@ -1,6 +1,7 @@ """Validate branding configuration variables.""" # Third Party Imports +from pydantic import StrictStr from pydantic import constr from pydantic import validator from pydantic.color import Color @@ -40,8 +41,20 @@ class Branding(HyperglassModel): class Font(HyperglassModel): """Validation model for params.branding.font.""" - primary: str = "Nunito" - mono: str = "Fira Code" + class Primary(HyperglassModel): + """Validation model for params.branding.font.primary.""" + + name: StrictStr = "Nunito" + size: StrictStr = "1rem" + + class Mono(HyperglassModel): + """Validation model for params.branding.font.mono.""" + + name: StrictStr = "Fira Code" + size: StrictStr = "87.5%" + + primary: Primary = Primary() + mono: Mono = Mono() class HelpMenu(HyperglassModel): """Validation model for params.branding.help_menu.""" diff --git a/hyperglass/render/templates/theme.sass.j2 b/hyperglass/render/templates/theme.sass.j2 index 6750367..6b9ea00 100644 --- a/hyperglass/render/templates/theme.sass.j2 +++ b/hyperglass/render/templates/theme.sass.j2 @@ -4,6 +4,10 @@ $hg-secondary: {{ colors.secondary }} $hg-danger: {{ colors.danger }} $hg-warning: {{ colors.warning }} $hg-background: {{ colors.background }} +$hg-font-primary: {{ font.primary.name }} +$hg-font-primary-size: {{ font.primary.size }} +$hg-font-mono: {{ font.mono.name }} +$hg-font-mono-size: {{ font.mono.size }} // Functions @function findTextColor($color) @@ -87,9 +91,10 @@ $enable-validation-icons: false $theme-colors: ("primary": $hg-primary, "secondary": $hg-secondary, "danger": $hg-danger, "warning": $hg-warning, "light": findTextColor(black), "dark": findTextColor(white), "overlay": $hg-overlay) //// Fonts/Text -$font-family-sans-serif: "{{ font.primary }}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" -$font-family-monospace: "{{ font.mono }}", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace +$font-family-sans-serif: $hg-font-primary, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" +$font-family-monospace: $hg-font-mono, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace $headings-font-weight: 400 +$font-size-base: $hg-font-primary-size //// Borders $border-radius: .5rem diff --git a/hyperglass/render/webassets.py b/hyperglass/render/webassets.py index c28c8b6..ae77245 100644 --- a/hyperglass/render/webassets.py +++ b/hyperglass/render/webassets.py @@ -63,8 +63,8 @@ async def _get_fonts(): log.debug("Downloading theme fonts...") font_base = "https://fonts.googleapis.com/css?family={p}|{m}&display=swap" - font_primary = "+".join(params.branding.font.primary.split(" ")).strip() - font_mono = "+".join(params.branding.font.mono.split(" ")).strip() + font_primary = "+".join(params.branding.font.primary.name.split(" ")).strip() + font_mono = "+".join(params.branding.font.mono.name.split(" ")).strip() font_url = font_base.format(p=font_primary + ":300,400,700", m=font_mono + ":400") font_command = f"node {str(FONT_CMD)} -w -i '{font_url}' -o {str(FONT_DIR)}" diff --git a/hyperglass/static/src/sass/overrides.sass b/hyperglass/static/src/sass/overrides.sass index d761776..3ee2909 100644 --- a/hyperglass/static/src/sass/overrides.sass +++ b/hyperglass/static/src/sass/overrides.sass @@ -310,14 +310,16 @@ background-color: $hg-field-bg !important transition: all .3s !important font-weight: 200 !important - font-size: 1.4rem !important + // font-size: 1.4rem !important + font-size: $font-size-lg opacity: 1 !important pointer-events: auto !important #hg-accordion .btn-link font-weight: 200 - font-size: 1.4rem + // font-size: 1.4rem + font-size: $font-size-lg #hg-accordion .card-body diff --git a/line_count.svg b/line_count.svg index 7f08606..91e20b9 100644 --- a/line_count.svg +++ b/line_count.svg @@ -17,7 +17,7 @@ Lines of Code - 3051 - 3051 + 3060 + 3060 \ No newline at end of file