Skip to content

Commit

Permalink
Nav: update to latest redlines (#10008)
Browse files Browse the repository at this point in the history
* first

* add nav style reversion to MDL2 theme package

* Change files

* update snapshots and API

* code review feedback

* update

* more snapshots

* more changes

* update snapshots

* more fixes

* changes

* fix tslint error

* Fixes
  • Loading branch information
phkuo authored and msft-github-bot committed Aug 19, 2019
1 parent d317923 commit f0097f8
Show file tree
Hide file tree
Showing 16 changed files with 260 additions and 99 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Nav: update to latest redlines",
"packageName": "@uifabric/fluent-theme",
"email": "[email protected]",
"commit": "7779a3437650dff286de759c3474e6fe8c4294e7",
"date": "2019-07-31T21:05:19.873Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Nav: add backwards compat for update to latest redlines",
"packageName": "@uifabric/mdl2-theme",
"email": "[email protected]",
"commit": "7779a3437650dff286de759c3474e6fe8c4294e7",
"date": "2019-07-31T21:05:31.597Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "minor",
"comment": "Semantic slots: add bodyBackgroundHovered and bodyBackgroundSelected",
"packageName": "@uifabric/styling",
"email": "[email protected]",
"commit": "7779a3437650dff286de759c3474e6fe8c4294e7",
"date": "2019-07-31T21:05:43.090Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Nav: update to latest redlines",
"packageName": "office-ui-fabric-react",
"email": "[email protected]",
"commit": "7779a3437650dff286de759c3474e6fe8c4294e7",
"date": "2019-07-31T21:05:37.306Z"
}
4 changes: 4 additions & 0 deletions packages/fluent-theme/src/fluent/FluentStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { IconButtonStyles } from './styles/IconButton.styles';
import { LabelStyles } from './styles/Label.styles';
import { LinkStyles } from './styles/Link.styles';
import { ModalStyles } from './styles/Modal.styles';
import { NavStyles } from './styles/Nav.styles';
import { PanelStyles } from './styles/Panel.styles';
import { PeoplePickerItemStyles } from './styles/PeoplePicker.styles';
import { PersonaStyles } from './styles/Persona.styles';
Expand Down Expand Up @@ -130,6 +131,9 @@ export const FluentStyles: any = {
Modal: {
styles: ModalStyles
},
Nav: {
styles: NavStyles
},
Panel: {
styles: PanelStyles
},
Expand Down
48 changes: 48 additions & 0 deletions packages/fluent-theme/src/fluent/styles/Nav.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { INavStyleProps, INavStyles } from 'office-ui-fabric-react/lib/Nav';

export const NavStyles = (props: INavStyleProps): Partial<INavStyles> => {
const { theme, isDisabled, isSelected, isGroup, isLink, navHeight = 44 } = props;
const { semanticColors } = theme;

return {
link: [
{
height: navHeight,
lineHeight: `${navHeight}px`
},
!isDisabled && {
selectors: {
'.${classNames.compositeLink}:hover &': {
backgroundColor: semanticColors.bodyBackgroundHovered
}
}
},
isSelected && {
backgroundColor: semanticColors.bodyBackgroundChecked
}
],
chevronButton: [
{
lineHeight: `${navHeight}px`,
selectors: {
'&:hover': {
backgroundColor: semanticColors.bodyBackgroundHovered
},
'.${classNames.compositeLink}:hover &': {
backgroundColor: semanticColors.bodyBackgroundHovered
}
}
},
isGroup && {
height: navHeight
},
isLink && {
height: navHeight - 2
}
],
chevronIcon: {
height: navHeight,
lineHeight: `${navHeight}px`
}
};
};
4 changes: 4 additions & 0 deletions packages/mdl2-theme/src/mdl2/MDL2Styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { LabelStyles } from './styles/Label.styles';
import { LinkStyles } from './styles/Link.styles';
import { MessageBarStyles } from './styles/MessageBar.styles';
import { MessageBarButtonStyles } from './styles/MessageBarButton.styles';
import { NavStyles } from './styles/Nav.styles';
import { PanelStyles } from './styles/Panel.styles';
import { PersonaStyles, PersonaCoinStyles } from './styles/Persona.styles';
import { PivotStyles } from './styles/Pivot.styles';
Expand Down Expand Up @@ -121,6 +122,9 @@ export const MDL2Styles = {
MessageBarButton: {
styles: MessageBarButtonStyles
},
Nav: {
styles: NavStyles
},
Panel: {
styles: PanelStyles
},
Expand Down
48 changes: 48 additions & 0 deletions packages/mdl2-theme/src/mdl2/styles/Nav.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { INavStyleProps, INavStyles } from 'office-ui-fabric-react/lib/Nav';

export const NavStyles = (props: INavStyleProps): Partial<INavStyles> => {
const { theme, isDisabled, isSelected, isGroup, isLink, navHeight = 36 } = props;
const { palette } = theme;

return {
link: [
{
height: navHeight,
lineHeight: `${navHeight}px`
},
!isDisabled && {
selectors: {
'.ms-Nav-compositeLink:hover &': {
backgroundColor: palette.neutralLighterAlt
}
}
},
isSelected && {
backgroundColor: palette.neutralLighter
}
],
chevronButton: [
{
lineHeight: `${navHeight}px`,
selectors: {
'&:hover': {
backgroundColor: palette.neutralLighterAlt
},
'$compositeLink:hover &': {
backgroundColor: palette.neutralLighterAlt
}
}
},
isGroup && {
height: navHeight
},
isLink && {
height: navHeight - 2
}
],
chevronIcon: {
height: navHeight,
lineHeight: `${navHeight}px`
}
};
};
34 changes: 17 additions & 17 deletions packages/office-ui-fabric-react/src/components/Nav/Nav.styles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { INavStyleProps, INavStyles } from './Nav.types';
import { IButtonStyles } from '../../Button';
import { AnimationClassNames, getFocusStyle, ZIndexes, getGlobalClassNames, HighContrastSelector } from '../../Styling';
import { AnimationClassNames, getFocusStyle, ZIndexes, getGlobalClassNames, HighContrastSelector, FontWeights } from '../../Styling';

const GlobalClassNames = {
root: 'ms-Nav',
Expand All @@ -22,8 +22,7 @@ export const buttonStyles: IButtonStyles = {
label: {
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
overflow: 'hidden',
lineHeight: '36px'
overflow: 'hidden'
}
};

Expand All @@ -38,7 +37,7 @@ export const getStyles = (props: INavStyleProps): INavStyles => {
isSelected,
isDisabled,
isButtonEntry,
navHeight = 36,
navHeight = 44,
position,
leftPadding = 20,
leftPaddingExpanded = 28,
Expand Down Expand Up @@ -81,8 +80,7 @@ export const getStyles = (props: INavStyleProps): INavStyles => {
{
display: 'block',
position: 'relative',
color: semanticColors.bodyText,
backgroundColor: semanticColors.bodyBackground
color: semanticColors.bodyText
},
isExpanded && 'is-expanded',
isSelected && 'is-selected',
Expand All @@ -97,7 +95,7 @@ export const getStyles = (props: INavStyleProps): INavStyles => {
{
display: 'block',
position: 'relative',
height: `${navHeight}px`,
height: navHeight,
width: '100%',
lineHeight: `${navHeight}px`,
textDecoration: 'none',
Expand All @@ -122,14 +120,15 @@ export const getStyles = (props: INavStyleProps): INavStyles => {
!isDisabled && {
selectors: {
'.ms-Nav-compositeLink:hover &': {
backgroundColor: palette.neutralLighterAlt,
backgroundColor: semanticColors.bodyBackgroundHovered,
color: semanticColors.bodyText
}
}
},
isSelected && {
color: palette.themePrimary,
backgroundColor: palette.neutralLighter,
color: semanticColors.bodyTextChecked,
fontWeight: FontWeights.semibold, // todo: get from theme
backgroundColor: semanticColors.bodyBackgroundChecked,
selectors: {
'&:after': {
borderLeft: `2px solid ${palette.themePrimary}`,
Expand Down Expand Up @@ -173,24 +172,24 @@ export const getStyles = (props: INavStyleProps): INavStyles => {
},
'&:hover': {
color: semanticColors.bodyText,
backgroundColor: palette.neutralLighterAlt
backgroundColor: semanticColors.bodyBackgroundHovered
},
[`.${classNames.compositeLink}:hover &`]: {
color: semanticColors.bodyText,
backgroundColor: palette.neutralLighterAlt
backgroundColor: semanticColors.bodyBackgroundHovered
}
}
},
isGroup && {
fontSize: fonts.large.fontSize,
width: '100%',
height: `${navHeight}px`,
height: navHeight,
borderBottom: `1px solid ${semanticColors.bodyDivider}`
},
isLink && {
display: 'block',
width: `${leftPaddingExpanded - 2}px`,
height: `${navHeight - 2}px`,
width: leftPaddingExpanded - 2,
height: navHeight - 2,
position: 'absolute',
top: '1px',
left: `${position}px`,
Expand Down Expand Up @@ -220,7 +219,7 @@ export const getStyles = (props: INavStyleProps): INavStyles => {
{
position: 'absolute',
left: '8px',
height: `${navHeight}px`,
height: navHeight,
lineHeight: `${navHeight}px`,
fontSize: fonts.small.fontSize,
transition: 'transform .1s linear'
Expand All @@ -242,7 +241,8 @@ export const getStyles = (props: INavStyleProps): INavStyles => {
classNames.navItems,
{
listStyleType: 'none',
padding: 0
padding: 0,
margin: 0 // remove default <UL> styles
}
],
group: [classNames.group, isExpanded && 'is-expanded'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ exports[`Nav renders Nav correctly 1`] = `
ms-Nav-navItems
{
list-style-type: none;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
Expand All @@ -72,7 +76,6 @@ exports[`Nav renders Nav correctly 1`] = `
className=
ms-Nav-compositeLink
{
background-color: #ffffff;
color: #323130;
display: block;
position: relative;
Expand All @@ -98,8 +101,8 @@ exports[`Nav renders Nav correctly 1`] = `
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 14px;
font-weight: 400;
height: 36px;
line-height: 36px;
height: 44px;
line-height: 44px;
outline: transparent;
overflow: hidden;
padding-bottom: 0;
Expand Down Expand Up @@ -165,7 +168,7 @@ exports[`Nav renders Nav correctly 1`] = `
border-color: WindowText;
}
.ms-Nav-compositeLink:hover & {
background-color: #faf9f8;
background-color: #f3f2f1;
color: #323130;
}
data-is-focusable={true}
Expand Down
Loading

0 comments on commit f0097f8

Please sign in to comment.