1+ import React from "react" ;
12import { colors } from "../theme" ;
2- import styled from "styled-components" ;
33import { NavBar } from "./NavBar" ;
44import { NavBarButton } from "./NavBarButton" ;
55import { PopoverContainer , NavBarPopoverButton , NavBarMenuButton , NavBarMenuItem } from "./NavBarMenuButtons" ;
66import { Info } from "./svgs/Info" ;
77import { Tab , Tabs , TabList , TabPanel } from "./Tabs" ;
8+ import "./NavBar.stories.css" ;
89
910const dotsBase64 = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iNTYiIHZpZXdCb3g9IjAgMCAxMCA1NiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSI1IiBjeT0iNSIgcj0iNSIgZmlsbD0iIzAwMCIvPgogIDxjaXJjbGUgY3g9IjUiIGN5PSIyOCIgcj0iNSIgZmlsbD0iIzAwMCIvPgogIDxjaXJjbGUgY3g9IjUiIGN5PSI1MSIgcj0iNSIgZmlsbD0iIzAwMCIvPgo8L3N2Zz4K" ;
1011
11- const InfoMenuButton = styled ( NavBarPopoverButton ) `
12- &:hover {
13- svg path {
14- fill: ${ colors . palette . lightBlue } ;
15- }
16- }
17- ` ;
12+ const InfoMenuButton = ( { children, ...props } : React . ComponentProps < typeof NavBarPopoverButton > ) => {
13+ const [ isHovered , setIsHovered ] = React . useState ( false ) ;
1814
19- const DotsMenuButton = styled ( NavBarMenuButton ) `
20- padding: 1rem;
21- ` ;
15+ return (
16+ < div
17+ onMouseEnter = { ( ) => setIsHovered ( true ) }
18+ onMouseLeave = { ( ) => setIsHovered ( false ) }
19+ style = { { height : '100%' } }
20+ >
21+ < NavBarPopoverButton
22+ { ...props }
23+ style = { {
24+ '--info-icon-fill' : isHovered ? colors . palette . lightBlue : undefined ,
25+ ...props . style
26+ } as React . CSSProperties }
27+ className = "info-menu-button"
28+ >
29+ { children }
30+ </ NavBarPopoverButton >
31+ </ div >
32+ ) ;
33+ } ;
2234
23- const StyledNavBarMenuItem = styled ( NavBarMenuItem ) `
24- color: ${ colors . palette . orange } ;
25- ` ;
35+ const DotsMenuButton = ( props : React . ComponentProps < typeof NavBarMenuButton > ) => (
36+ < NavBarMenuButton { ... props } style = { { padding : '1rem' , ... props . style } } />
37+ ) ;
2638
27- const StyledWrapper = styled . div `
28- display: flex;
29- height: 100%
30- ` ;
31-
32- const StyledNavBar = styled ( NavBar ) `
33- position: fixed;
34- left: 2rem;
35- top: 2rem;
36- width: calc(100% - 36rem);
37- ` ;
38-
39- export const Plain = ( ) => < StyledNavBar > NavBar</ StyledNavBar > ;
40- export const LogoAndChildren = ( ) => < StyledNavBar logo > Menu</ StyledNavBar > ;
41- export const AltTextLinkedLogo = ( ) => < StyledNavBar logo = { { alt : 'custom alt' , href : '/' } } /> ;
42- export const AltTextNoLinkedLogo = ( ) => < StyledNavBar logo = { { alt : 'custom alt unlinked' } } /> ;
43- export const OverrideJustifyContent = ( ) => < StyledNavBar justifyContent = 'center' >
39+ export const Plain = ( ) => < NavBar className = "story-navbar" > NavBar</ NavBar > ;
40+ export const LogoAndChildren = ( ) => < NavBar logo className = "story-navbar" > Menu</ NavBar > ;
41+ export const AltTextLinkedLogo = ( ) => < NavBar logo = { { alt : 'custom alt' , href : '/' } } className = "story-navbar" /> ;
42+ export const AltTextNoLinkedLogo = ( ) => < NavBar logo = { { alt : 'custom alt unlinked' } } className = "story-navbar" /> ;
43+ export const OverrideJustifyContent = ( ) => < NavBar justifyContent = 'center' className = "story-navbar" >
4444 < strong > Centered Menu</ strong >
45- </ StyledNavBar > ;
45+ </ NavBar > ;
4646
4747export const Controls_NavBarButton = ( ) =>
48- < StyledNavBar >
48+ < NavBar className = "story-navbar" >
4949 < NavBarButton label = "Help" />
5050 < NavBarButton label = "Info" icon = { < Info /> } />
51- < NavBarButton style = { { padding : '1rem' } } icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iNTYiIHZpZXdCb3g9IjAgMCAxMCA1NiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSI1IiBjeT0iNSIgcj0iNSIgZmlsbD0iIzAwMCIvPgogIDxjaXJjbGUgY3g9IjUiIGN5PSIyOCIgcj0iNSIgZmlsbD0iIzAwMCIvPgogIDxjaXJjbGUgY3g9IjUiIGN5PSI1MSIgcj0iNSIgZmlsbD0iIzAwMCIvPgo8L3N2Zz4K" aria-label = "Menu" />
52- </ StyledNavBar >
51+ < NavBarButton style = { { padding : '1rem' } } icon = { dotsBase64 } aria-label = "Menu" />
52+ </ NavBar >
5353
5454export const PopoverAndMenu = ( ) =>
55- < StyledNavBar >
55+ < NavBar className = "story-navbar" >
5656 < InfoMenuButton label = "Menu" >
5757 < PopoverContainer >
5858 < button > Example button</ button >
@@ -71,15 +71,15 @@ export const PopoverAndMenu = () =>
7171 < TabPanel id = "three" > Third</ TabPanel >
7272 </ Tabs >
7373 </ InfoMenuButton >
74- < StyledWrapper >
74+ < div className = "story-wrapper" >
7575 < NavBarMenuButton label = "Help" >
7676 < NavBarMenuItem > Open Guide</ NavBarMenuItem >
7777 < NavBarMenuItem > Contact Support</ NavBarMenuItem >
7878 </ NavBarMenuButton >
7979 < DotsMenuButton aria-label = "Test menu" icon = { dotsBase64 } >
8080 < NavBarMenuItem > Cool menu item</ NavBarMenuItem >
8181 < NavBarMenuItem > Really long menu item with a lot of text</ NavBarMenuItem >
82- < StyledNavBarMenuItem > Styled menu item</ StyledNavBarMenuItem >
82+ < NavBarMenuItem className = "story-styled-menu-item" > Styled menu item</ NavBarMenuItem >
8383 </ DotsMenuButton >
84- </ StyledWrapper >
85- </ StyledNavBar > ;
84+ </ div >
85+ </ NavBar > ;
0 commit comments