Skip to content

Commit

Permalink
GN-102 Bnf content (#125)
Browse files Browse the repository at this point in the history
* Scrim

* GN-101 Move focus to search when clicked

* GN-101 Close MyAccount Dropdown on meganav click

* GN-101 Close MyAccount Dropdown on meganav click

* GN-95 Now click scrim to close

* GN-101 Fix list styling variation

* GN-102 Add BNF content

* GN-102 BNFc content

* GN-102 BNF content update

* GN-101 Code review fixes

Co-authored-by: w@rren <[email protected]>

* GN-102 Nitpicking css

* GN-102 Pull url from services

* GN-102 Spacing

* GN-101 Fix failing tests

* GN-102 Update snapshot

* GN-102 Fix letters and dancing button

Co-authored-by: w@rren <[email protected]>
  • Loading branch information
emollett and wa-rren-dev authored Sep 27, 2021
1 parent d921e9e commit e4b0e58
Show file tree
Hide file tree
Showing 10 changed files with 432 additions and 84 deletions.
2 changes: 1 addition & 1 deletion src/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class Header extends Component {
<>
<span
id="scrim"
className={this.state.scrimIsActive && styles.scrim}
className={this.state.scrimIsActive ? styles.scrim : undefined}
aria-hidden="true"
/>

Expand Down
127 changes: 127 additions & 0 deletions src/Header/Nav/Dropdown/Components/BNF.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import React from "react";
import { Button } from "@nice-digital/nds-button";
import { Grid, GridItem } from "@nice-digital/nds-grid";
import styles from "./Components.module.scss";
import services from "../../../../services.json";

export function BNF() {
const baseUrl = services.external.find(
(service) => service.text == "BNF"
).href;

const drugsAtoZurl = baseUrl + "drug/#";

const drugsAtoZ = [
{ letter: "A", link: true },
{ letter: "B", link: true },
{ letter: "C", link: true },
{ letter: "D", link: true },
{ letter: "E", link: true },
{ letter: "F", link: true },
{ letter: "G", link: true },
{ letter: "H", link: true },
{ letter: "I", link: true },
{ letter: "J", link: true },
{ letter: "K", link: true },
{ letter: "L", link: true },
{ letter: "M", link: true },
{ letter: "N", link: true },
{ letter: "O", link: true },
{ letter: "P", link: true },
{ letter: "Q", link: true },
{ letter: "R", link: true },
{ letter: "S", link: true },
{ letter: "T", link: true },
{ letter: "U", link: true },
{ letter: "V", link: true },
{ letter: "W", link: true },
{ letter: "X", link: true },
{ letter: "Y", link: true },
{ letter: "Z", link: true },
];

return (
<section aria-label="BNF - dropdown navigation">
<h2 className="mt--0">BNF</h2>
<p>
The BNF aims to provide prescribers, pharmacists, and other healthcare
professionals with sound up-to-date information about the use of
medicines.
</p>
<Button variant="primary" to={baseUrl}>
View BNF
</Button>

<h3 className="mt--d">Drugs A to Z</h3>
<ol className={styles.alphabet}>
{drugsAtoZ.map(({ letter, link }) => {
return (
<li
key={letter}
className={`${styles.letter} ${link ? "" : styles.chunkyLetter}`}
>
{link ? (
<a href={`${drugsAtoZurl}${letter}`}>{letter}</a>
) : (
<span>{letter}</span>
)}
</li>
);
})}
</ol>

<Grid gutter="loose">
<GridItem cols={12} md={3}>
<h3 className="mt--0">Browse A to Z by</h3>
<ul className={styles.listUnstyled}>
<li>
<a href={`${baseUrl}interaction/`}>Interactions</a>
</li>
<li>
<a href={`${baseUrl}treatment-summary/`}>Treatment summaries</a>
</li>
</ul>
</GridItem>
<GridItem cols={12} md={6}>
<h3 className="mt--0">Browse by type</h3>
<ul className={styles.listUnstyled} style={{ columnCount: 2 }}>
<li>
<a href={`${baseUrl}dental-practitioners-formulary/`}>
Dental practitioners' formulary
</a>
</li>
<li>
<a href={`${baseUrl}nurse-prescribers-formulary/`}>
Nurse prescribers' formulary
</a>
</li>
<li>
<a href={`${baseUrl}guidance/`}>Medicines guidance</a>
</li>
<li>
<a href={`${baseUrl}wound-management/`}>Wound management</a>
</li>
<li>
<a href={`${baseUrl}medical-devices/`}>Medical devices</a>
</li>
<li>
<a href={`${baseUrl}borderline-substance-taxonomy/`}>
Borderline substances
</a>
</li>
</ul>
</GridItem>
<GridItem cols={12} md={3}>
<h3 className="mt--0">What’s new</h3>
<ul className={styles.listUnstyled}>
<li>
<a href={`${baseUrl}about/changes.html`}>Latest BNF</a>
</li>
</ul>
</GridItem>
</Grid>
<hr />
<a href={`${baseUrl}about/`}>About BNF</a>
</section>
);
}
123 changes: 123 additions & 0 deletions src/Header/Nav/Dropdown/Components/BNFc.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import React from "react";
import { Button } from "@nice-digital/nds-button";
import { Grid, GridItem } from "@nice-digital/nds-grid";
import styles from "./Components.module.scss";

const drugsAtoZ = [
{ letter: "A", link: "https://bnfc.nice.org.uk/drug/#A" },
{ letter: "B", link: "https://bnfc.nice.org.uk/drug/#B" },
{ letter: "C", link: "https://bnfc.nice.org.uk/drug/#C" },
{ letter: "D", link: "https://bnfc.nice.org.uk/drug/#D" },
{ letter: "E", link: "https://bnfc.nice.org.uk/drug/#E" },
{ letter: "F", link: "https://bnfc.nice.org.uk/drug/#F" },
{ letter: "G", link: "https://bnfc.nice.org.uk/drug/#G" },
{ letter: "H", link: "https://bnfc.nice.org.uk/drug/#H" },
{ letter: "I", link: "https://bnfc.nice.org.uk/drug/#I" },
{ letter: "J", link: "https://bnfc.nice.org.uk/drug/#J" },
{ letter: "K", link: "https://bnfc.nice.org.uk/drug/#K" },
{ letter: "L", link: "https://bnfc.nice.org.uk/drug/#L" },
{ letter: "M", link: "https://bnfc.nice.org.uk/drug/#M" },
{ letter: "N", link: "https://bnfc.nice.org.uk/drug/#N" },
{ letter: "O", link: "https://bnfc.nice.org.uk/drug/#O" },
{ letter: "P", link: "https://bnfc.nice.org.uk/drug/#P" },
{ letter: "Q", link: null },
{ letter: "R", link: "https://bnfc.nice.org.uk/drug/#R" },
{ letter: "S", link: "https://bnfc.nice.org.uk/drug/#S" },
{ letter: "T", link: "https://bnfc.nice.org.uk/drug/#T" },
{ letter: "U", link: "https://bnfc.nice.org.uk/drug/#U" },
{ letter: "V", link: "https://bnfc.nice.org.uk/drug/#V" },
{ letter: "W", link: "https://bnfc.nice.org.uk/drug/#W" },
{ letter: "X", link: null },
{ letter: "Y", link: null },
{ letter: "Z", link: null },
];

export function BNFc() {
return (
<section aria-label="BNFc - dropdown navigation">
<h2 className="mt--0">BNFc</h2>
<p>Everything NICE says on a topic in an interactive flowchart</p>
<Button variant="primary" to="https://bnfc.nice.org.uk/">
Explore BNFc
</Button>

<h3>Drugs A to Z</h3>
<ol className={styles.alphabet}>
{drugsAtoZ.map((letter) => {
return (
<li
key={letter.letter}
className={`${styles.letter} ${
letter.link == null ? styles.chunkyLetter : ""
}`}
>
{letter.link == null ? (
<span>{letter.letter}</span>
) : (
<a href={letter.link}>{letter.letter}</a>
)}
</li>
);
})}
</ol>

<Grid gutter="loose">
<GridItem cols={12} md={3}>
<h3>Browse A to Z by</h3>
<ul className={styles.listUnstyled}>
<li>
<a href="https://bnfc.nice.org.uk/interaction/">Interactions</a>
</li>
<li>
<a href="https://bnfc.nice.org.uk/treatment-summary/">
Treatment summaries
</a>
</li>
</ul>
</GridItem>
<GridItem cols={12} md={6}>
<h3>Browse by type</h3>
<ul className={styles.listUnstyled} style={{ columnCount: 2 }}>
<li>
<a href="https://bnfc.nice.org.uk/dental-practitioners-formulary/">
Dental practitioners' formulary
</a>
</li>
<li>
<a href="https://bnfc.nice.org.uk/nurse-prescribers-formulary/">
Nurse prescribers' formulary
</a>
</li>
<li>
<a href="https://bnfc.nice.org.uk/guidance/">
Medicines guidance
</a>
</li>
<li>
<a href="https://bnfc.nice.org.uk/medical-devices/">
Medical devices
</a>
</li>
<li>
<a href="https://bnfc.nice.org.uk/borderline-substance-taxonomy/">
Borderline substances
</a>
</li>
</ul>
</GridItem>
<GridItem cols={12} md={3}>
<h3>Latest</h3>
<ul className={styles.listUnstyled}>
<li>
<a href="https://bnfc.nice.org.uk/about/changes.html">
What's changed
</a>
</li>
</ul>
</GridItem>
</Grid>
<hr />
<a href="https://bnfc.nice.org.uk/about/">About BNF</a>
</section>
);
}
79 changes: 79 additions & 0 deletions src/Header/Nav/Dropdown/Components/Components.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,82 @@
max-width: none; // To override max-width of 66ch set on lists
padding: 0;
}

.alphabet {
display: flex;
flex-wrap: wrap;
gap: rem($nds-spacing-small);
list-style: none;
margin: rem(0 0 $nds-spacing-large);
max-width: 90%;
padding: 0;

&:focus {
outline: none;
}
}

.chunkyLetter {
@include nds-font-size(h4);
color: $nds-colour-nice-dark-grey;

span {
width: 3.95ch;
}
}

.letter {
display: inline-block;
font-weight: bold;
margin: rem(0 $nds-spacing-small $nds-spacing-small 0);

a,
span {
display: block;
padding: rem($nds-spacing-small 0);
text-align: center;
}

a {
background: $nds-colour-true-white;
border: 1px solid $nds-colour-border;
text-decoration: none;
width: 4.95ch;

&:hover {
text-decoration: underline;
}
}
}

.btn {
&:hover,
&:focus,
&:active {
border: em(1px) solid $nds-colour-btn-primary-text !important;
}

&--cta {
&:hover,
&:focus,
&:active {
border: em(1px) solid $nds-colour-btn-cta-text !important;
}
}

&--secondary {
&:hover,
&:focus,
&:active {
border: em(1px) solid $nds-colour-btn-secondary-text !important;
}
}

&--inverse {
&:hover,
&:focus,
&:active {
border: em(1px) solid $nds-colour-btn-inverse-text !important;
}
}
}
2 changes: 2 additions & 0 deletions src/Header/Nav/Dropdown/Components/index.jsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export { Guidance } from "./Guidance";
export { More } from "./More";
export { BNF } from "./BNF";
export { BNFc } from "./BNFc";
4 changes: 3 additions & 1 deletion src/Header/Nav/Dropdown/Dropdown.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import PropTypes from "prop-types";
import styles from "./Dropdown.module.scss";
import { Guidance, More } from "./Components/";
import { Guidance, More, BNF, BNFc } from "./Components/";
import Remove from "@nice-digital/icons/lib/Remove";

export function Dropdown({
Expand All @@ -15,6 +15,8 @@ export function Dropdown({
const components = {
Guidance: Guidance,
More: More,
BNF: BNF,
BNFc: BNFc,
};
const Component = components[component];

Expand Down
1 change: 1 addition & 0 deletions src/Header/Nav/Nav.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe("Nav", () => {
isExpanded: false,
accountsData: null,
service: null,
handleScrim: () => {},
};
const externalServices = services.external;

Expand Down
Loading

0 comments on commit e4b0e58

Please sign in to comment.