Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a8e4cc3
Copy Overflow Code into branch
micahgodbolt Apr 17, 2017
7345c8c
Adding focus zone around overflow set
micahgodbolt Apr 17, 2017
c3ff083
Updated docs and icon props
micahgodbolt Apr 17, 2017
62a5469
Adding change file
micahgodbolt Apr 17, 2017
eb237c8
Update OverflowSet.Props.ts
micahgodbolt Apr 18, 2017
9de2ec2
Improve prop comments
micahgodbolt Apr 18, 2017
d54c5c6
Fixed merge conflict
micahgodbolt Apr 18, 2017
228ddd1
Merge branch 'master' into overflow-set
micahgodbolt Apr 18, 2017
cd011db
Fixed a few PR requests
micahgodbolt Apr 18, 2017
1085601
Merge branch 'overflow-set' of https://github.com/micahgodbolt/office…
micahgodbolt Apr 18, 2017
850c74a
Fixed overflow icon styles
micahgodbolt Apr 18, 2017
8155ef5
Created an IOverflowItemProps
micahgodbolt Apr 18, 2017
e296f1a
Merge branch 'master' into overflow-set
micahgodbolt Apr 18, 2017
e8e30c0
Merge branch 'master' into overflow-set
micahgodbolt Apr 20, 2017
458ad1f
Merge branch 'master' into overflow-set
micahgodbolt Apr 21, 2017
c81f76e
Merge branch 'master' into overflow-set
micahgodbolt Apr 21, 2017
ac1cb5e
Merge branch 'master' into overflow-set
micahgodbolt Apr 24, 2017
b526d40
Merge branch 'master' into overflow-set
micahgodbolt Apr 25, 2017
7e74eef
Merge branch 'master' into overflow-set
micahgodbolt Apr 25, 2017
fe718e3
Updated buttons to accept ClassNames, changed overflowset to use defa…
micahgodbolt Apr 25, 2017
6d9fd0f
Merge branch 'overflow-set' of https://github.com/micahgodbolt/office…
micahgodbolt Apr 25, 2017
a887b22
Merge branch 'master' into overflow-set
micahgodbolt Apr 25, 2017
82a4188
Merge branch 'master' into overflow-set
micahgodbolt Apr 26, 2017
2eab455
Merge branch 'master' into overflow-set
micahgodbolt Apr 26, 2017
fd424b4
Updated example to be more actual use case
micahgodbolt Apr 26, 2017
8f35a16
Merge branch 'overflow-set' of https://github.com/micahgodbolt/office…
micahgodbolt Apr 26, 2017
8d7bc00
Removed default overflow button render as each one will certainly be …
micahgodbolt Apr 26, 2017
e7b86db
Fixed linting errors
micahgodbolt Apr 26, 2017
82c5b6d
Merge branch 'master' into overflow-set
micahgodbolt Apr 26, 2017
988e0c7
Merge branch 'master' into overflow-set
micahgodbolt Apr 27, 2017
c0884d9
Changed onRenderOverfowButton to be of type IButtonProps for better c…
micahgodbolt Apr 27, 2017
198e3ae
Merge branch 'overflow-set' of https://github.com/micahgodbolt/office…
micahgodbolt Apr 27, 2017
2520d1d
Update button assign to mix props into empty object
micahgodbolt Apr 27, 2017
d9ba936
Moved custom onRender to the custom example. Created basic example wi…
micahgodbolt Apr 27, 2017
d57593a
Moved class props into button props file
micahgodbolt Apr 27, 2017
ac26ad3
Commented out overflow set index.ts to keep hidden for now
micahgodbolt Apr 27, 2017
e8eff9c
Fix documentation and added key back to onRenderItems
micahgodbolt Apr 28, 2017
473c484
Fixed linting errors
micahgodbolt Apr 28, 2017
78275f9
Merge branch 'master' into overflow-set
micahgodbolt Apr 28, 2017
35f9325
Merge branch 'master' into overflow-set
micahgodbolt May 1, 2017
bb54cbd
Merge branch 'overflow-set' of https://github.com/micahgodbolt/office…
micahgodbolt May 1, 2017
e8c2960
Revert button changes
micahgodbolt May 1, 2017
6d424e3
updated example and items type
micahgodbolt May 1, 2017
038b3f7
Updated dropdown to have defaultText
micahgodbolt May 2, 2017
edb0ec5
Added change file
micahgodbolt May 2, 2017
a72004f
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
micahgodbolt May 3, 2017
30c1a74
Merge branch 'master' into overflow-set
micahgodbolt May 3, 2017
501956d
Merge master
micahgodbolt May 3, 2017
8f64dec
Update master_2017-05-02-22-52.json
micahgodbolt May 3, 2017
2e4df29
Merge branch 'master' into overflow-set
micahgodbolt May 3, 2017
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
10 changes: 10 additions & 0 deletions common/changes/overflow-set_2017-04-17-21-47.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "OverflowSet: New Overflow Set componet to create sets of elements with overflow showing in callout",
"type": "patch"
}
],
"email": "micahgodbolt@gmail.com"
}
1 change: 1 addition & 0 deletions packages/office-ui-fabric-react/src/OverflowSet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/OverflowSet/index';
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class BaseButton extends BaseComponent<IBaseButtonProps, IBaseButtonState
}

