UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

68 lines 3.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var React = require("react"); var office_ui_fabric_react_1 = require("office-ui-fabric-react"); // Non-mutating styles definition var stackItemStyles = { root: { alignItems: 'center', background: office_ui_fabric_react_1.DefaultPalette.themePrimary, color: office_ui_fabric_react_1.DefaultPalette.white, display: 'flex', height: 50, justifyContent: 'center', overflow: 'hidden' } }; var nonShrinkingStackItemStyles = { root: { alignItems: 'center', background: office_ui_fabric_react_1.DefaultPalette.themePrimary, color: office_ui_fabric_react_1.DefaultPalette.white, display: 'flex', height: 50, justifyContent: 'center', overflow: 'hidden', width: 500 } }; // Tokens definition var outerStackTokens = { childrenGap: 5 }; var innerStackTokens = { childrenGap: 5, padding: 10 }; var HorizontalStackShrinkExample = /** @class */ (function (_super) { tslib_1.__extends(HorizontalStackShrinkExample, _super); function HorizontalStackShrinkExample(props) { var _this = _super.call(this, props) || this; _this._onWidthChange = function (value) { _this.setState({ stackWidth: value }); }; _this.state = { stackWidth: 100 }; return _this; } HorizontalStackShrinkExample.prototype.render = function () { // Mutating styles definition var stackStyles = { root: { background: office_ui_fabric_react_1.DefaultPalette.themeTertiary, overflow: 'hidden', width: this.state.stackWidth + "%" } }; return (React.createElement(office_ui_fabric_react_1.Stack, { tokens: outerStackTokens }, React.createElement(office_ui_fabric_react_1.Slider, { label: "Change the stack width to see how child items shrink:", min: 1, max: 100, step: 1, defaultValue: 100, showValue: true, onChange: this._onWidthChange }), React.createElement(office_ui_fabric_react_1.Stack, { horizontal: true, styles: stackStyles, tokens: innerStackTokens }, React.createElement(office_ui_fabric_react_1.Stack.Item, { grow: true, styles: stackItemStyles }, "I shrink"), React.createElement(office_ui_fabric_react_1.Stack.Item, { grow: true, styles: stackItemStyles }, "I shrink"), React.createElement(office_ui_fabric_react_1.Stack.Item, { grow: true, disableShrink: true, styles: nonShrinkingStackItemStyles }, "I don't shrink"), React.createElement(office_ui_fabric_react_1.Stack.Item, { grow: true, styles: stackItemStyles }, "I shrink")))); }; return HorizontalStackShrinkExample; }(React.Component)); exports.HorizontalStackShrinkExample = HorizontalStackShrinkExample; //# sourceMappingURL=Stack.Horizontal.Shrink.Example.js.map