|
| 1 | +# primo-explore-search-bar-sub-menu |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +Add a nav bar underneath the search bar to provide additional links in the primo-explore UI. |
| 6 | + |
| 7 | +### Screenshot |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +1. Assuming you've installed and are using [primo-explore-devenv](https://github.com/ExLibrisGroup/primo-explore-devenv). |
| 14 | + |
| 15 | +2. Navigate to your template/central package root directory. For example: |
| 16 | + ``` |
| 17 | + cd primo-explore/custom/MY_VIEW_ID |
| 18 | + ``` |
| 19 | +3. If you do not already have a package.json file in this directory, create one: |
| 20 | + ``` |
| 21 | + npm init -y |
| 22 | + ``` |
| 23 | +4. Install this package: |
| 24 | + ``` |
| 25 | + npm install primo-explore-search-bar-sub-menu --save-dev |
| 26 | + ``` |
| 27 | +
|
| 28 | +## Usage |
| 29 | +
|
| 30 | +Once installed, inject `searchBarSubMenu` as a dependency: |
| 31 | +
|
| 32 | +```js |
| 33 | +let app = angular.module('viewCustom', ['searchBarSubMenu']) |
| 34 | +``` |
| 35 | + |
| 36 | +**Note:** If you're using the --browserify build option, you will need to first import the module with: |
| 37 | + |
| 38 | +```js |
| 39 | +import 'primo-explore-search-bar-sub-menu'; |
| 40 | +``` |
| 41 | + |
| 42 | +Then add the `search-bar-sub-menu` directive to the `prmSearchBarAfter` component: |
| 43 | + |
| 44 | +```js |
| 45 | +app.component('prmSearchBarAfter', { |
| 46 | + template: '<search-bar-sub-menu></search-bar-sub-menu>' |
| 47 | +}) |
| 48 | +``` |
| 49 | + |
| 50 | +### Config |
| 51 | + |
| 52 | +You'll need to configure the module by passing it an array of objects as an angular `constant`: |
| 53 | + |
| 54 | +| name | type | usage | |
| 55 | +|------|-------------|--------| |
| 56 | +| `cssClasses` | string | extra css classes to put on the buttons, i.e. 'button-over-dark' if your background color is dark | |
| 57 | +| `name` | string | the text that will appear as the button link | |
| 58 | +| `description` | string | for the aria label | |
| 59 | +| `action` | string | url for the link. always opens in a new window. | |
| 60 | +| `icon` | object | defines the icon for the link. must be chosen from <https://material.io/icons/>. you need to specify both the name of the action "set" (see link) and the icon itself, in the form "ic_person_outline_24px". note that all icons do not work so you may have to experiment some | |
| 61 | +| `show_xs` | boolean | true is you want to continue to show button text in xs screens and only show the icons. false by default | |
| 62 | + |
| 63 | +### Translations |
| 64 | + |
| 65 | +You can use translations to access back office text by wrapping the value in curly braces, e.g. `{nui.menu.librarycard}`. Anything that works in the primo templates link this `<span translate="nyu.menu.librarycard"></span>` will work if it's available in the current scope. |
| 66 | + |
| 67 | +### Styles |
| 68 | + |
| 69 | +Change the background color of the menu bar: |
| 70 | + |
| 71 | +```css |
| 72 | +search-bar-sub-menu div.search-bar-sub-menu { |
| 73 | + background-color: green !important; |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +Change the padding between the search bar the menu bar, these are the default values: |
| 78 | + |
| 79 | +```css |
| 80 | +prm-search-bar { |
| 81 | + padding-bottom: 58.5px; |
| 82 | +} |
| 83 | +.__sm prm-search-bar { |
| 84 | + padding-bottom: 49.5px; |
| 85 | +} |
| 86 | +.__xs prm-search-bar { |
| 87 | + padding-bottom: 36pxs; |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +Where `36px` is the default height of the menu bar. |
| 92 | + |
| 93 | +### Example |
| 94 | + |
| 95 | +```js |
| 96 | +app.constant('searchBarSubMenuItems', |
| 97 | + [ |
| 98 | + { |
| 99 | + name: "Back to Primo Classic", |
| 100 | + description: "Back to Primo Classic", |
| 101 | + action: "http://primo.school.edu/primo_library/libweb/action/search.do?vid=" + viewName, |
| 102 | + icon: { |
| 103 | + set: 'navigation', |
| 104 | + icon: 'ic_arrow_back_24px' |
| 105 | + }, |
| 106 | + show_xs: true, |
| 107 | + cssClasses: 'button-over-dark' |
| 108 | + }, |
| 109 | + { |
| 110 | + name: "Library Hours", |
| 111 | + description: "Library Hours", |
| 112 | + action: "https://school.edu/library-hours", |
| 113 | + icon: { |
| 114 | + set: 'av', |
| 115 | + icon: 'ic_av_timer_24px' |
| 116 | + }, |
| 117 | + cssClasses: 'button-over-dark' |
| 118 | + } |
| 119 | + ] |
| 120 | +); |
| 121 | + |
| 122 | +``` |
0 commit comments