Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,28 @@
"NODE_ENV": "development"
},
"sourceMaps": true
},
{
"type": "node",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to check this in? I'm guessing so but I just wanted to make sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I think this was just from testing with jest. Will revert this

"request": "launch",
"name": "Jest All",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"${relativeFile}"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Add secondaryText to ContextualMenuItem to render on the right of item.name (text)",
"type": "minor"
}
],
"packageName": "office-ui-fabric-react",
"email": "[email protected]"
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
"license": "MIT",
"devDependencies": {
"@microsoft/rush": "4.3.0"
},
"dependencies": {
"jest": "^22.4.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,11 @@ export interface IButtonStyles {
*/
description?: IStyle;

/**
* Style for the description text if applicable (for compound buttons.)
*/
secondaryText?: IStyle;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secondary text is here, but isn't being used in button.

If the idea is to replace description with secondaryText, lets start supporting both (in BaseButton.tsx and style files) so that we can deprecate description

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, sorry no I forgot to remove this. Am adding vr-tests now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought I am not sure. Without this addition I am unable to add this property to ContextualMenu.styles.ts (since this derives from IMenuStyles which falls under ButtonTypes.ts (namely, IMenuItemStyles extends IButtonStyles). Is this fine? Or how do you suggest adding it properly to just effect ContextualMenuItems?


/**
* Style override for the description text when the button is hovered.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { memoizeFunction } from '../../Utilities';
import { getDividerClassNames } from '../Divider/VerticalDivider.classNames';
import { getMenuItemStyles, getStyles as getContextualMenuStyles } from './ContextualMenu.styles';
import { ITheme, mergeStyleSets } from '../../Styling';
import { getStyles as getContextualMenuStyles, getMenuItemStyles } from './ContextualMenu.styles';
import { IVerticalDividerClassNames } from '../Divider/VerticalDivider.types';
import { getDividerClassNames } from '../Divider/VerticalDivider.classNames';
import { memoizeFunction } from '../../Utilities';

export interface IContextualMenuClassNames {
container: string;
Expand All @@ -21,6 +21,7 @@ export interface IMenuItemClassNames {
checkmarkIcon: string;
subMenuIcon: string;
label: string;
secondaryText: string;
splitContainer: string;
splitPrimary: string;
splitMenu: string;
Expand Down Expand Up @@ -198,6 +199,10 @@ export const getItemClassNames = memoizeFunction((
'ms-ContextualMenu-itemText',
styles.label
],
secondaryText: [
'ms-ContextualMenu-secondaryText',
styles.secondaryText
],
splitContainer: [
styles.splitButtonFlexContainer,
!disabled && !checked && [{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {
concatStyleSets,
FontSizes,
FontWeights,
IRawStyle,
ITheme,
concatStyleSets,
getFocusStyle,
HighContrastSelector
HighContrastSelector,
IRawStyle,
ITheme
} from '../../Styling';
import { IContextualMenuStyles, IMenuItemStyles } from './ContextualMenu.types';

import { memoizeFunction } from '../../Utilities';

const ContextualMenuItemHeight = '32px';
Expand Down Expand Up @@ -117,6 +116,11 @@ export const getMenuItemStyles = memoizeFunction((
overflow: 'hidden',
whiteSpace: 'nowrap'
},
secondaryText: {
color: theme.palette.neutralTertiary,
paddingLeft: '20px',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dzearing / @joschect How is RTL handled in Fabric? Is this handled in the build pipeline?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is handled automatically.

You can test it through npm start by going to the top right gear, and selecting the rtl option :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Thanks, @dzearing!

textAlign: 'right',
},
icon: {
display: 'inline-block',
minHeight: '1px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ export interface IContextualMenuItem {
*/
name?: string;

/**
* Seconday description for the menu item to display
*/
secondaryText?: string;

itemType?: ContextualMenuItemType;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ function getMenuItemClassNames(): IMenuItemClassNames {
checkmarkIcon: 'checkmarkIcon',
subMenuIcon: 'subMenuIcon',
label: 'label',
secondaryText: 'secondaryText',
splitContainer: 'splitContainer',
splitPrimary: 'splitPrimary',
splitMenu: 'splitMenu',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { hasSubmenu, getIsChecked } from '../../utilities/contextualMenu/index';
import { getIsChecked, hasSubmenu } from '../../utilities/contextualMenu/index';
import { getRTL } from '../../Utilities';
import { Icon } from '../../Icon';
import { IContextualMenuItemProps } from './ContextualMenuItem.types';
Expand Down Expand Up @@ -54,6 +54,13 @@ const renderItemName = ({ item, classNames }: IContextualMenuItemProps) => {
return null;
};

const renderSecondaryText = ({ item, classNames }: IContextualMenuItemProps) => {
if (item.secondaryText) {
return <span className={ classNames.secondaryText }>{ item.secondaryText }</span>;
}
return null;
};

const renderSubMenuIcon = ({ item, classNames }: IContextualMenuItemProps) => {
if (hasSubmenu(item)) {
return (
Expand All @@ -79,6 +86,7 @@ export const ContextualMenuItem: React.StatelessComponent<IContextualMenuItemPro
{ renderCheckMarkIcon(props) }
{ renderItemIcon(props) }
{ renderItemName(props) }
{ renderSecondaryText(props) }
{ renderSubMenuIcon(props) }
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '@uifabric/example-app-base';
import { ContextualMenuBasicExample } from './examples/ContextualMenu.Basic.Example';
import { ContextualMenuIconExample } from './examples/ContextualMenu.Icon.Example';
import { ContextualMenuIconSecondaryTextExample } from './examples/ContextualMenu.Icon.SecondaryText.Example';
import { ContextualMenuSectionExample } from './examples/ContextualMenu.Section.Example';
import { ContextualMenuSubmenuExample } from './examples/ContextualMenu.Submenu.Example';
import { ContextualMenuCustomizationWithNoWrapExample } from './examples/ContextualMenu.CustomizationWithNoWrap.Example';
Expand All @@ -21,6 +22,7 @@ import { ContextualMenuStatus } from './ContextualMenu.checklist';

const ContextualMenuBasicExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/ContextualMenu/examples/ContextualMenu.Basic.Example.tsx') as string;
const ContextualMenuIconExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/ContextualMenu/examples/ContextualMenu.Icon.Example.tsx') as string;
const ContextualMenuIconSecondaryTextExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/ContextualMenu/examples/ContextualMenu.Icon.SecondaryText.Example.tsx') as string;
const ContextualMenuSectionExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/ContextualMenu/examples/ContextualMenu.Section.Example.tsx') as string;
const ContextualMenuSubmenuExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/ContextualMenu/examples/ContextualMenu.Submenu.Example.tsx') as string;
const ContextualMenuCheckmarksExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/ContextualMenu/examples/ContextualMenu.Checkmarks.Example.tsx') as string;
Expand Down Expand Up @@ -51,6 +53,12 @@ export class ContextualMenuPage extends React.Component<IComponentDemoPageProps,
>
<ContextualMenuIconExample />
</ExampleCard>
<ExampleCard
title='ContextualMenu with icons and secondary text'
code={ ContextualMenuIconSecondaryTextExampleCode }
>
<ContextualMenuIconSecondaryTextExample />
</ExampleCard>
<ExampleCard
title='ContextualMenu with submenus'
code={ ContextualMenuSubmenuExampleCode }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function getMenuItemClassNames(): IMenuItemClassNames {
checkmarkIcon: 'checkmarkIcon',
subMenuIcon: 'subMenuIcon',
label: 'label',
secondaryText: 'secondaryText',
splitContainer: 'splitContainer',
splitPrimary: 'splitPrimary',
splitMenu: 'splitMenu',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ShallowWrapper {
"linkContent": "linkContent",
"linkContentMenu": "linkContentMenu",
"root": "root",
"secondaryText": "secondaryText",
"splitContainer": "splitContainer",
"splitMenu": "splitMenu",
"splitPrimary": "splitPrimary",
Expand Down Expand Up @@ -51,6 +52,7 @@ ShallowWrapper {
null,
null,
null,
null,
],
"className": "linkContent",
},
Expand All @@ -72,6 +74,7 @@ ShallowWrapper {
null,
null,
null,
null,
],
"type": "div",
},
Expand All @@ -90,6 +93,7 @@ ShallowWrapper {
null,
null,
null,
null,
],
"className": "linkContent",
},
Expand All @@ -111,6 +115,7 @@ ShallowWrapper {
null,
null,
null,
null,
],
"type": "div",
},
Expand Down Expand Up @@ -140,6 +145,7 @@ ShallowWrapper {
"linkContent": "linkContent",
"linkContentMenu": "linkContentMenu",
"root": "root",
"secondaryText": "secondaryText",
"splitContainer": "splitContainer",
"splitMenu": "splitMenu",
"splitPrimary": "splitPrimary",
Expand Down Expand Up @@ -174,6 +180,7 @@ ShallowWrapper {
className="icon"
/>,
null,
null,
<StyledIconBase
className="subMenuIcon"
iconName="ChevronRight"
Expand All @@ -196,6 +203,7 @@ ShallowWrapper {
"type": [Function],
},
null,
null,
Object {
"instance": null,
"key": undefined,
Expand Down Expand Up @@ -223,6 +231,7 @@ ShallowWrapper {
className="icon"
/>,
null,
null,
<StyledIconBase
className="subMenuIcon"
iconName="ChevronRight"
Expand All @@ -245,6 +254,7 @@ ShallowWrapper {
"type": [Function],
},
null,
null,
Object {
"instance": null,
"key": undefined,
Expand Down Expand Up @@ -286,6 +296,7 @@ ShallowWrapper {
"linkContent": "linkContent",
"linkContentMenu": "linkContentMenu",
"root": "root",
"secondaryText": "secondaryText",
"splitContainer": "splitContainer",
"splitMenu": "splitMenu",
"splitPrimary": "splitPrimary",
Expand Down Expand Up @@ -320,6 +331,7 @@ ShallowWrapper {
/>,
null,
null,
null,
],
"className": "linkContent",
},
Expand All @@ -339,6 +351,7 @@ ShallowWrapper {
},
null,
null,
null,
],
"type": "div",
},
Expand All @@ -355,6 +368,7 @@ ShallowWrapper {
/>,
null,
null,
null,
],
"className": "linkContent",
},
Expand All @@ -374,6 +388,7 @@ ShallowWrapper {
},
null,
null,
null,
],
"type": "div",
},
Expand Down Expand Up @@ -403,6 +418,7 @@ ShallowWrapper {
"linkContent": "linkContent",
"linkContentMenu": "linkContentMenu",
"root": "root",
"secondaryText": "secondaryText",
"splitContainer": "splitContainer",
"splitMenu": "splitMenu",
"splitPrimary": "splitPrimary",
Expand Down Expand Up @@ -443,6 +459,7 @@ ShallowWrapper {
menuItem
</span>,
null,
null,
],
"className": "linkContent",
},
Expand Down Expand Up @@ -474,6 +491,7 @@ ShallowWrapper {
"type": "span",
},
null,
null,
],
"type": "div",
},
Expand All @@ -495,6 +513,7 @@ ShallowWrapper {
menuItem
</span>,
null,
null,
],
"className": "linkContent",
},
Expand Down Expand Up @@ -526,6 +545,7 @@ ShallowWrapper {
"type": "span",
},
null,
null,
],
"type": "div",
},
Expand Down
Loading