frc-ui
Version:
React Web UI
56 lines (55 loc) • 2.5 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import React from 'react';
import classNames from 'classnames';
const defaultProps = {
collapsed: false
};
class CollapseButton extends React.PureComponent {
constructor() {
super(...arguments);
this.f_path = () => {
const { direction, collapsed } = this.props;
if (collapsed) {
switch (direction) {
case 'left':
return 'right';
case 'right':
return 'left';
case 'top':
return 'bottom';
case 'bottom':
return 'top';
default:
return direction;
}
}
return direction;
};
}
render() {
const _a = this.props, { direction, className } = _a, other = __rest(_a, ["direction", "className"]);
delete other.collapsed;
const cls = classNames('swc-collapse-button', `swc-collapse-button-${direction}`, className);
const path = {
left: 'M736.4375 1024 224.4375 512 736.4375 0l63.125 63.125L350.7525 512l448.81 448.875L736.4375 1024z',
right: 'M287.5625 0L799.56249999 512 287.5625 1024l-63.125-63.125L673.2475 512l-448.81-448.875L287.5625 0z',
top: 'M0 736.4375L512 224.43750001 1024 736.4375l-63.125 63.125L512 350.7525l-448.875 448.81L0 736.4375z',
bottom: 'M1024 287.5625L512 799.56249999 0 287.5625l63.125-63.125L512 673.2475l448.875-448.81L1024 287.5625z'
};
let d = path[this.f_path()];
return (React.createElement("div", Object.assign({}, other, { className: cls }),
React.createElement("svg", { viewBox: '0 0 1024 1024', className: 'swc-collapse-button-arrow', width: '1em', height: '1em', fill: 'currentColor', "aria-hidden": 'true', focusable: 'false' },
React.createElement("path", { d: d }))));
}
}
export default CollapseButton;