return (
menuIconProps ?
menuIconProps && menuIconProps.iconName ?
<Icon
{ ...menuIconProps }
className={ css(`${classNames.base}-icon`, classNames.menuIcon, menuIconProps.className) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as React from 'react';
import { OverflowSet } from './OverflowSet';
import { IContextualMenuItem } from '../../ContextualMenu';
import { IIconProps } from '../../Icon';
import { IRenderFunction } from '../../Utilities';

export interface IOverflowSetProps extends React.Props<OverflowSet> {

/**
* An array of items to be rendered by your onRenderItem function in the primary content area
*/
items?: any[];

/**
* An array of items to be passed to overflow contextual menu
*/
overflowItems?: IContextualMenuItem[];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are the types different items vs overflow items?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

OverflowItems are meant to be rendered in a contextual menu. Of course there isn't anything stopping someone from rendering them in something else....If any[] is prefered I have no problems either way.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think contextualmenuitem already has a mechanism to render anything else inside them, so I think it is ok.


/**
* Icon props used to override overflow icon.
*/
iconProps?: IIconProps;

/**
* Method to call when trying to render an item.
* If item contains an onRender, that function will be used instead.
*/
onRenderItem?: IRenderFunction<any>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@import '../../common/common';

.root {
position: relative;
display: flex;
flex-wrap: nowrap;
}


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit blank

.item {
flex-shrink: 0;
}

.overflowIcon {
align-self: stretch;
height: auto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import * as React from 'react';
import {
css,
autobind,
BaseComponent
} from '../../Utilities';
import { IOverflowSetProps } from './OverflowSet.Props';
import { IconButton } from '../../Button';
import { FocusZone, FocusZoneDirection } from '../../FocusZone';

const styles: any = require('./OverflowSet.scss');

export class OverflowSet extends BaseComponent<IOverflowSetProps, null> {

public render() {
let { items, overflowItems } = this.props;
return (
<FocusZone className={ css('ms-OverflowSet', styles.root) } direction={ FocusZoneDirection.horizontal } role='menubar' >
{ items && this._onRenderItems(items) }
{ overflowItems.length && this._onRenderOverflowButton(overflowItems) }
</FocusZone>
);
}

@autobind
private _onRenderOverflowButton(items) {
let { iconProps = {} } = this.props;
iconProps.iconName = iconProps.iconName ? iconProps.iconName : 'More';
return (
<IconButton
className={ css(styles.overflowIcon) }
iconProps={ iconProps }
menuIconProps={ { iconName: null } }
menuProps={ {
items: items
} }
/>
);
}

@autobind
private _onRenderItems(items) {
return items.map((item, i) => {
let key = item.key ? item.key : i;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The props definition should say that items can take a key. It might even be worth explicitly stating this in the type definition instead of just putting any (though not sure how to best do that, maybe an intersection type?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can do this in the prop items?: any[] | { key: string }[];

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not sure if this really solves it though. Basically it's either anything, or just a key. Unless I don't understand intersection properly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You actually probably don't need an intersection, you can just say items?: {key?: string} []. You can assign anything to that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

items?: {key?: string} [] would mean that [{key: foo, bar: baz}] would be invalid. I can either specify no props or all of the props.

image

let onRender = item.onRender ? item.onRender : this.props.onRenderItem;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This won't work;

onRender has a signature (item) => JSX.Element
onRenderItem has a signature (props, defaultRender) => JSX.element

Youre passing item and index, which satisfies neither.

return (
<div
className={ css('ms-OverflowSet-item', styles.item) }
key={ key } >
{ onRender ? onRender(item, i) : item }
</div>
);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as React from 'react';
import { Link } from 'office-ui-fabric-react/lib/Link';
import { LayerHost } from 'office-ui-fabric-react/lib/Layer';
import {
ExampleCard,
ComponentPage,
PropertiesTableSet
} from '@uifabric/example-app-base';
import { OverflowSetBasicExample } from './examples/OverflowSet.Basic.Example';

const OverflowSetBasicExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/OverflowSet/examples/OverflowSet.Basic.Example.tsx') as string;

export class OverflowSetPage extends React.Component<any, any> {
public render() {
return (
<ComponentPage
title='OverflowSet'
componentName='OverflowSetExample'
overview={
<div>
<p>
The Overflow Set component is a flexible container component that is usefull for displaying a primary set of content with additional content in an overflow callout.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

spelling

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OverflowSet ?

</p>
</div>
}
exampleCards={
<LayerHost>
<ExampleCard title='OverflowSet' code={ OverflowSetBasicExampleCode }>
<OverflowSetBasicExample />
</ExampleCard>
</LayerHost>
}
propertiesTables={
<PropertiesTableSet
sources={ [
require<string>('!raw-loader!office-ui-fabric-react/src/components/OverflowSet/OverflowSet.Props.ts')
] }
/>
}
/>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/* tslint:disable:no-unused-variable */
import * as React from 'react';
/* tslint:enable:no-unused-variable */
import { BaseComponent } from 'office-ui-fabric-react/lib/Utilities';
import { PrimaryButton } from 'office-ui-fabric-react/lib/Button';
import { DefaultButton } from 'office-ui-fabric-react/lib/Button';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you can collapse these two

import {
OverflowSet
} from '../index';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

examples should have imports that the user would do...


export class OverflowSetBasicExample extends BaseComponent<any, any> {

public render() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe you should keep the basic example basic and have a "customized" example to customized. Reading the docs this is basically a for loop on items to render them as a given thing, with a menuProps.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sounds good.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is done

return (
<OverflowSet
items={ [
{
key: 'search',
'onRender': () => {
return (
<PrimaryButton
iconProps={ { iconName: 'Add' } }
text='Add'
/>
);
}
},
{
key: 'newItem',
name: 'New',
icon: 'Add',
ariaLabel: 'New. Use left and right arrow keys to navigate',
onClick: () => { return; },
subMenuProps: {
items: [
{
key: 'emailMessage',
name: 'Email message',
icon: 'Mail',
},
{
key: 'calendarEvent',
name: 'Calendar event',
icon: 'Calendar'
}
],
},
},
{
key: 'upload',
name: 'Upload',
icon: 'Upload',
onClick: () => { return; },
},
{
key: 'share',
name: 'Share',
icon: 'Share',
onClick: () => { return; }
}
] }
overflowItems={ [
{
key: 'newItem',
name: 'Add',
icon: 'Add',
ariaLabel: 'New. Use left and right arrow keys to navigate',
onClick: () => { return; },
subMenuProps: {
items: [
{
key: 'emailMessage',
name: 'Email message',
icon: 'Mail',
},
{
key: 'calendarEvent',
name: 'Calendar event',
icon: 'Calendar'
}
],
},
},
{
key: 'move',
name: 'Move to...',
icon: 'MoveToFolder',
onClick: () => { return; }
},
{
key: 'copy',
name: 'Copy to...',
icon: 'Copy',
onClick: () => { return; }
},
{
key: 'rename',
name: 'Rename...',
icon: 'Edit',
onClick: () => { return; }
},
{
key: 'disabled',
name: 'Disabled...',
icon: 'Cancel',
disabled: true,
onClick: () => { return; }
}
]
}
onRenderItem={ (item) => {
return (
<DefaultButton
iconProps={ { iconName: item.icon } }
menuProps={ item.subMenuProps }
text={ item.name }
> </DefaultButton>
);
} }
/>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './OverflowSet';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

don't add this here until we're using it and happy with it.

export * from './OverflowSet.Props';
6 changes: 6 additions & 0 deletions packages/office-ui-fabric-react/src/demo/AppDefinition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ export const AppDefinition: IAppDefinition = {
name: 'Overlay',
url: '#/examples/overlay'
},
{
getComponent: cb => cb(require<any>('../components/OverflowSet/OverflowSetPage').OverflowSetPage),
key: 'OverflowSet',
name: 'OverflowSet',
url: '#/examples/overflowset'
},
{
getComponent: cb => cb(require<any>('../components/Panel/PanelPage').PanelPage),
key: 'Panel',
Expand Down