From c6dc06f184ef79d2fd68ab98895f6ab0c08e4aac Mon Sep 17 00:00:00 2001 From: Carlos Wu Date: Thu, 19 Oct 2023 09:51:40 +0200 Subject: [PATCH] Data bubble navigation (#1056) --- .stylelintrc | 1 - package.json | 4 +- static/sass/_pattern_global-nav.scss | 115 +++++++++++++++++ static/sass/styles.scss | 12 +- templates/data/_form-data-kafka.html | 4 +- templates/data/_form-data-opensearch.html | 4 +- templates/data/index.html | 129 ++++++++++++-------- templates/partial/_data-navigation.html | 49 ++++++++ templates/partial/_navigation.html | 88 ++----------- templates/partial/_standard-navigation.html | 74 +++++++++++ yarn.lock | 12 ++ 11 files changed, 358 insertions(+), 134 deletions(-) create mode 100644 static/sass/_pattern_global-nav.scss create mode 100644 templates/partial/_data-navigation.html create mode 100644 templates/partial/_standard-navigation.html diff --git a/.stylelintrc b/.stylelintrc index 9d17b00ac..644d34522 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -5,7 +5,6 @@ ], "ignoreFiles": ["static/sass/_hljs.scss"], "rules": { - "order/properties-alphabetical-order": true, "no-invalid-position-at-import-rule": null, "scss/at-mixin-pattern": null, "declaration-empty-line-before": null, diff --git a/package.json b/package.json index d5d6192dd..57253163e 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,11 @@ "watch-js": "watch -p 'static/js/**/!(*.test)*.{jsx,ts,tsx}' -c 'node build.js'", "build": "yarn run build-css && yarn run build-js", "build-css": "sass static/sass/styles.scss static/css/styles.css --load-path=node_modules --style=compressed && postcss --map false --use autoprefixer --replace 'static/css/**/*.css'", - "build-js": "node build.js && yarn run build-cookie-policy && yarn run build-fuse && yarn run build-latest-news", + "build-js": "node build.js && yarn run build-cookie-policy && yarn run build-fuse && yarn run build-latest-news && yarn run build-global-nav", "build-cookie-policy": "mkdir -p static/js/modules/cookie-policy && cp node_modules/@canonical/cookie-policy/build/js/cookie-policy.js static/js/modules/cookie-policy", "build-latest-news": "mkdir -p static/js/modules/latest-news && cp node_modules/@canonical/latest-news/dist/latest-news.js static/js/modules/latest-news", "build-fuse": "mkdir -p static/js/modules/fuse && cp node_modules/fuse.js/dist/fuse.js static/js/modules/fuse", + "build-global-nav": "mkdir -p static/js/modules/global-nav && cp node_modules/@canonical/global-nav/dist/global-nav.js static/js/modules/global-nav", "format-python": "black --line-length 79 webapp tests", "format-prettier": "prettier -w 'static/js/*.{js,jsx,ts,tsx}' 'static/sass/*.scss'", "lint-python": "flake8 --extend-ignore=E203 webapp tests && black --check --line-length 79 webapp tests", @@ -25,6 +26,7 @@ "dependencies": { "@canonical/cookie-policy": "3.5.0", "@canonical/latest-news": "1.4.1", + "@canonical/global-nav": "3.6.1", "@testing-library/cypress": "9.0.0", "autoprefixer": "10.4.13", "concurrently": "7.6.0", diff --git a/static/sass/_pattern_global-nav.scss b/static/sass/_pattern_global-nav.scss new file mode 100644 index 000000000..ae2a144bd --- /dev/null +++ b/static/sass/_pattern_global-nav.scss @@ -0,0 +1,115 @@ +@mixin canonical-p-global-nav { + .global-nav__row { + max-width: $grid-max-width; + } + + // Using id to override inherited styles from Vanilla and project + #g-navigation { + background-color: $color-dark; + height: 2rem; + line-height: 1rem; + + @media screen and (max-width: $breakpoint-large - 1) { + .p-navigation__nav { + height: 100vh; + left: 0; + padding-top: 0.5rem; + position: relative; + top: -1rem; + width: 100%; + } + } + + .p-global-nav-anchors { + @extend %small-text; + + color: $color-mid-light; + font-weight: $font-weight-thin; + padding-top: 0.3rem; + padding-bottom: 0; + text-decoration: none; + } + + .p-navigation__nav { + background-color: $color-dark; + } + + #all-canonical-link { + @extend .p-global-nav-anchors; + } + + @media screen and (min-width: $breakpoint-large - 1) { + padding-left: 0; + } + + .p-navigation__banner { + @media screen and (max-width: $breakpoint-small) { + padding-left: 1rem; + } + } + + .global-nav__header-link-anchor { + padding: 0.5rem auto 0.5rem 1.5rem; + + &::after { + color: $color-mid-light; + top: 0.5rem; + } + + @media screen and (max-width: $breakpoint-large - 1) { + padding-top: 0.5rem; + padding-bottom: 0.5rem; + padding-left: 1.5rem; + } + } + + .p-navigation__dropdown { + background-color: $color-dark; + } + } + + #all-canonical-mobile { + .p-navigation__dropdown-item { + padding-left: 1.5rem; + } + + .global-nav__header-link-anchor::after { + color: $color-mid-light; + top: 0.8rem; + } + } + + .global-nav { + @media screen and (max-width: $breakpoint-large - 1) { + position: relative; + + } + } + + .global-nav-dropdown { + top: 1.5rem; + } + + .p-navigation__toggle--open, .p-navigation__toggle--close { + padding-top: 0.5rem; + padding-bottom: 0.5rem; + } + + .data-fabric-menu { + padding-left: 0; + padding-right: 0; + + .p-navigation__toggle--open { + margin-top: 0; + padding-top: 0.5rem; + } + } + + .global-nav-dropdown.show-content { + top: 1.9rem; + } + + #all-canonical-desktop { + background-color: $color-dark; + } +} diff --git a/static/sass/styles.scss b/static/sass/styles.scss index cd8d43f51..096057fa3 100644 --- a/static/sass/styles.scss +++ b/static/sass/styles.scss @@ -4,7 +4,6 @@ @import "@canonical/cookie-policy/build/css/cookie-policy"; $color-brand: #7c355d; -$color-dark: $colors--dark-theme--background-default; $color-tabs-active-bar: $colors--light-theme--text-default; $nudge--small: 0.55rem; $p-small-lh-diff: map-get($line-heights, default-text) - @@ -22,6 +21,7 @@ $p-small-lh-diff: map-get($line-heights, default-text) - @import "pattern_navigation"; @import "pattern_search-panel"; @import "pattern_careers-progression"; +@import "pattern_global-nav"; @include vanilla; @include vf-p-icon-status-waiting; @@ -42,6 +42,7 @@ $p-small-lh-diff: map-get($line-heights, default-text) - @include canonical-p-search-panel; @include canonical-u-footer-align-bottom; @include canonical-p-careers-progression; +@include canonical-p-global-nav; .js-find-a-partner__partner { // find-a-partner search @@ -786,4 +787,11 @@ $p-small-lh-diff: map-get($line-heights, default-text) - float: right; position: sticky; } -} \ No newline at end of file +} + +// /data UX requirement align to the left for smaller devices +.p-data-logos { + @media screen and (min-width: $breakpoint-large - 1) { + text-align: right; + } +} diff --git a/templates/data/_form-data-kafka.html b/templates/data/_form-data-kafka.html index bb9a278b0..8b80ac112 100644 --- a/templates/data/_form-data-kafka.html +++ b/templates/data/_form-data-kafka.html @@ -11,7 +11,7 @@