UNPKG

@oceanbase/design

Version:
152 lines (150 loc) 4.8 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/alert/style/index.ts var style_exports = {}; __export(style_exports, { default: () => style_default, genAlertStyle: () => genAlertStyle }); module.exports = __toCommonJS(style_exports); var import_genComponentStyleHook = require("../../_util/genComponentStyleHook"); var genTypeStyle = (color, token) => { const borderWidth = 8; return { content: '""', width: borderWidth, // 绕 Y 轴旋转 60deg 是为了让圆角有一定的视觉拉伸,以与原先的边框贴合更加紧密 transform: "rotateY(60deg)", backgroundColor: color, position: "absolute", height: `calc(100% - ${token.lineWidth}px)`, left: -token.lineWidth - borderWidth / 2 / 2, top: token.lineWidth / 2, borderTopLeftRadius: token.borderRadiusLG, borderBottomLeftRadius: token.borderRadiusLG }; }; var genColoredStyle = (color, colorHover, token) => { const { componentCls, iconCls } = token; return { [`${componentCls}-message`]: { color }, [`${componentCls}-description`]: { color }, [`${componentCls}-close-icon`]: { [`${iconCls}`]: { color, "&:hover": { color: colorHover } }, [`${componentCls}-close-text`]: { color, "&:hover": { color: colorHover } } } }; }; var genAlertStyle = (token) => { const { componentCls, colorSuccess, colorSuccessHover, colorInfo, colorInfoHover, colorWarning, colorWarningHover, colorError, colorErrorHover, colorIcon, colorIconHover, motionDurationMid } = token; const height = token.fontSize * token.lineHeight; return { [`${componentCls}`]: { // vertical align to flex-start alignItems: "flex-start !important", paddingRight: token.padding, [`${componentCls}-icon`]: { height }, [`${componentCls}-close-icon`]: { height, color: colorIcon, transition: `color ${motionDurationMid}`, "&:hover": { color: colorIconHover } } }, [`${componentCls}:not(${componentCls}-with-description)`]: { paddingLeft: token.padding }, [`${componentCls}${componentCls}-with-description`]: { paddingBlock: token.padding, [`${componentCls}-message`]: { fontWeight: 500, marginBottom: token.marginXXS }, [`${componentCls}-description`]: { color: token.colorTextSecondary }, [`${componentCls}-icon`]: { fontSize: token.fontSizeHeading4, height: token.fontSizeHeading3, marginInlineEnd: token.margin }, [`${componentCls}-action`]: { marginInlineStart: token.marginXS } }, [`${componentCls}:not(${componentCls}-banner):not(${componentCls}-ghost)`]: { [`&${componentCls}-success::before`]: genTypeStyle(colorSuccess, token), [`&${componentCls}-info::before`]: genTypeStyle(colorInfo, token), [`&${componentCls}-warning::before`]: genTypeStyle(colorWarning, token), [`&${componentCls}-error::before`]: genTypeStyle(colorError, token) }, [`${componentCls}${componentCls}-ghost`]: { backgroundColor: "transparent", border: "none", padding: 0, borderRadius: 0 }, [`${componentCls}-colored`]: { [`&${componentCls}-success`]: genColoredStyle(colorSuccess, colorSuccessHover, token), [`&${componentCls}-info`]: genColoredStyle(colorInfo, colorInfoHover, token), [`&${componentCls}-warning`]: genColoredStyle(colorWarning, colorWarningHover, token), [`&${componentCls}-error`]: genColoredStyle(colorError, colorErrorHover, token) } }; }; var style_default = (prefixCls) => { const useStyle = (0, import_genComponentStyleHook.genComponentStyleHook)("Alert", (token) => { return [genAlertStyle(token)]; }); return useStyle(prefixCls); }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { genAlertStyle });