From c3119f0ee31a0f4fff71a0f31bf9c410fe429f74 Mon Sep 17 00:00:00 2001 From: David Zearing Date: Mon, 27 Feb 2017 13:35:40 -0800 Subject: [PATCH] Module css: commandbar (#1125) * CommandBar updates. * Fixing commandbar issues. * Deleting unused classes. --- .../src/components/CommandBar/CommandBar.scss | 482 ++++++++---------- .../src/components/CommandBar/CommandBar.tsx | 66 ++- 2 files changed, 263 insertions(+), 285 deletions(-) diff --git a/packages/office-ui-fabric-react/src/components/CommandBar/CommandBar.scss b/packages/office-ui-fabric-react/src/components/CommandBar/CommandBar.scss index de6ebfe9e9c0d8..e2048394bf26ea 100644 --- a/packages/office-ui-fabric-react/src/components/CommandBar/CommandBar.scss +++ b/packages/office-ui-fabric-react/src/components/CommandBar/CommandBar.scss @@ -41,331 +41,291 @@ $SearchBox-sidePadding: 8px; // padding in input on left and right sides without @include border-right(1px, solid, $color); } -:global { - .ms-CommandBar { - @include ms-font-m; +.root { + @include ms-font-m; + color: $ms-color-neutralPrimary; + + position: relative; + background-color: $ms-color-neutralLighter; + height: $CommandBar-height; + white-space: nowrap; + user-select: none; +} + +.primaryCommands { + position: absolute; + overflow: hidden; + display: inline; + vertical-align: top; + line-height: $CommandBar-height; + max-width: 100%; + margin: 0 20px; +} + +.sideCommands { + position: absolute; + @include right(0px); + @include text-align(right); + @include padding-right(20px); +} + +// Command Bar Item +.item { + display: inline-block; + color: $ms-color-themePrimary; + height: $CommandBarItem-height; + outline: transparent; + vertical-align: top; + margin: 0 4px; + + &:hover { + background-color: $ms-color-neutralLight; color: $ms-color-neutralPrimary; + } - position: relative; - background-color: $ms-color-neutralLighter; - height: $CommandBar-height; - white-space: nowrap; - user-select: none; + @media screen and (-ms-high-contrast: active) { + @include highContrastBorder($ms-color-black); + height: 38px; + outline: none; } - .ms-CommandBar-primaryCommands { - position: absolute; - overflow: hidden; - display: inline; - vertical-align: top; - line-height: $CommandBar-height; - max-width: 100%; - margin: 0 20px; + @media screen and (-ms-high-contrast: black-on-white) { + @include highContrastBorder($ms-color-white); + height: 38px; + outline: none; } +} - .ms-CommandBar-sideCommands { - position: absolute; - @include right(0px); - @include text-align(right); - @include padding-right(20px); +.itemChevronDown, +.itemCommandText { + display: inline-block; + padding: 0 4px; + vertical-align: top; +} + +@mixin CommandBarItem-text { + @include focus-border(2px); + @include ms-font-m; + color: $ms-color-neutralPrimary; + + position: relative; + background: none; + border: none; + line-height: $CommandBarItem-height; + min-width: 20px; + text-align: center; + padding: 0 4px; + display: block; + height: 100%; + + &.itemLinkIsNoName { + padding: 0 8px; } +} - // Command Bar Item - .ms-CommandBarItem { - display: inline-block; - color: $ms-color-themePrimary; - height: $CommandBarItem-height; - outline: transparent; - vertical-align: top; - padding: 0 4px; - - &:hover { - background-color: $ms-color-neutralLight; - color: $ms-color-neutralPrimary; - } +.itemText { + @include CommandBarItem-text; +} + +.itemLink { + @include CommandBarItem-text; + cursor: pointer; + &:hover, + &.itemLinkIsExpanded { @media screen and (-ms-high-contrast: active) { - @include highContrastBorder($ms-color-black); - height: 38px; - outline: none; + @include highContrastBorder($ms-color-white); } @media screen and (-ms-high-contrast: black-on-white) { - @include highContrastBorder($ms-color-white); - height: 38px; - outline: none; + @include highContrastBorder($ms-color-black); } } - .ms-CommandBarItem-chevronDown, - .ms-CommandBarItem-commandText { - display: inline-block; - padding: 0 4px; - vertical-align: top; - } - - @mixin CommandBarItem-text { - @include focus-border(2px); - @include ms-font-m; - color: $ms-color-neutralPrimary; + &:hover:not([disabled]) { + color: $ms-color-neutralDark; + background-color: $ms-color-neutralLight; - position: relative; - background: none; - border: none; - line-height: $CommandBarItem-height; - min-width: 20px; - text-align: center; - padding: 0 4px; - display: block; - height: 100%; - - &.ms-CommandBarItem--noName { - padding: 0 8px; + .itemIcon { + color: $ms-color-themeDark; } - } - - .ms-CommandBarItem-text { - @include CommandBarItem-text; - } - - .ms-CommandBarItem-link { - @include CommandBarItem-text; - cursor: pointer; - &:hover, - &.is-expanded { - @media screen and (-ms-high-contrast: active) { - @include highContrastBorder($ms-color-white); - } - - @media screen and (-ms-high-contrast: black-on-white) { - @include highContrastBorder($ms-color-black); - } + .itemChevronDown { + color: $ms-color-neutralPrimaryAlt; } - &:hover:not([disabled]) { + .itemOverflow { color: $ms-color-neutralDark; - background-color: $ms-color-neutralLight; - - .ms-CommandBarItem-icon { - color: $ms-color-themeDark; - } - - .ms-CommandBarItem-chevronDown { - color: $ms-color-neutralPrimaryAlt; - } - - .ms-CommandBarItem-overflow { - color: $ms-color-neutralDark; - } } + } - &.is-expanded { - background-color: $ms-color-neutralQuaternaryAlt; - color: $ms-color-black; - - .ms-CommandBarItem-icon { - color: $ms-color-themeDarker; - } - - .ms-CommandBarItem-chevronDown { - color: $ms-color-neutralDark; - } + &.itemLinkIsExpanded { + background-color: $ms-color-neutralQuaternaryAlt; + color: $ms-color-black; - .ms-CommandBarItem-overflow { - color: $ms-color-black; - } + .itemIcon { + color: $ms-color-themeDarker; } - &.is-expanded:hover { - background-color: $ms-color-neutralQuaternary; + .itemChevronDown { + color: $ms-color-neutralDark; } - &[disabled] { - color: $ms-color-neutralTertiaryAlt; - cursor: default; - pointer-events: none; - .ms-CommandBarItem-icon { - color: $ms-color-neutralTertiaryAlt; - } + .itemOverflow { + color: $ms-color-black; } } - .ms-CommandBarItem-icon { - font-size: $CommandBarItem-fontSize; - padding: 0 4px; - } - - .ms-CommandBarItem-iconColor { - color: $ms-color-themeDarkAlt; - } - - .ms-CommandBarItem-chevronDown { - color: $ms-color-neutralSecondary; - font-size: $CommandBarItem-chevronDown-fontSize; + &.itemLinkIsExpanded:hover { + background-color: $ms-color-neutralQuaternary; } - .ms-CommandBarItem-overflow { - font-size: $CommandBarItem-overflow-fontSize; - color: $ms-color-neutralPrimary; - padding: 0 7px; + &[disabled] { + color: $ms-color-neutralTertiaryAlt; + cursor: default; + pointer-events: none; + .itemIcon { + color: $ms-color-neutralTertiaryAlt; + } } +} - // CommandBarSearch needs to replaced with SearchBox component, and hence following styles revisited/cleaned. - .ms-CommandBarSearch { - @include float(left); - width: 208px; - max-width: 208px; - background-color: $ms-color-white; - color: $ms-color-neutralPrimary; - height: $SearchBox-height; - position: relative; - box-sizing: border-box; - border-color: transparent; // give a base state for animation - @include border-right(1px, solid, $ms-color-neutralLight); +.itemIcon { + font-size: $CommandBarItem-fontSize; + padding: 0 4px; +} - @media screen and (-ms-high-contrast: active) { - @include border-right(1px, solid, $ms-color-white); - z-index: 10; - } +.itemIconColor { + color: $ms-color-themeDarkAlt; +} - @media screen and (-ms-high-contrast: black-on-white) { - @include border-right(1px, solid, $ms-color-black); - } +.itemChevronDown { + color: $ms-color-neutralSecondary; + font-size: $CommandBarItem-chevronDown-fontSize; +} - &:before { - position: absolute; - content: ' '; - right: 0; - bottom: 0; - left: 0; - margin: 0 8px; - border-bottom: 1px solid $ms-color-neutralLight; - } +.itemOverflow { + font-size: $CommandBarItem-overflow-fontSize; + color: $ms-color-neutralPrimary; + padding: 0 7px; +} - &:hover { - color: $ms-color-themePrimary; +// CommandBarSearch needs to replaced with SearchBox component, and hence following styles revisited/cleaned. +.search { + @include float(left); + width: 208px; + max-width: 208px; + background-color: $ms-color-white; + color: $ms-color-neutralPrimary; + height: $SearchBox-height; + position: relative; + box-sizing: border-box; + border-color: transparent; // give a base state for animation + @include border-right(1px, solid, $ms-color-neutralLight); + + @media screen and (-ms-high-contrast: active) { + @include border-right(1px, solid, $ms-color-white); + z-index: 10; + } - @media screen and (-ms-high-contrast: active) { - @include highContrastBorder($ms-color-white); - } + @media screen and (-ms-high-contrast: black-on-white) { + @include border-right(1px, solid, $ms-color-black); + } - @media screen and (-ms-high-contrast: black-on-white) { - @include highContrastBorder($ms-color-black); - } - } + &:before { + position: absolute; + content: ' '; + right: 0; + bottom: 0; + left: 0; + margin: 0 8px; + border-bottom: 1px solid $ms-color-neutralLight; } - .ms-CommandBarSearch-input { - height: $SearchBox-height; - // Due to a bug in IE9, we have to use a transparent left border instead of left padding - padding: $SearchBox-sidePadding $SearchBox-sidePadding $SearchBox-sidePadding 0; - border: none; - @include border-left($SearchBox-height + 2, solid, transparent); - background-color: transparent; - width: 100%; - box-sizing: border-box; - outline: none; - cursor: pointer; - font-size: $ms-font-size-m; + &:hover { + color: $ms-color-themePrimary; @media screen and (-ms-high-contrast: active) { - @include border-left($SearchBox-height, solid, $ms-color-black); + @include highContrastBorder($ms-color-white); } @media screen and (-ms-high-contrast: black-on-white) { - @include border-left($SearchBox-height, solid, $ms-color-white); - } - - // remove default iOS styles on input boxes - -webkit-appearance: none; - -webkit-border-radius: 0; - - // hide IE's X button for clearing the input (we have our own) - &::-ms-clear { - display: none; + @include highContrastBorder($ms-color-black); } } +} - // default styles for icons, show the search icon and hide X (and arrow) until focused - .ms-CommandBarSearch-iconSearchWrapper { - display: block; +.searchInput { + height: $SearchBox-height; + // Due to a bug in IE9, we have to use a transparent left border instead of left padding + padding: $SearchBox-sidePadding $SearchBox-sidePadding $SearchBox-sidePadding 0; + border: none; + @include border-left($SearchBox-height + 2, solid, transparent); + background-color: transparent; + width: 100%; + box-sizing: border-box; + outline: none; + cursor: pointer; + font-size: $ms-font-size-m; + + @media screen and (-ms-high-contrast: active) { + @include border-left($SearchBox-height, solid, $ms-color-black); } - .ms-CommandBarSearch-iconArrowWrapper { - display: none; + @media screen and (-ms-high-contrast: black-on-white) { + @include border-left($SearchBox-height, solid, $ms-color-white); } - .ms-CommandBarSearch-iconSearchWrapper, - .ms-CommandBarSearch-iconArrowWrapper { - top: 0; - @include padding-left(17px); - @include padding-right(8px); - } + // remove default iOS styles on input boxes + -webkit-appearance: none; + -webkit-border-radius: 0; - .ms-CommandBarSearch-iconClearWrapper { + // hide IE's X button for clearing the input (we have our own) + &::-ms-clear { display: none; - top: 1px; - @include right(0px); - z-index: $ms-zIndex-front; } +} - //== State: Puts search in an active state - // - .ms-CommandBarSearch.is-active { - background-color: $ms-color-themeLight; - color: $ms-color-black; - - &:hover { - background-color: $ms-color-themeLight; - color: $ms-color-black; - } - - .ms-CommandBarSearch-input { - cursor: text; - @include padding-right($SearchBox-height); // leave room for the X - @include border-left-width($SearchBox-sidePadding); - } - - &.ms-CommandBarSearch--hasBack .ms-CommandBarSearch-input { - @include border-left-width($SearchBox-height); // leave room for arrow - } - - // when focused, remove the search icon and possibly show arrow icon - & .ms-CommandBarSearch-iconSearchWrapper { - display: none; - } +// default styles for icons, show the search icon and hide X (and arrow) until focused +.searchIconSearchWrapper { + display: block; +} - &.ms-CommandBarSearch--hasBack .ms-CommandBarSearch-iconArrowWrapper { - display: block; - } +.searchIconArrowWrapper { + display: none; +} - .ms-CommandBarSearch-input { - @include padding-right($SearchBox-height); - } +.searchIconSearchWrapper, +.searchIconArrowWrapper { + top: 0; + @include padding-left(17px); + @include padding-right(8px); +} - .ms-CommandBarSearch-iconClearWrapper { - display: block; - } - } +.searchIconClearWrapper { + display: none; + top: 1px; + @include right(0px); + z-index: $ms-zIndex-front; +} - .ms-CommandBarSearch-iconWrapper { - height: $SearchBox-height; - line-height: $SearchBox-height; - cursor: pointer; - position: absolute; - text-align: center; - } +.searchIconWrapper { + height: $SearchBox-height; + line-height: $SearchBox-height; + cursor: pointer; + position: absolute; + text-align: center; +} - // New rules - .ms-CommandBarSearch .ms-Icon:before { - font-size: $SearchBox-iconSize; - color: $ms-color-themePrimary; - } +// New rules +.search :global(.ms-Icon:before) { + font-size: $SearchBox-iconSize; + color: $ms-color-themePrimary; +} - .ms-CommandBarSearch-input, - .ms-CommandBarSearch-input::-webkit-input-placeholder { - @include ms-baseFont; - font-size: $ms-font-size-m; - } +.searchInput, +.searchInput::-webkit-input-placeholder { + @include ms-baseFont; + font-size: $ms-font-size-m; } + diff --git a/packages/office-ui-fabric-react/src/components/CommandBar/CommandBar.tsx b/packages/office-ui-fabric-react/src/components/CommandBar/CommandBar.tsx index a026dcaf2e386d..603b9b10b5248a 100644 --- a/packages/office-ui-fabric-react/src/components/CommandBar/CommandBar.tsx +++ b/packages/office-ui-fabric-react/src/components/CommandBar/CommandBar.tsx @@ -17,7 +17,7 @@ import { IconName, IIconProps } from '../../Icon'; -import './CommandBar.scss'; +import styles from './CommandBar.scss'; const OVERFLOW_KEY = 'overflow'; const OVERFLOW_WIDTH = 41.5; @@ -92,42 +92,51 @@ export class CommandBar extends React.Component - -
- +
+ +
+
-
- +
+
); } return ( -
+
{ searchBox } -
+
{ renderedItems.map((item, index) => ( this._renderItemInCommandBar(item, index, expandedMenuItemKey) )).concat((renderedOverflowItems && renderedOverflowItems.length) ? [ -
+
] : []) }
-
+
{ renderedFarItems.map((item, index) => ( this._renderItemInCommandBar(item, index, expandedMenuItemKey, true) )) } @@ -135,7 +144,7 @@ export class CommandBar extends React.Component { (contextualMenuProps) ? ( + return
{ (() => { if (item.onClick || hasSubmenuItems(item)) { return ; } else { return
{ (hasIcon) ? this._renderIcon(item) : (null) } - +
; } })() } @@ -199,8 +217,8 @@ export class CommandBar extends React.Component; }