Skip to content

Commit 4ebd693

Browse files
committed
use an editable svg as the navbar toggle icon
by default, the background image rendered by the "navbar-toggler-icon" class is a dark colored hamburger menu icon. since it uses an image, it was incapable of being dynamically styled with css alone. this commit replaces the "navbar-toggler-icon" class inside "navbar-toggler" with an editable svg, allowing us to change the color. - ref: #207
1 parent 2646754 commit 4ebd693

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/assets/svg/ToggleIcon.jsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as React from 'react'
2+
import themeColors from '../theme/default-colors.module.scss'
3+
4+
const ToggleIcon = ({ linkColor }, props) => {
5+
const fill = themeColors[linkColor]
6+
7+
return (
8+
<svg
9+
xmlns='http://www.w3.org/2000/svg'
10+
xmlSpace='preserve'
11+
style={{
12+
enableBackground: 'new 0 0 227 163.3',
13+
}}
14+
viewBox='0 0 227 163.3'
15+
fill={fill}
16+
width={25}
17+
height={25}
18+
{...props}
19+
>
20+
<path d='M113.1 33h-95C5.8 33-2.1 22.1 2.2 11.3 4.6 5.2 9.3 1.8 15.8 1.1c1.5-.2 3-.1 4.5-.1h185.5c2.2 0 4.4-.1 6.5.3 8.1 1.6 13.6 9.2 12.7 17.2-.8 8.1-7.5 14.3-15.9 14.3-21 .1-42 0-63 .1-11 .1-22 .1-33 .1zM113 65h95c12.7 0 20.7 11.7 15.6 22.6-3.1 6.6-8.5 9.4-15.7 9.4H18.4C5.8 97-2.2 86 2.2 75.1c2.6-6.4 8.3-10 16.3-10.1H113zM113.3 129c31.7 0 63.3-.1 95 0 13.2 0 21.1 13.3 14.5 24.1-3.5 5.8-9 7.9-15.7 7.9-45.8-.1-91.7 0-137.5 0H19.1c-10.7 0-17.9-6.4-18-15.9C1 135.5 8.3 129 19.3 129h94z' />
21+
</svg>
22+
)
23+
}
24+
25+
export default ToggleIcon

src/compounds/Header/Header.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
33
import { Container, Nav, Navbar } from 'react-bootstrap'
4+
import ToggleIcon from '../../assets/svg/ToggleIcon'
45
import Logo from '../Logo/Logo'
56

67
const Header = ({ auth, linkColor, logo, navLinks, userSession }) => {
@@ -12,7 +13,9 @@ const Header = ({ auth, linkColor, logo, navLinks, userSession }) => {
1213
<Navbar.Brand className='w-50'>
1314
<Logo src={src} alt={alt} height={45} />
1415
</Navbar.Brand>
15-
<Navbar.Toggle aria-controls='basic-navbar-nav' />
16+
<Navbar.Toggle aria-controls='basic-navbar-nav'>
17+
<ToggleIcon linkColor={linkColor} />
18+
</Navbar.Toggle>
1619
<Navbar.Collapse id='basic-navbar-nav'>
1720
<Nav className='ms-auto'>
1821
{navLinks.map((nav) => (

0 commit comments

Comments
 (0)