Gathering detailed insights and metrics for @canonical/global-nav
Gathering detailed insights and metrics for @canonical/global-nav
Gathering detailed insights and metrics for @canonical/global-nav
Gathering detailed insights and metrics for @canonical/global-nav
npm install @canonical/global-nav
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
5 Stars
535 Commits
23 Forks
14 Watching
16 Branches
112 Contributors
Updated on 24 Apr 2024
JavaScript (37.74%)
Shell (27.04%)
HTML (24.81%)
SCSS (9.49%)
Dockerfile (0.92%)
Cumulative downloads
Total Downloads
Last day
43.9%
649
Compared to previous day
Last week
17.8%
2,262
Compared to previous week
Last month
-33.5%
8,690
Compared to previous month
Last year
52%
169,238
Compared to previous year
1
This project contains the JavaScript and styles to add an "All Canonical" navigation dropdown item to the Vanilla navigation pattern.
The dropdown contains a list of Canonical eco-system websites, giving a user the ability to jump around the core sites easily.
Use a node package manager to install this component and then link the JS file into the head of your site, with optional settings.
The styles will automatically be injected into the page's <head>
.
1yarn add @canonical/global-nav 2
...or...
1npm install @canonical/global-nav --save
To consume the library directly, add a link to the JS file containing an IIFE and run the canonicalGlobalNav.createNav()
function;
1<script src="/node_modules/@canonical/global-nav/dist/iife.js"></script> 2<script> 3 canonicalGlobalNav.createNav(); 4</script>
To import it, simply call it from your site-wide JS file;
1import { createNav } from '@canonical/global-nav'; 2createNav();
.global-nav
class to a ul.p-navigation__items
element within the navigation pattern. The module will look for this class and add the dropdown as the first item in the list.The createNav
function takes an object of options with the following property:
breakpoint
: The point, in pixels, at which the navigation switches between desktop and mobile layouts. The default is 620px
, which is meant to reflect the default value of $breakpoint-navigation-threshold
in Vanilla (see Vanilla's breakpoint documentation).
mobileContainerSelector
and desktopContainerSelector
: Selectors (can be 'id' or 'class') of where to attach the mobile and desktop views of the global-nav. This will also circumvent the default eventListeners being attached as they are dependent on the default structure, so custom JS will be nessacary. Also in this case, the class global-nav
should still be used to indicate the position of the 'All Canonical' tab button. If ony one is used it will render the default global nav.
If the $breakpoint-navigation-threshold
Vanilla variable is overridden in your project, you will need to set this option on the global nav.
For example, to set the breakpoint
to 1036
:
1<script src="/node_modules/@canonical/global-nav/dist/index.js"></script>
2
3<script>
4 canonicalGlobalNav.createNav({
5 breakpoint: 1036,
6 mobileContainerSelector: 'global-nav-mobile',
7 desktopContainerSelector: 'global-nav-desktop',
8 });
9</script>
If you're importing;
1import { createNav } from '@canonical/global-nav'; 2createNav({ breakpoint: 1036 });
To build the JS into the /dist
folder, run:
1./run build
The simplest way to run the site locally is to first install Docker (on Linux you may need to add your user to the docker
group), and then use the ./run
script:
1./run
You can also use the dotrun snap, by running:
1dotrun
Once the containers are setup, you can visit http://127.0.0.1:8300 in your browser.
For working on Sass files and JS files , you may want to dynamically watch for changes to rebuild the dist files whenever something changes.
To setup the watcher, open a new terminal window and run:
1./run watch
Before submitting your pull request, run the tests - which checks both the JS and Sass for errors.
./run test
Just because this was a bit of a pain, here is what I did.
"
to single '
- CRITICALdata:image/svg+xml,
in the right place in product-details.jsThis project uses the Vanilla framework as a dependency in two ways: the SCSS files are imported directly to build the styles of the global-nav itself (via the vanilla-framework
npm package, as defined in dependencied in package.json) and for styling the demo page (via direct link in the index.html file).
When updating Vanilla to latest version both dependencies should be updated.
The package is versioned using semantic versioning and published to the NPM registry.
To cut a new release run:
1npm version [patch|minor|major]
This will trigger the prepublishonly
script which will ensure requisite artefacts are built before publishing.
Code licensed LGPLv3 by Canonical Ltd.
With ♥ from Canonical
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
all changesets reviewed
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More