ci: Prettier纳入两层防御体系 (#520)
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Successful in 1m6s
CI Build & Deploy Pipeline / Build Staging Web Image (push) Successful in 1m49s
CI Build & Deploy Pipeline / Build Production API Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Web Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (push) Has been skipped
CI Build & Deploy Pipeline / Deploy Production (push) Has been skipped
CI Build & Deploy Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 3m1s
CI/CD Pipeline / Unit Tests (push) Successful in 3m20s
CI/CD Pipeline / Integration Tests (push) Successful in 1m29s
CI Build & Deploy Pipeline / Build Staging API Image (push) Successful in 7m4s
CI Build & Deploy Pipeline / Build Staging Worker Image (push) Successful in 7m54s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 45s
CI Build & Deploy Pipeline / Staging E2E Tests (push) Failing after 2m50s
CI Build & Deploy Pipeline / Staging API Integration Tests (push) Successful in 3m28s
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Successful in 1m6s
CI Build & Deploy Pipeline / Build Staging Web Image (push) Successful in 1m49s
CI Build & Deploy Pipeline / Build Production API Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Web Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (push) Has been skipped
CI Build & Deploy Pipeline / Deploy Production (push) Has been skipped
CI Build & Deploy Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 3m1s
CI/CD Pipeline / Unit Tests (push) Successful in 3m20s
CI/CD Pipeline / Integration Tests (push) Successful in 1m29s
CI Build & Deploy Pipeline / Build Staging API Image (push) Successful in 7m4s
CI Build & Deploy Pipeline / Build Staging Worker Image (push) Successful in 7m54s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 45s
CI Build & Deploy Pipeline / Staging E2E Tests (push) Failing after 2m50s
CI Build & Deploy Pipeline / Staging API Integration Tests (push) Successful in 3m28s
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
This commit was merged in pull request #520.
This commit is contained in:
@@ -2,26 +2,25 @@
|
||||
* V21 Button 按钮
|
||||
* 封装 Ant Design Button,应用 V21 设计系统样式
|
||||
*/
|
||||
import React from "react";
|
||||
import { Button as AntButton } from "antd";
|
||||
import type { ButtonProps as AntButtonProps } from "antd";
|
||||
import classNames from "classnames";
|
||||
import "./ui.css";
|
||||
import React from "react"
|
||||
import { Button as AntButton } from "antd"
|
||||
import type { ButtonProps as AntButtonProps } from "antd"
|
||||
import classNames from "classnames"
|
||||
import "./ui.css"
|
||||
|
||||
export type ButtonType =
|
||||
"primary" | "secondary" | "ghost" | "text" | "danger" | "link";
|
||||
export type ButtonType = "primary" | "secondary" | "ghost" | "text" | "danger" | "link"
|
||||
|
||||
export type ButtonSize = "sm" | "md" | "lg";
|
||||
export type ButtonSize = "sm" | "md" | "lg"
|
||||
|
||||
export interface ButtonProps extends Omit<AntButtonProps, "type" | "size"> {
|
||||
/** 按钮类型 */
|
||||
buttonType?: ButtonType;
|
||||
buttonType?: ButtonType
|
||||
/** 按钮尺寸 */
|
||||
buttonSize?: ButtonSize;
|
||||
buttonSize?: ButtonSize
|
||||
/** 兼容 antd type(用于直接替换) */
|
||||
type?: AntButtonProps["type"];
|
||||
type?: AntButtonProps["type"]
|
||||
/** 兼容 antd size */
|
||||
size?: AntButtonProps["size"];
|
||||
size?: AntButtonProps["size"]
|
||||
}
|
||||
|
||||
const TYPE_CLASS_MAP: Record<ButtonType, string> = {
|
||||
@@ -31,29 +30,29 @@ const TYPE_CLASS_MAP: Record<ButtonType, string> = {
|
||||
text: "xx-btn-text",
|
||||
danger: "xx-btn-danger",
|
||||
link: "xx-btn-link",
|
||||
};
|
||||
}
|
||||
|
||||
const SIZE_CLASS_MAP: Record<ButtonSize, string> = {
|
||||
sm: "xx-btn-sm",
|
||||
md: "xx-btn-md",
|
||||
lg: "xx-btn-lg",
|
||||
};
|
||||
}
|
||||
|
||||
/** 将 buttonType 映射到 antd type */
|
||||
const toAntdType = (bt: ButtonType): AntButtonProps["type"] => {
|
||||
switch (bt) {
|
||||
case "primary":
|
||||
return "primary";
|
||||
return "primary"
|
||||
case "danger":
|
||||
return "primary";
|
||||
return "primary"
|
||||
case "link":
|
||||
return "link";
|
||||
return "link"
|
||||
case "text":
|
||||
return "text";
|
||||
return "text"
|
||||
default:
|
||||
return "default";
|
||||
return "default"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const Button: React.FC<ButtonProps> = ({
|
||||
buttonType = "ghost",
|
||||
@@ -64,17 +63,16 @@ const Button: React.FC<ButtonProps> = ({
|
||||
size,
|
||||
...rest
|
||||
}) => {
|
||||
const antdType = type ?? toAntdType(buttonType);
|
||||
const antdType = type ?? toAntdType(buttonType)
|
||||
const antdSize =
|
||||
size ??
|
||||
(buttonSize === "sm" ? "small" : buttonSize === "lg" ? "large" : "middle");
|
||||
size ?? (buttonSize === "sm" ? "small" : buttonSize === "lg" ? "large" : "middle")
|
||||
|
||||
const v21Class = classNames(
|
||||
"xx-btn",
|
||||
TYPE_CLASS_MAP[buttonType],
|
||||
SIZE_CLASS_MAP[buttonSize],
|
||||
className,
|
||||
);
|
||||
)
|
||||
|
||||
return (
|
||||
<AntButton
|
||||
@@ -86,7 +84,7 @@ const Button: React.FC<ButtonProps> = ({
|
||||
>
|
||||
{children}
|
||||
</AntButton>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default Button;
|
||||
export default Button
|
||||
|
||||
Reference in New Issue
Block a user