Fix menuItem background colors depending on the context

This commit is contained in:
Fabio Berger
2018-11-11 16:48:31 +01:00
parent 753b33aec5
commit 1ec8a4115f
4 changed files with 18 additions and 3 deletions

View File

@@ -4,11 +4,13 @@ import * as _ from 'lodash';
import * as React from 'react';
import { Button } from 'ts/components/ui/button';
import { Text } from 'ts/components/ui/text';
import { ScreenWidths } from 'ts/types';
export interface NestedSidebarMenuProps {
sectionNameToLinks: ObjectMap<ALink[]>;
sidebarHeader?: React.ReactNode;
shouldReformatMenuItemNames?: boolean;
screenWidth: ScreenWidths;
}
export const NestedSidebarMenu = (props: NestedSidebarMenuProps) => {
@@ -22,7 +24,7 @@ export const NestedSidebarMenu = (props: NestedSidebarMenuProps) => {
...link,
title: menuItemTitle,
};
return <MenuItem key={`menu-item-${menuItemTitle}`} link={finalLink} />;
return <MenuItem key={`menu-item-${menuItemTitle}`} link={finalLink} screenWidth={props.screenWidth} />;
});
// tslint:disable-next-line:no-unused-variable
return (
@@ -44,6 +46,7 @@ export const NestedSidebarMenu = (props: NestedSidebarMenuProps) => {
export interface MenuItemProps {
link: ALink;
screenWidth: ScreenWidths;
}
export interface MenuItemState {
@@ -70,7 +73,13 @@ export class MenuItem extends React.Component<MenuItemProps, MenuItemState> {
borderRadius="4px"
padding="0.4em 0.375em"
width="100%"
backgroundColor={isActive ? colors.lightLinkBlue : 'transparent'}
backgroundColor={
isActive
? colors.lightLinkBlue
: this.props.screenWidth === ScreenWidths.Sm
? 'white'
: colors.grey100
}
fontSize="14px"
textAlign="left"
>

View File

@@ -94,7 +94,11 @@ export class DocPage extends React.Component<DocPageProps, DocPageState> {
const sidebar = _.isUndefined(this.state.docAgnosticFormat) ? (
<div />
) : (
<NestedSidebarMenu sidebarHeader={this._renderSidebarHeader()} sectionNameToLinks={sectionNameToLinks} />
<NestedSidebarMenu
sidebarHeader={this._renderSidebarHeader()}
sectionNameToLinks={sectionNameToLinks}
screenWidth={this.props.screenWidth}
/>
);
return (
<DevelopersPage

View File

@@ -346,6 +346,7 @@ export class DocsHome extends React.Component<DocsHomeProps, DocsHomeState> {
sidebarHeader={isSmallScreen ? this._renderSidebarHeader() : undefined}
sectionNameToLinks={sectionNameToLinks}
shouldReformatMenuItemNames={false}
screenWidth={this.props.screenWidth}
/>
);
return (

View File

@@ -76,6 +76,7 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
<NestedSidebarMenu
sidebarHeader={isSmallScreen ? this._renderSidebarHeader() : undefined}
sectionNameToLinks={sectionNameToLinks}
screenWidth={this.props.screenWidth}
/>
);
return (