Improve props for ToolbarIcon

Summary: This allows props like `style` to be passed through (so it can be further styled), and makes `active` optional.

Reviewed By: jknoxville

Differential Revision: D21438791

fbshipit-source-id: bbab4a7768fce5de56e4deff67e50ff69914d123
This commit is contained in:
Scott Kyle
2020-05-07 11:11:39 -07:00
committed by Facebook GitHub Bot
parent 9534cafb17
commit c7ff6f6266

View File

@@ -12,32 +12,32 @@ import {colors} from './colors';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import React from 'react'; import React from 'react';
type Props = { type Props = React.ComponentProps<typeof ToolbarIconContainer> & {
title: string; active?: boolean;
icon: string; icon: string;
active: boolean; title: string;
onClick: () => void; onClick: () => void;
}; };
const ToolbarIcon = styled.div({ const ToolbarIconContainer = styled.div({
marginRight: 9, marginRight: 9,
marginTop: -3, marginTop: -3,
marginLeft: 4, marginLeft: 4,
position: 'relative', // for settings popover positioning position: 'relative', // for settings popover positioning
}); });
export default function (props: Props) { export default function ToolbarIcon({active, icon, ...props}: Props) {
return ( return (
<ToolbarIcon onClick={props.onClick} title={props.title}> <ToolbarIconContainer {...props}>
<Glyph <Glyph
name={props.icon} name={icon}
size={16} size={16}
color={ color={
props.active active
? colors.macOSTitleBarIconSelected ? colors.macOSTitleBarIconSelected
: colors.macOSTitleBarIconActive : colors.macOSTitleBarIconActive
} }
/> />
</ToolbarIcon> </ToolbarIconContainer>
); );
} }