UNPKG

@douyinfe/semi-ui

Version:

A modern, comprehensive, flexible design system and UI library. Connect DesignOps & DevOps. Quickly build beautiful React apps. Maintained by Douyin-fe team.

54 lines 2.16 kB
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 cls from 'classnames'; import { cssClasses } from '@douyinfe/semi-foundation/lib/es/divider/constants'; import '@douyinfe/semi-foundation/lib/es/divider/divider.css'; const prefixCls = cssClasses.PREFIX; const Divider = props => { const { layout = 'horizontal', dashed, align = 'center', className, margin, style, children } = props, rest = __rest(props, ["layout", "dashed", "align", "className", "margin", "style", "children"]); const dividerClassNames = cls(`${prefixCls}-divider`, className, { [`${prefixCls}-divider-horizontal`]: layout === 'horizontal', [`${prefixCls}-divider-vertical`]: layout === 'vertical', [`${prefixCls}-divider-dashed`]: !!dashed, [`${prefixCls}-divider-with-text`]: children && layout === 'horizontal', [`${prefixCls}-divider-with-text-${align}`]: children && layout === 'horizontal' }); let overrideDefaultStyle = {}; if (margin !== undefined) { if (layout === 'vertical') { overrideDefaultStyle = { 'marginLeft': margin, 'marginRight': margin }; } else if (layout === 'horizontal') { overrideDefaultStyle = { 'marginTop': margin, 'marginBottom': margin }; } } return /*#__PURE__*/React.createElement("div", Object.assign({}, rest, { className: dividerClassNames, style: Object.assign(Object.assign({}, overrideDefaultStyle), style) }), children && layout === 'horizontal' ? typeof children === 'string' ? ( /*#__PURE__*/React.createElement("span", { className: `${prefixCls}-divider_inner-text`, "x-semi-prop": "children" }, children)) : children : null); }; export default Divider;