Restyle CommandBar for Fabric

with more roundness and native colors.
This commit is contained in:
Sevo Kukol
2023-09-12 13:40:41 +02:00
parent 7c35f01b13
commit dccdd4a60b
2 changed files with 23 additions and 9 deletions

View File

@@ -10,6 +10,7 @@ import * as React from "react";
import create, { UseStore } from "zustand"; import create, { UseStore } from "zustand";
import { ConnectionStatusType, PoolIdType } from "../../../Common/Constants"; import { ConnectionStatusType, PoolIdType } from "../../../Common/Constants";
import { StyleConstants } from "../../../Common/StyleConstants"; import { StyleConstants } from "../../../Common/StyleConstants";
import { Platform, configContext } from "../../../ConfigContext";
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent"; import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
import Explorer from "../../Explorer"; import Explorer from "../../Explorer";
import { useSelectedNode } from "../../useSelectedNode"; import { useSelectedNode } from "../../useSelectedNode";
@@ -82,15 +83,24 @@ export const CommandBar: React.FC<Props> = ({ container }: Props) => {
); );
} }
const rootStyle = configContext.platform == Platform.Fabric ? {
root: {
backgroundColor: "transparent",
padding: "0px 14px 0px 14px"
}
} : {
root: {
backgroundColor: backgroundColor,
}
}
return ( return (
<div className="commandBarContainer"> <div className="commandBarContainer">
<FluentCommandBar <FluentCommandBar
ariaLabel="Use left and right arrow keys to navigate between commands" ariaLabel="Use left and right arrow keys to navigate between commands"
items={uiFabricStaticButtons.concat(uiFabricTabsButtons)} items={uiFabricStaticButtons.concat(uiFabricTabsButtons)}
farItems={uiFabricControlButtons} farItems={uiFabricControlButtons}
styles={{ styles={rootStyle}
root: { backgroundColor: backgroundColor },
}}
overflowButtonProps={{ ariaLabel: "More commands" }} overflowButtonProps={{ ariaLabel: "More commands" }}
/> />
</div> </div>

View File

@@ -11,6 +11,7 @@ import _ from "underscore";
import ChevronDownIcon from "../../../../images/Chevron_down.svg"; import ChevronDownIcon from "../../../../images/Chevron_down.svg";
import { PoolIdType } from "../../../Common/Constants"; import { PoolIdType } from "../../../Common/Constants";
import { StyleConstants } from "../../../Common/StyleConstants"; import { StyleConstants } from "../../../Common/StyleConstants";
import { configContext, Platform } from "../../../ConfigContext";
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants"; import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor"; import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent"; import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
@@ -25,11 +26,13 @@ import { MemoryTracker } from "./MemoryTrackerComponent";
export const convertButton = (btns: CommandButtonComponentProps[], backgroundColor: string): ICommandBarItemProps[] => { export const convertButton = (btns: CommandButtonComponentProps[], backgroundColor: string): ICommandBarItemProps[] => {
const buttonHeightPx = StyleConstants.CommandBarButtonHeight; const buttonHeightPx = StyleConstants.CommandBarButtonHeight;
const hoverColor = configContext.platform == Platform.Fabric ? StyleConstants.FabricAccentLight : StyleConstants.AccentLight;
const getFilter = (isDisabled: boolean): string => { const getFilter = (isDisabled: boolean): string => {
if (isDisabled) { if (isDisabled) {
return StyleConstants.GrayScale; return StyleConstants.GrayScale;
} }
return undefined; return configContext.platform == Platform.Fabric ? StyleConstants.NoColor : undefined;
}; };
return btns return btns
@@ -69,6 +72,7 @@ export const convertButton = (btns: CommandButtonComponentProps[], backgroundCol
height: buttonHeightPx, height: buttonHeightPx,
paddingRight: 0, paddingRight: 0,
paddingLeft: 0, paddingLeft: 0,
borderRadius: configContext.platform == Platform.Fabric ? StyleConstants.FabricButtonBorderRadius : "0px",
minWidth: 24, minWidth: 24,
marginLeft: isSplit ? 0 : 5, marginLeft: isSplit ? 0 : 5,
marginRight: isSplit ? 0 : 5, marginRight: isSplit ? 0 : 5,
@@ -80,17 +84,17 @@ export const convertButton = (btns: CommandButtonComponentProps[], backgroundCol
splitButtonMenuButton: { splitButtonMenuButton: {
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
selectors: { selectors: {
":hover": { backgroundColor: StyleConstants.AccentLight }, ":hover": { backgroundColor: hoverColor },
}, },
width: 16, width: 16,
}, },
label: { fontSize: StyleConstants.mediumFontSize }, label: { fontSize: StyleConstants.mediumFontSize },
rootHovered: { backgroundColor: StyleConstants.AccentLight }, rootHovered: { backgroundColor: hoverColor },
rootPressed: { backgroundColor: StyleConstants.AccentLight }, rootPressed: { backgroundColor: hoverColor },
splitButtonMenuButtonExpanded: { splitButtonMenuButtonExpanded: {
backgroundColor: StyleConstants.AccentExtra, backgroundColor: StyleConstants.AccentExtra,
selectors: { selectors: {
":hover": { backgroundColor: StyleConstants.AccentLight }, ":hover": { backgroundColor: hoverColor },
}, },
}, },
splitButtonDivider: { splitButtonDivider: {
@@ -121,7 +125,7 @@ export const convertButton = (btns: CommandButtonComponentProps[], backgroundCol
// TODO Remove all this crazy styling once we adopt Ui-Fabric Azure themes // TODO Remove all this crazy styling once we adopt Ui-Fabric Azure themes
selectors: { selectors: {
".ms-ContextualMenu-itemText": { fontSize: StyleConstants.mediumFontSize }, ".ms-ContextualMenu-itemText": { fontSize: StyleConstants.mediumFontSize },
".ms-ContextualMenu-link:hover": { backgroundColor: StyleConstants.AccentLight }, ".ms-ContextualMenu-link:hover": { backgroundColor: hoverColor },
".ms-ContextualMenu-icon": { width: 16, height: 16 }, ".ms-ContextualMenu-icon": { width: 16, height: 16 },
}, },
}, },