office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
149 lines • 6.07 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { CommandBar } from 'office-ui-fabric-react/lib/CommandBar';
import { CommandBarButton } from 'office-ui-fabric-react/lib/Button';
var CommandBarButtonAsExample = /** @class */ (function (_super) {
tslib_1.__extends(CommandBarButtonAsExample, _super);
function CommandBarButtonAsExample() {
var _this = _super !== null && _super.apply(this, arguments) || this;
// Data for CommandBar
_this.getItems = function () {
return [
{
key: 'newItem',
name: 'New',
cacheKey: 'myCacheKey',
iconProps: {
iconName: 'Add'
},
ariaLabel: 'New. Use left and right arrow keys to navigate',
subMenuProps: {
items: [
(_a = {
key: 'emailMessage',
name: 'Email message',
iconProps: {
iconName: 'Mail'
}
},
_a['data-automation-id'] = 'newEmailButton',
_a),
{
key: 'calendarEvent',
name: 'Calendar event',
iconProps: {
iconName: 'Calendar'
}
}
]
}
},
(_b = {
key: 'upload',
name: 'Upload',
iconProps: {
iconName: 'Upload'
},
href: 'https://dev.office.com/fabric'
},
_b['data-automation-id'] = 'uploadButton',
_b),
{
key: 'share',
name: 'Share',
iconProps: {
iconName: 'Share'
},
onClick: function () { return console.log('Share'); }
},
{
key: 'download',
name: 'Download',
iconProps: {
iconName: 'Download'
},
onClick: function () { return console.log('Download'); }
}
];
var _a, _b;
};
_this.getOverlflowItems = function () {
return [
{
key: 'move',
name: 'Move to...',
onClick: function () { return console.log('Move to'); },
iconProps: {
iconName: 'MoveToFolder'
}
},
{
key: 'copy',
name: 'Copy to...',
onClick: function () { return console.log('Copy to'); },
iconProps: {
iconName: 'Copy'
}
},
{
key: 'rename',
name: 'Rename...',
onClick: function () { return console.log('Rename'); },
iconProps: {
iconName: 'Edit'
}
}
];
};
_this.getFarItems = function () {
return [
{
key: 'sort',
name: 'Sort',
iconProps: {
iconName: 'SortLines'
},
onClick: function () { return console.log('Sort'); }
},
{
key: 'tile',
name: 'Grid view',
iconProps: {
iconName: 'Tiles'
},
iconOnly: true,
onClick: function () { return console.log('Tiles'); }
},
{
key: 'info',
name: 'Info',
iconProps: {
iconName: 'Info'
},
iconOnly: true,
onClick: function () { return console.log('Info'); }
}
];
};
return _this;
}
CommandBarButtonAsExample.prototype.render = function () {
var customButton = function (props) {
var buttonOnMouseClick = function () { return alert(props.text + " clicked"); };
return (React.createElement(CommandBarButton, tslib_1.__assign({}, props, { onClick: buttonOnMouseClick, styles: tslib_1.__assign({}, props.styles, { textContainer: { fontSize: 18 }, icon: { color: 'red' } }) })));
};
return (React.createElement("div", null,
React.createElement(CommandBar, { overflowButtonProps: {
menuProps: {
items: [],
isBeakVisible: true,
beakWidth: 20,
gapSpace: 10,
directionalHint: 1 /* topCenter */
}
}, buttonAs: customButton, items: this.getItems(), overflowItems: this.getOverlflowItems(), farItems: this.getFarItems(), ariaLabel: 'Use left and right arrow keys to navigate between commands' })));
};
return CommandBarButtonAsExample;
}(React.Component));
export { CommandBarButtonAsExample };
//# sourceMappingURL=CommandBar.ButtonAs.Example.js.map