Site Navigation for volvocars.com
This is the global navigation component that can be found on volvocars.com
Install
Install the package:
npm install @volvo-cars/site-nav-component
# or
yarn add @volvo-cars/site-nav-component
Requirements
Styling and theming is handled with VCC UI:
npm install vcc-ui
- Wrap your application in a
<StyleProvider>
and<ThemeProvider>
- Configure at least the following static assets for VCC UI (example configuration):
- The "Volvo Logo"
- The "Volvo Novum Light", "Volvo Novum Regular" and "Volvo Broad" fonts
Browser support and polyfills
The code is compiled to match @volvo-cars/browserslist-config but you also need to include some runtime polyfills to support old browsers. We recommend the @volvo-cars/polyfill package.
If you have given a sub navigation (through the children
prop), we will measure it once at component mount to determine the height the site nav should occupy. We use ResizeObserver
to re-measure the sub navigation, so if you have a sub navigation that will hide or resize you should add a ResizeObserver polyfill.
Usage
The data and content are not provided in this package. You will need to fetch content from the VCC Content Delivery API. Please contact Content Delivery API team for more information.
import { SiteNav } from "@volvo-cars/site-nav-component"
const myApp() (
...
<SiteNav
data={dataFromContentDeliveryAPI}
/>
...
)
Props
Props | Type | Description | Required | Default |
---|---|---|---|---|
data |
SiteNavPayload |
Data from VCC Content Delivery API | ✔︎ | null |
userMenuData |
UserMenuPayload |
Data for the user menu | null |
|
children |
jsx |
Child nodes (sub navigation) to stick beneath the footer | null |
|
enableMaxWidth |
boolean |
Enable max width for menu (1440px) | false |
|
hideOnScroll |
boolean |
Hide navigation when scrolling down, enabled by default if given children prop |
!!children |
|
hideOnScrollOffsetTop |
number |
The amount of pixels that needs to be scrolled to hide the header, defaults to 80 | 80 |
User Menu Data
The data for user menu is also not provided in this package. You will need to fetch the data from the My Volvo API.
the production endpoints are like this: https://www.volvocars.com/data/dynamic/myvolvo/menu?sc_site=${marketCode}
Embedded Search
Embedded Search should work out of the box, but since it is using fetch
to get the search suggestions,
your application might need to pollyfill fetch
to support older browsers (i.e. IE 11).
We use isomorphic-unfetch
npm package.
Tracking
<SiteNav>
component is doing click tracking if you set up Google Tag Manager (GTM) properly on your page. If you don't have GTM it should silently ignore and work as usual.
We highly recommend you to enable tracking. It will allow us to have a better understating of the actual usage of the component and improve it based on the data we gather.
Please contact the analytics team in order to set up the Google Tag Manager.
Bug Report
Please report any issues and bugs to the Web Impressions board in JIRA.
Changelog
See our CHANGELOG
Support
If you have any questions or need help using this component please shout out on the ced-wi-general
(Web Impressions) slack channel.