migrate components starting with the letter B
### components ### * BackTop * Badge * Breadcrumb * Button
This commit is contained in:
Родитель
0942affdf9
Коммит
11f484c154
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using CssInCSharp;
|
||||
using static AntDesign.GlobalStyle;
|
||||
using static AntDesign.Theme;
|
||||
|
@ -107,35 +107,44 @@ namespace AntDesign
|
|||
|
||||
protected override UseComponentStyleResult UseComponentStyle()
|
||||
{
|
||||
return GenComponentStyleHook("BackTop", (token) =>
|
||||
{
|
||||
var fontSizeHeading3 = token.FontSizeHeading3;
|
||||
var colorTextDescription = token.ColorTextDescription;
|
||||
var colorTextLightSolid = token.ColorTextLightSolid;
|
||||
var colorText = token.ColorText;
|
||||
var controlHeightLG = token.ControlHeightLG;
|
||||
var backTopToken = MergeToken(
|
||||
token,
|
||||
new BackTopToken()
|
||||
{
|
||||
BackTopBackground = colorTextDescription,
|
||||
BackTopColor = colorTextLightSolid,
|
||||
BackTopHoverBackground = colorText,
|
||||
BackTopFontSize = fontSizeHeading3,
|
||||
BackTopSize = controlHeightLG,
|
||||
BackTopBlockEnd = (int)(controlHeightLG * 1.25),
|
||||
BackTopInlineEnd = (int)(controlHeightLG * 2.5),
|
||||
BackTopInlineEndMD = (int)(controlHeightLG * 1.5),
|
||||
BackTopInlineEndXS = (int)(controlHeightLG * 0.5),
|
||||
ZIndexPopup = token.ZIndexBase + 10,
|
||||
});
|
||||
return new CSSInterpolation[]
|
||||
return GenComponentStyleHook(
|
||||
"BackTop",
|
||||
(token) =>
|
||||
{
|
||||
GenSharedBackTopStyle(backTopToken),
|
||||
GenMediaBackTopStyle(backTopToken)
|
||||
};
|
||||
});
|
||||
var fontSizeHeading3 = token.FontSizeHeading3;
|
||||
var colorTextDescription = token.ColorTextDescription;
|
||||
var colorTextLightSolid = token.ColorTextLightSolid;
|
||||
var colorText = token.ColorText;
|
||||
var controlHeightLG = token.ControlHeightLG;
|
||||
var backTopToken = MergeToken(
|
||||
token,
|
||||
new BackTopToken()
|
||||
{
|
||||
BackTopBackground = colorTextDescription,
|
||||
BackTopColor = colorTextLightSolid,
|
||||
BackTopHoverBackground = colorText,
|
||||
BackTopFontSize = fontSizeHeading3,
|
||||
BackTopSize = controlHeightLG,
|
||||
BackTopBlockEnd = (int)(controlHeightLG * 1.25),
|
||||
BackTopInlineEnd = (int)(controlHeightLG * 2.5),
|
||||
BackTopInlineEndMD = (int)(controlHeightLG * 1.5),
|
||||
BackTopInlineEndXS = (int)(controlHeightLG * 0.5),
|
||||
});
|
||||
return new CSSInterpolation[]
|
||||
{
|
||||
GenSharedBackTopStyle(backTopToken),
|
||||
GenMediaBackTopStyle(backTopToken)
|
||||
};
|
||||
},
|
||||
(token) =>
|
||||
{
|
||||
return new BackTopToken()
|
||||
{
|
||||
ZIndexPopup = token.ZIndexBase + 10,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using CssInCSharp;
|
||||
using static AntDesign.GlobalStyle;
|
||||
using static AntDesign.Theme;
|
||||
|
@ -150,7 +150,8 @@ namespace AntDesign
|
|||
var numberPrefixCls = @$"{antCls}-scroll-number";
|
||||
var colorPreset = GenPresetColor(
|
||||
token,
|
||||
(colorKey, args) => {
|
||||
(colorKey, args) =>
|
||||
{
|
||||
var darkColor = args.DarkColor;
|
||||
return new CSSObject()
|
||||
{
|
||||
|
@ -387,52 +388,67 @@ namespace AntDesign
|
|||
};
|
||||
}
|
||||
|
||||
public BadgeToken PrepareToken(BadgeToken token)
|
||||
{
|
||||
var fontSize = token.FontSize;
|
||||
var lineHeight = token.LineHeight;
|
||||
var lineWidth = token.LineWidth;
|
||||
var marginXS = token.MarginXS;
|
||||
var colorBorderBg = token.ColorBorderBg;
|
||||
var badgeFontHeight = (int)Math.Round((double)fontSize * lineHeight);
|
||||
var badgeShadowSize = lineWidth;
|
||||
var badgeTextColor = token.ColorBgContainer;
|
||||
var badgeColor = token.ColorError;
|
||||
var badgeColorHover = token.ColorErrorHover;
|
||||
var badgeToken = MergeToken(
|
||||
token,
|
||||
new BadgeToken()
|
||||
{
|
||||
BadgeFontHeight = badgeFontHeight,
|
||||
BadgeShadowSize = badgeShadowSize,
|
||||
BadgeTextColor = badgeTextColor,
|
||||
BadgeColor = badgeColor,
|
||||
BadgeColorHover = badgeColorHover,
|
||||
BadgeShadowColor = colorBorderBg,
|
||||
BadgeProcessingDuration = "1.2s",
|
||||
BadgeRibbonOffset = marginXS,
|
||||
BadgeRibbonCornerTransform = "scaleY(0.75)",
|
||||
BadgeRibbonCornerFilter = @$"brightness(75%)",
|
||||
});
|
||||
return badgeToken;
|
||||
}
|
||||
|
||||
public BadgeToken PrepareComponentToken(GlobalToken token)
|
||||
{
|
||||
var fontSize = token.FontSize;
|
||||
var lineHeight = token.LineHeight;
|
||||
var fontSizeSM = token.FontSizeSM;
|
||||
var lineWidth = token.LineWidth;
|
||||
return new BadgeToken()
|
||||
{
|
||||
IndicatorZIndex = "auto",
|
||||
IndicatorHeight = (int)Math.Round((double)fontSize * lineHeight) - 2 * lineWidth,
|
||||
IndicatorHeightSM = fontSize,
|
||||
DotSize = fontSizeSM / 2,
|
||||
TextFontSize = fontSizeSM,
|
||||
TextFontSizeSM = fontSizeSM,
|
||||
TextFontWeight = "normal",
|
||||
StatusSize = fontSizeSM / 2,
|
||||
};
|
||||
}
|
||||
|
||||
protected override UseComponentStyleResult UseComponentStyle()
|
||||
{
|
||||
return GenComponentStyleHook("Badge", (token) =>
|
||||
{
|
||||
var fontSize = token.FontSize;
|
||||
var lineHeight = token.LineHeight;
|
||||
var lineWidth = token.LineWidth;
|
||||
var marginXS = token.MarginXS;
|
||||
var colorBorderBg = token.ColorBorderBg;
|
||||
var badgeFontHeight = (int)Math.Round((double)fontSize * lineHeight);
|
||||
var badgeShadowSize = lineWidth;
|
||||
var badgeTextColor = token.ColorBgContainer;
|
||||
var badgeColor = token.ColorError;
|
||||
var badgeColorHover = token.ColorErrorHover;
|
||||
var fontSizeSM = token.FontSizeSM;
|
||||
|
||||
var badgeToken = MergeToken(
|
||||
token,
|
||||
new BadgeToken()
|
||||
{
|
||||
BadgeFontHeight = badgeFontHeight,
|
||||
BadgeShadowSize = badgeShadowSize,
|
||||
BadgeTextColor = badgeTextColor,
|
||||
BadgeColor = badgeColor,
|
||||
BadgeColorHover = badgeColorHover,
|
||||
BadgeShadowColor = colorBorderBg,
|
||||
BadgeProcessingDuration = "1.2s",
|
||||
BadgeRibbonOffset = marginXS,
|
||||
BadgeRibbonCornerTransform = "scaleY(0.75)",
|
||||
BadgeRibbonCornerFilter = @$"brightness(75%)",
|
||||
|
||||
IndicatorZIndex = "auto",
|
||||
IndicatorHeight = (int)Math.Round((double)fontSize * lineHeight) - 2 * lineWidth,
|
||||
IndicatorHeightSM = fontSize,
|
||||
DotSize = fontSizeSM / 2,
|
||||
TextFontSize = fontSizeSM,
|
||||
TextFontSizeSM = fontSizeSM,
|
||||
TextFontWeight = "normal",
|
||||
StatusSize = fontSizeSM / 2,
|
||||
});
|
||||
return new CSSInterpolation[]
|
||||
return GenComponentStyleHook(
|
||||
"Badge",
|
||||
(token) =>
|
||||
{
|
||||
GenSharedBadgeStyle(badgeToken)
|
||||
};
|
||||
});
|
||||
var badgeToken = PrepareToken(token);
|
||||
return new CSSInterpolation[] { GenSharedBadgeStyle(badgeToken) };
|
||||
},
|
||||
PrepareComponentToken);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using CssInCSharp;
|
||||
using static AntDesign.GlobalStyle;
|
||||
using static AntDesign.Theme;
|
||||
|
@ -59,7 +59,7 @@ namespace AntDesign
|
|||
Transition = @$"color {token.MotionDurationMid}",
|
||||
Padding = @$"0 {token.PaddingXXS}px",
|
||||
BorderRadius = token.BorderRadiusSM,
|
||||
Height = (int)token.LineHeight * token.FontSize,
|
||||
Height = (int)(token.LineHeight * token.FontSize),
|
||||
Display = "inline-block",
|
||||
MarginInline = -token.MarginXXS,
|
||||
["&:hover"] = new CSSObject()
|
||||
|
@ -88,7 +88,7 @@ namespace AntDesign
|
|||
[$"{componentCls}-overlay-link"] = new CSSObject()
|
||||
{
|
||||
BorderRadius = token.BorderRadiusSM,
|
||||
Height = (int)token.LineHeight * token.FontSize,
|
||||
Height = (int)(token.LineHeight * token.FontSize),
|
||||
Display = "inline-block",
|
||||
Padding = @$"0 {token.PaddingXXS}px",
|
||||
MarginInline = -token.MarginXXS,
|
||||
|
@ -124,11 +124,20 @@ namespace AntDesign
|
|||
|
||||
protected override UseComponentStyleResult UseComponentStyle()
|
||||
{
|
||||
return GenComponentStyleHook("Breadcrumb", (token) =>
|
||||
{
|
||||
var breadcrumbToken = MergeToken(
|
||||
token,
|
||||
new BreadcrumbToken()
|
||||
return GenComponentStyleHook(
|
||||
"Breadcrumb",
|
||||
(token) =>
|
||||
{
|
||||
var breadcrumbToken = MergeToken(
|
||||
token,
|
||||
new BreadcrumbToken()
|
||||
{
|
||||
});
|
||||
return new CSSInterpolation[] { GenBreadcrumbStyle(breadcrumbToken) };
|
||||
},
|
||||
(token) =>
|
||||
{
|
||||
return new BreadcrumbToken()
|
||||
{
|
||||
ItemColor = token.ColorTextDescription,
|
||||
LastItemColor = token.ColorText,
|
||||
|
@ -137,9 +146,10 @@ namespace AntDesign
|
|||
LinkHoverColor = token.ColorText,
|
||||
SeparatorColor = token.ColorTextDescription,
|
||||
SeparatorMargin = token.MarginXS,
|
||||
});
|
||||
return new CSSInterpolation[] { GenBreadcrumbStyle(breadcrumbToken) };
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -6,20 +6,66 @@ using static AntDesign.StyleUtil;
|
|||
|
||||
namespace AntDesign
|
||||
{
|
||||
public class ComponentToken
|
||||
public partial class ButtonToken
|
||||
{
|
||||
public int FontWeight { get; set; }
|
||||
|
||||
public string DefaultShadow { get; set; }
|
||||
|
||||
public string PrimaryShadow { get; set; }
|
||||
|
||||
public string DangerShadow { get; set; }
|
||||
|
||||
public string PrimaryColor { get; set; }
|
||||
|
||||
public string DefaultColor { get; set; }
|
||||
|
||||
public string DefaultBg { get; set; }
|
||||
|
||||
public string DefaultBorderColor { get; set; }
|
||||
|
||||
public string DangerColor { get; set; }
|
||||
|
||||
public string BorderColorDisabled { get; set; }
|
||||
|
||||
public string DefaultGhostColor { get; set; }
|
||||
|
||||
public string GhostBg { get; set; }
|
||||
|
||||
public string DefaultGhostBorderColor { get; set; }
|
||||
|
||||
public int PaddingInline { get; set; }
|
||||
|
||||
public int PaddingInlineLG { get; set; }
|
||||
|
||||
public int PaddingInlineSM { get; set; }
|
||||
|
||||
public int OnlyIconSize { get; set; }
|
||||
|
||||
public int OnlyIconSizeLG { get; set; }
|
||||
|
||||
public int OnlyIconSizeSM { get; set; }
|
||||
|
||||
public string GroupBorderColor { get; set; }
|
||||
|
||||
public string LinkHoverBg { get; set; }
|
||||
|
||||
public string TextHoverBg { get; set; }
|
||||
|
||||
public int ContentFontSize { get; set; }
|
||||
|
||||
public int ContentFontSizeLG { get; set; }
|
||||
|
||||
public int ContentFontSizeSM { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public partial class ButtonToken : TokenWithCommonCls
|
||||
{
|
||||
public string ColorOutlineDefault { get; set; }
|
||||
|
||||
public int ButtonPaddingHorizontal { get; set; }
|
||||
|
||||
public int ButtonIconOnlyFontSize { get; set; }
|
||||
|
||||
public int ButtonFontWeight { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public partial class Button
|
||||
|
@ -28,7 +74,7 @@ namespace AntDesign
|
|||
{
|
||||
var componentCls = token.ComponentCls;
|
||||
var iconCls = token.IconCls;
|
||||
var buttonFontWeight = token.ButtonFontWeight;
|
||||
var fontWeight = token.FontWeight;
|
||||
return new CSSObject()
|
||||
{
|
||||
[componentCls] = new CSSObject()
|
||||
|
@ -36,7 +82,7 @@ namespace AntDesign
|
|||
Outline = "none",
|
||||
Position = "relative",
|
||||
Display = "inline-block",
|
||||
FontWeight = buttonFontWeight,
|
||||
FontWeight = fontWeight,
|
||||
WhiteSpace = "nowrap",
|
||||
TextAlign = "center",
|
||||
BackgroundImage = "none",
|
||||
|
@ -48,6 +94,10 @@ namespace AntDesign
|
|||
TouchAction = "manipulation",
|
||||
LineHeight = token.LineHeight,
|
||||
Color = token.ColorText,
|
||||
["&:disabled > *"] = new CSSObject()
|
||||
{
|
||||
PointerEvents = "none",
|
||||
},
|
||||
["> span"] = new CSSObject()
|
||||
{
|
||||
Display = "inline-block",
|
||||
|
@ -56,6 +106,10 @@ namespace AntDesign
|
|||
{
|
||||
LineHeight = 0,
|
||||
},
|
||||
[$"> {iconCls} + span, > span + {iconCls}"] = new CSSObject()
|
||||
{
|
||||
MarginInlineStart = token.MarginXS,
|
||||
},
|
||||
[$"&:not({componentCls}-icon-only) > {componentCls}-icon"] = new CSSObject()
|
||||
{
|
||||
[$"&{componentCls}-loading-icon, &:not(:last-child)"] = new CSSObject()
|
||||
|
@ -63,10 +117,6 @@ namespace AntDesign
|
|||
MarginInlineEnd = token.MarginXS,
|
||||
},
|
||||
},
|
||||
[$"> span + {iconCls}"] = new CSSObject()
|
||||
{
|
||||
MarginInlineStart = token.MarginXS,
|
||||
},
|
||||
["> a"] = new CSSObject()
|
||||
{
|
||||
Color = "currentColor",
|
||||
|
@ -75,6 +125,15 @@ namespace AntDesign
|
|||
{
|
||||
["..."] = GenFocusStyle(token)
|
||||
},
|
||||
[$"&{componentCls}-two-chinese-chars::first-letter"] = new CSSObject()
|
||||
{
|
||||
LetterSpacing = "0.34em",
|
||||
},
|
||||
[$"&{componentCls}-two-chinese-chars > *:not({iconCls})"] = new CSSObject()
|
||||
{
|
||||
MarginInlineEnd = "-0.34em",
|
||||
LetterSpacing = "0.34em",
|
||||
},
|
||||
[$"&-icon-only{componentCls}-compact-item"] = new CSSObject()
|
||||
{
|
||||
Flex = "none",
|
||||
|
@ -122,11 +181,11 @@ namespace AntDesign
|
|||
};
|
||||
}
|
||||
|
||||
public CSSObject GenHoverActiveButtonStyle(CSSObject hoverStyle = default, CSSObject activeStyle = default)
|
||||
public CSSObject GenHoverActiveButtonStyle(string btnCls, CSSObject hoverStyle = default, CSSObject activeStyle = default)
|
||||
{
|
||||
return new CSSObject()
|
||||
{
|
||||
["&:not(:disabled)"] = new CSSObject()
|
||||
[$"&:not(:disabled):not({btnCls}-disabled)"] = new CSSObject()
|
||||
{
|
||||
["&:hover"] = hoverStyle,
|
||||
["&:active"] = activeStyle,
|
||||
|
@ -160,32 +219,33 @@ namespace AntDesign
|
|||
return new CSSObject()
|
||||
{
|
||||
Cursor = "not-allowed",
|
||||
BorderColor = token.ColorBorder,
|
||||
BorderColor = token.BorderColorDisabled,
|
||||
Color = token.ColorTextDisabled,
|
||||
BackgroundColor = token.ColorBgContainerDisabled,
|
||||
BoxShadow = "none",
|
||||
};
|
||||
}
|
||||
|
||||
public CSSObject GenGhostButtonStyle(string btnCls, string textColor, string borderColor, string textColorDisabled, string borderColorDisabled, CSSObject hoverStyle = default, CSSObject activeStyle = default)
|
||||
public CSSObject GenGhostButtonStyle(string btnCls, string background, string textColor, string borderColor, string textColorDisabled, string borderColorDisabled, CSSObject hoverStyle = default, CSSObject activeStyle = default)
|
||||
{
|
||||
return new CSSObject()
|
||||
{
|
||||
[$"&{btnCls}-background-ghost"] = new CSSObject()
|
||||
{
|
||||
Color = textColor,
|
||||
BackgroundColor = "transparent",
|
||||
BackgroundColor = background,
|
||||
BorderColor = borderColor,
|
||||
BoxShadow = "none",
|
||||
["..."] = GenHoverActiveButtonStyle(
|
||||
btnCls,
|
||||
new CSSObject()
|
||||
{
|
||||
BackgroundColor = "transparent",
|
||||
BackgroundColor = background,
|
||||
["..."] = hoverStyle,
|
||||
},
|
||||
new CSSObject()
|
||||
{
|
||||
BackgroundColor = "transparent",
|
||||
BackgroundColor = background,
|
||||
["..."] = activeStyle,
|
||||
}),
|
||||
["&:disabled"] = new CSSObject()
|
||||
|
@ -202,7 +262,7 @@ namespace AntDesign
|
|||
{
|
||||
return new CSSObject()
|
||||
{
|
||||
["&:disabled"] = new CSSObject()
|
||||
[$"&:disabled, &{token.ComponentCls}-disabled"] = new CSSObject()
|
||||
{
|
||||
["..."] = GenDisabledStyle(token)
|
||||
},
|
||||
|
@ -221,7 +281,7 @@ namespace AntDesign
|
|||
{
|
||||
return new CSSObject()
|
||||
{
|
||||
["&:disabled"] = new CSSObject()
|
||||
[$"&:disabled, &{token.ComponentCls}-disabled"] = new CSSObject()
|
||||
{
|
||||
Cursor = "not-allowed",
|
||||
Color = token.ColorTextDisabled,
|
||||
|
@ -234,10 +294,12 @@ namespace AntDesign
|
|||
return new CSSObject()
|
||||
{
|
||||
["..."] = GenSolidButtonStyle(token),
|
||||
BackgroundColor = token.ColorBgContainer,
|
||||
BorderColor = token.ColorBorder,
|
||||
BoxShadow = @$"0 {token.ControlOutlineWidth}px 0 {token.ControlTmpOutline}",
|
||||
BackgroundColor = token.DefaultBg,
|
||||
BorderColor = token.DefaultBorderColor,
|
||||
Color = token.DefaultColor,
|
||||
BoxShadow = token.DefaultShadow,
|
||||
["..."] = GenHoverActiveButtonStyle(
|
||||
token.ComponentCls,
|
||||
new CSSObject()
|
||||
{
|
||||
Color = token.ColorPrimaryHover,
|
||||
|
@ -248,12 +310,13 @@ namespace AntDesign
|
|||
Color = token.ColorPrimaryActive,
|
||||
BorderColor = token.ColorPrimaryActive,
|
||||
}),
|
||||
["..."] = GenGhostButtonStyle(token.ComponentCls, token.ColorBgContainer, token.ColorBgContainer, token.ColorTextDisabled, token.ColorBorder),
|
||||
["..."] = GenGhostButtonStyle(token.ComponentCls, token.GhostBg, token.DefaultGhostColor, token.DefaultGhostBorderColor, token.ColorTextDisabled, token.ColorBorder),
|
||||
[$"&{token.ComponentCls}-dangerous"] = new CSSObject()
|
||||
{
|
||||
Color = token.ColorError,
|
||||
BorderColor = token.ColorError,
|
||||
["..."] = GenHoverActiveButtonStyle(
|
||||
token.ComponentCls,
|
||||
new CSSObject()
|
||||
{
|
||||
Color = token.ColorErrorHover,
|
||||
|
@ -264,7 +327,7 @@ namespace AntDesign
|
|||
Color = token.ColorErrorActive,
|
||||
BorderColor = token.ColorErrorActive,
|
||||
}),
|
||||
["..."] = GenGhostButtonStyle(token.ComponentCls, token.ColorError, token.ColorError, token.ColorTextDisabled, token.ColorBorder),
|
||||
["..."] = GenGhostButtonStyle(token.ComponentCls, token.GhostBg, token.ColorError, token.ColorError, token.ColorTextDisabled, token.ColorBorder),
|
||||
["..."] = GenSolidDisabledButtonStyle(token)
|
||||
},
|
||||
};
|
||||
|
@ -275,10 +338,11 @@ namespace AntDesign
|
|||
return new CSSObject()
|
||||
{
|
||||
["..."] = GenSolidButtonStyle(token),
|
||||
Color = token.ColorTextLightSolid,
|
||||
Color = token.PrimaryColor,
|
||||
BackgroundColor = token.ColorPrimary,
|
||||
BoxShadow = @$"0 {token.ControlOutlineWidth}px 0 {token.ControlOutline}",
|
||||
BoxShadow = token.PrimaryShadow,
|
||||
["..."] = GenHoverActiveButtonStyle(
|
||||
token.ComponentCls,
|
||||
new CSSObject()
|
||||
{
|
||||
Color = token.ColorTextLightSolid,
|
||||
|
@ -291,6 +355,7 @@ namespace AntDesign
|
|||
}),
|
||||
["..."] = GenGhostButtonStyle(
|
||||
token.ComponentCls,
|
||||
token.GhostBg,
|
||||
token.ColorPrimary,
|
||||
token.ColorPrimary,
|
||||
token.ColorTextDisabled,
|
||||
|
@ -308,8 +373,10 @@ namespace AntDesign
|
|||
[$"&{token.ComponentCls}-dangerous"] = new CSSObject()
|
||||
{
|
||||
BackgroundColor = token.ColorError,
|
||||
BoxShadow = @$"0 {token.ControlOutlineWidth}px 0 {token.ColorErrorOutline}",
|
||||
BoxShadow = token.DangerShadow,
|
||||
Color = token.DangerColor,
|
||||
["..."] = GenHoverActiveButtonStyle(
|
||||
token.ComponentCls,
|
||||
new CSSObject()
|
||||
{
|
||||
BackgroundColor = token.ColorErrorHover,
|
||||
|
@ -320,6 +387,7 @@ namespace AntDesign
|
|||
}),
|
||||
["..."] = GenGhostButtonStyle(
|
||||
token.ComponentCls,
|
||||
token.GhostBg,
|
||||
token.ColorError,
|
||||
token.ColorError,
|
||||
token.ColorTextDisabled,
|
||||
|
@ -354,9 +422,11 @@ namespace AntDesign
|
|||
{
|
||||
Color = token.ColorLink,
|
||||
["..."] = GenHoverActiveButtonStyle(
|
||||
token.ComponentCls,
|
||||
new CSSObject()
|
||||
{
|
||||
Color = token.ColorLinkHover,
|
||||
BackgroundColor = token.LinkHoverBg,
|
||||
},
|
||||
new CSSObject()
|
||||
{
|
||||
|
@ -367,6 +437,7 @@ namespace AntDesign
|
|||
{
|
||||
Color = token.ColorError,
|
||||
["..."] = GenHoverActiveButtonStyle(
|
||||
token.ComponentCls,
|
||||
new CSSObject()
|
||||
{
|
||||
Color = token.ColorErrorHover,
|
||||
|
@ -385,10 +456,11 @@ namespace AntDesign
|
|||
return new CSSObject()
|
||||
{
|
||||
["..."] = GenHoverActiveButtonStyle(
|
||||
token.ComponentCls,
|
||||
new CSSObject()
|
||||
{
|
||||
Color = token.ColorText,
|
||||
BackgroundColor = token.ColorBgTextHover,
|
||||
BackgroundColor = token.TextHoverBg,
|
||||
},
|
||||
new CSSObject()
|
||||
{
|
||||
|
@ -401,6 +473,7 @@ namespace AntDesign
|
|||
Color = token.ColorError,
|
||||
["..."] = GenPureDisabledButtonStyle(token),
|
||||
["..."] = GenHoverActiveButtonStyle(
|
||||
token.ComponentCls,
|
||||
new CSSObject()
|
||||
{
|
||||
Color = token.ColorErrorHover,
|
||||
|
@ -415,18 +488,6 @@ namespace AntDesign
|
|||
};
|
||||
}
|
||||
|
||||
public CSSObject GenDisabledButtonStyle(ButtonToken token)
|
||||
{
|
||||
return new CSSObject()
|
||||
{
|
||||
["..."] = GenDisabledStyle(token),
|
||||
[$"&{token.ComponentCls}:hover"] = new CSSObject()
|
||||
{
|
||||
["..."] = GenDisabledStyle(token)
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public CSSObject GenTypeButtonStyle(ButtonToken token)
|
||||
{
|
||||
var componentCls = token.ComponentCls;
|
||||
|
@ -437,7 +498,7 @@ namespace AntDesign
|
|||
[$"{componentCls}-dashed"] = GenDashedButtonStyle(token),
|
||||
[$"{componentCls}-link"] = GenLinkButtonStyle(token),
|
||||
[$"{componentCls}-text"] = GenTextButtonStyle(token),
|
||||
[$"{componentCls}-disabled"] = GenDisabledButtonStyle(token)
|
||||
[$"{componentCls}-ghost"] = GenGhostButtonStyle(token.ComponentCls, token.GhostBg, token.ColorBgContainer, token.ColorBgContainer, token.ColorTextDisabled, token.ColorBorder)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -452,7 +513,6 @@ namespace AntDesign
|
|||
var buttonPaddingHorizontal = token.ButtonPaddingHorizontal;
|
||||
var iconCls = token.IconCls;
|
||||
var paddingVertical = Math.Max(0, (controlHeight - fontSize * lineHeight) / 2 - lineWidth);
|
||||
var paddingHorizontal = buttonPaddingHorizontal - lineWidth;
|
||||
var iconOnlyCls = @$"{componentCls}-icon-only";
|
||||
return new CSSInterpolation[]
|
||||
{
|
||||
|
@ -462,7 +522,7 @@ namespace AntDesign
|
|||
{
|
||||
FontSize = fontSize,
|
||||
Height = controlHeight,
|
||||
Padding = @$"{paddingVertical}px {paddingHorizontal}px",
|
||||
Padding = @$"{paddingVertical}px {buttonPaddingHorizontal}px",
|
||||
BorderRadius = borderRadius,
|
||||
[$"&{iconOnlyCls}"] = new CSSObject()
|
||||
{
|
||||
|
@ -502,7 +562,13 @@ namespace AntDesign
|
|||
|
||||
public CSSInterpolation GenSizeBaseButtonStyle(ButtonToken token)
|
||||
{
|
||||
return GenSizeButtonStyle(token);
|
||||
return GenSizeButtonStyle(
|
||||
MergeToken(
|
||||
token,
|
||||
new ButtonToken()
|
||||
{
|
||||
FontSize = token.ContentFontSize,
|
||||
}));
|
||||
}
|
||||
|
||||
public CSSInterpolation GenSizeSmallButtonStyle(ButtonToken token)
|
||||
|
@ -512,10 +578,11 @@ namespace AntDesign
|
|||
new ButtonToken()
|
||||
{
|
||||
ControlHeight = token.ControlHeightSM,
|
||||
FontSize = token.ContentFontSizeSM,
|
||||
Padding = token.PaddingXS,
|
||||
ButtonPaddingHorizontal = 8,
|
||||
ButtonPaddingHorizontal = token.PaddingInlineSM,
|
||||
BorderRadius = token.BorderRadiusSM,
|
||||
ButtonIconOnlyFontSize = token.FontSizeLG - 2,
|
||||
ButtonIconOnlyFontSize = token.OnlyIconSizeSM,
|
||||
});
|
||||
return GenSizeButtonStyle(smallToken, $"{token.ComponentCls}-sm");
|
||||
}
|
||||
|
@ -527,9 +594,10 @@ namespace AntDesign
|
|||
new ButtonToken()
|
||||
{
|
||||
ControlHeight = token.ControlHeightLG,
|
||||
FontSize = token.FontSizeLG,
|
||||
FontSize = token.ContentFontSizeLG,
|
||||
ButtonPaddingHorizontal = token.PaddingInlineLG,
|
||||
BorderRadius = token.BorderRadiusLG,
|
||||
ButtonIconOnlyFontSize = token.FontSizeLG + 2,
|
||||
ButtonIconOnlyFontSize = token.OnlyIconSizeLG,
|
||||
});
|
||||
return GenSizeButtonStyle(largeToken, $"{token.ComponentCls}-lg");
|
||||
}
|
||||
|
@ -549,34 +617,72 @@ namespace AntDesign
|
|||
};
|
||||
}
|
||||
|
||||
public ButtonToken PrepareToken(ButtonToken token)
|
||||
{
|
||||
var paddingInline = token.PaddingInline;
|
||||
var onlyIconSize = token.OnlyIconSize;
|
||||
var buttonToken = MergeToken(
|
||||
token,
|
||||
new ButtonToken()
|
||||
{
|
||||
ButtonPaddingHorizontal = paddingInline,
|
||||
ButtonIconOnlyFontSize = onlyIconSize,
|
||||
});
|
||||
return buttonToken;
|
||||
}
|
||||
|
||||
public ButtonToken PrepareComponentToken(GlobalToken token)
|
||||
{
|
||||
return new ButtonToken()
|
||||
{
|
||||
FontWeight = 400,
|
||||
DefaultShadow = @$"0 {token.ControlOutlineWidth}px 0 {token.ControlTmpOutline}",
|
||||
PrimaryShadow = @$"0 {token.ControlOutlineWidth}px 0 {token.ControlOutline}",
|
||||
DangerShadow = @$"0 {token.ControlOutlineWidth}px 0 {token.ColorErrorOutline}",
|
||||
PrimaryColor = token.ColorTextLightSolid,
|
||||
DangerColor = token.ColorTextLightSolid,
|
||||
BorderColorDisabled = token.ColorBorder,
|
||||
DefaultGhostColor = token.ColorBgContainer,
|
||||
GhostBg = "transparent",
|
||||
DefaultGhostBorderColor = token.ColorBgContainer,
|
||||
PaddingInline = token.PaddingContentHorizontal - token.LineWidth,
|
||||
PaddingInlineLG = token.PaddingContentHorizontal - token.LineWidth,
|
||||
PaddingInlineSM = 8 - token.LineWidth,
|
||||
OnlyIconSize = token.FontSizeLG,
|
||||
OnlyIconSizeSM = token.FontSizeLG - 2,
|
||||
OnlyIconSizeLG = token.FontSizeLG + 2,
|
||||
GroupBorderColor = token.ColorPrimaryHover,
|
||||
LinkHoverBg = "transparent",
|
||||
TextHoverBg = token.ColorBgTextHover,
|
||||
DefaultColor = token.ColorText,
|
||||
DefaultBg = token.ColorBgContainer,
|
||||
DefaultBorderColor = token.ColorBorder,
|
||||
// DefaultBorderColorDisabled = token.ColorBorder,
|
||||
ContentFontSize = token.FontSize,
|
||||
ContentFontSizeSM = token.FontSize,
|
||||
ContentFontSizeLG = token.FontSizeLG,
|
||||
};
|
||||
}
|
||||
|
||||
protected override UseComponentStyleResult UseComponentStyle()
|
||||
{
|
||||
return GenComponentStyleHook("Button", (token) =>
|
||||
{
|
||||
var controlTmpOutline = token.ControlTmpOutline;
|
||||
var paddingContentHorizontal = token.PaddingContentHorizontal;
|
||||
var buttonToken = MergeToken(
|
||||
token,
|
||||
new ButtonToken()
|
||||
{
|
||||
ColorOutlineDefault = controlTmpOutline,
|
||||
ButtonPaddingHorizontal = paddingContentHorizontal,
|
||||
ButtonIconOnlyFontSize = token.FontSizeLG,
|
||||
ButtonFontWeight = 400,
|
||||
});
|
||||
return new CSSInterpolation[]
|
||||
return GenComponentStyleHook(
|
||||
"Button",
|
||||
(token) =>
|
||||
{
|
||||
GenSharedButtonStyle(buttonToken),
|
||||
GenSizeSmallButtonStyle(buttonToken),
|
||||
GenSizeBaseButtonStyle(buttonToken),
|
||||
GenSizeLargeButtonStyle(buttonToken),
|
||||
GenBlockButtonStyle(buttonToken),
|
||||
GenTypeButtonStyle(buttonToken),
|
||||
GenGroupStyle(buttonToken),
|
||||
GenCompactItemStyle(token),
|
||||
GenCompactItemVerticalStyle(token)
|
||||
};
|
||||
});
|
||||
var buttonToken = PrepareToken(token);
|
||||
return new CSSInterpolation[]
|
||||
{
|
||||
GenSharedButtonStyle(buttonToken),
|
||||
GenSizeSmallButtonStyle(buttonToken),
|
||||
GenSizeBaseButtonStyle(buttonToken),
|
||||
GenSizeLargeButtonStyle(buttonToken),
|
||||
GenBlockButtonStyle(buttonToken),
|
||||
GenTypeButtonStyle(buttonToken),
|
||||
GenGroupStyle(buttonToken)
|
||||
};
|
||||
},
|
||||
PrepareComponentToken);
|
||||
}
|
||||
|
||||
public CSSObject GenButtonBorderStyle(string buttonTypeCls, string borderColor)
|
||||
|
@ -614,7 +720,7 @@ namespace AntDesign
|
|||
var componentCls = token.ComponentCls;
|
||||
var fontSize = token.FontSize;
|
||||
var lineWidth = token.LineWidth;
|
||||
var colorPrimaryHover = token.ColorPrimaryHover;
|
||||
var groupBorderColor = token.GroupBorderColor;
|
||||
var colorErrorHover = token.ColorErrorHover;
|
||||
return new CSSObject()
|
||||
{
|
||||
|
@ -662,11 +768,12 @@ namespace AntDesign
|
|||
FontSize = fontSize,
|
||||
},
|
||||
},
|
||||
GenButtonBorderStyle($"{componentCls}-primary", colorPrimaryHover),
|
||||
GenButtonBorderStyle($"{componentCls}-primary", groupBorderColor),
|
||||
GenButtonBorderStyle($"{componentCls}-danger", colorErrorHover)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -133,170 +133,8 @@ export const data0: Component[] = [
|
|||
|
||||
// 未完成测试的组件
|
||||
export const data1: Component[] = [
|
||||
{
|
||||
name: 'Avatar',
|
||||
src: ['components/avatar/style/index.ts'],
|
||||
dist: 'components/avatar/Style.cs',
|
||||
csOptions: {
|
||||
...defaultOptions,
|
||||
defaultClass: 'Avatar',
|
||||
typeMap: [
|
||||
{ from: 'Unknown1', to: 'CSSObject', ranges: [[1, 9]] },
|
||||
{ from: 'Unknown1', to: 'AvatarToken', includes: [2] },
|
||||
{ from: 'Unknown2', to: 'CSSObject', ranges: [[1, 8]] },
|
||||
{ from: 'Unknown2', to: 'AvatarToken', includes: [2] },
|
||||
{ from: 'Unknown3', to: 'CSSInterpolation[]', includes: [1, 4] },
|
||||
{ from: 'Unknown3', to: 'TokenWithCommonCls', includes: [2] },
|
||||
{ from: 'Unknown3', to: 'AvatarToken', includes: [3] },
|
||||
],
|
||||
transforms: [
|
||||
{ source: 'class ComponentToken', target: 'partial class AvatarToken : TokenWithCommonCls' },
|
||||
{ source: 'class AvatarToken', target: 'partial class AvatarToken' },
|
||||
{ source: 'class Avatar', target: 'partial class Avatar' },
|
||||
{ source: 'public CSSInterpolation[] GenComponentStyleHook', target: 'public RenderFragment UseStyle' },
|
||||
{ source: 'AvatarSizeStyle', target: 'avatarSizeStyle' },
|
||||
{ source: 'Math.Round(', target: '(int)Math.Round((double)' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'BackTop',
|
||||
src: ['components/back-top/style/index.ts'],
|
||||
dist: 'components/back-top/Style.cs',
|
||||
csOptions: {
|
||||
...defaultOptions,
|
||||
defaultClass: 'BackTop',
|
||||
typeMap: [
|
||||
{ from: 'Unknown1', to: 'BackTopToken', includes: [1] },
|
||||
{ from: 'Unknown2', to: 'BackTopToken', includes: [1] },
|
||||
{ from: 'Unknown3', to: 'CSSInterpolation[]', includes: [1, 4] },
|
||||
{ from: 'Unknown3', to: 'TokenWithCommonCls', includes: [2] },
|
||||
{ from: 'Unknown3', to: 'BackTopToken', includes: [3] },
|
||||
{ from: 'Unknown4', to: 'BackTopToken', includes: [1, 3] },
|
||||
{ from: 'Unknown4', to: 'TokenWithCommonCls', includes: [2] },
|
||||
],
|
||||
transforms: [
|
||||
{ source: 'class ComponentToken', target: 'partial class BackTopToken : TokenWithCommonCls' },
|
||||
{ source: 'class BackTopToken', target: 'partial class BackTopToken' },
|
||||
{ source: 'class BackTop', target: 'partial class BackTop' },
|
||||
{ source: 'public CSSInterpolation[] GenComponentStyleHook(TokenWithCommonCls token)', target: 'public RenderFragment UseStyle(TokenWithCommonCls token)' },
|
||||
{ source: 'controlHeightLG * 1.25', target: '(int)(controlHeightLG * 1.25)' },
|
||||
{ source: 'controlHeightLG * 2.5', target: '(int)(controlHeightLG * 2.5)' },
|
||||
{ source: 'controlHeightLG * 1.5', target: '(int)(controlHeightLG * 1.5)' },
|
||||
{ source: 'controlHeightLG * 0.5', target: '(int)(controlHeightLG * 0.5)' },
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Badge',
|
||||
src: ['components/badge/style/index.ts'],
|
||||
dist: 'components/badge/Style.cs',
|
||||
csOptions: {
|
||||
...defaultOptions,
|
||||
usings: defaultOptions.usings.concat(['using Keyframes = CssInCs.Keyframe;']),
|
||||
defaultClass: 'Badge',
|
||||
typeMap: [
|
||||
{ from: 'Keyframes', to: 'CSSObject' },
|
||||
{ from: 'Unknown7', to: 'CSSObject', ranges: [[1, 4]] },
|
||||
{ from: 'Unknown8', to: 'CSSInterpolation[]', includes: [1, 4] },
|
||||
{ from: 'Unknown8', to: 'GlobalToken', includes: [2] },
|
||||
{ from: 'Unknown8', to: 'BadgeToken', includes: [3] },
|
||||
],
|
||||
transforms: [
|
||||
{ source: 'class BadgeToken', target: 'partial class BadgeToken : TokenWithCommonCls' },
|
||||
{ source: 'class Badge', target: 'partial class Badge' },
|
||||
{ source: 'public CSSInterpolation[] GenComponentStyleHook', target: 'protected override CSSInterpolation[] UseStyle' },
|
||||
{ source: 'Math.Round(fontSize * lineHeight)', target: '(int)Math.Round((double)fontSize * lineHeight)' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Breadcrumb',
|
||||
src: ['components/breadcrumb/style/index.ts'],
|
||||
dist: 'components/breadcrumb/Style.cs',
|
||||
csOptions: {
|
||||
...defaultOptions,
|
||||
defaultClass: 'Breadcrumb',
|
||||
typeMap: [
|
||||
{ from: 'Unknown1', to: 'CSSObject', ranges: [[1, 19]] },
|
||||
{ from: 'Unknown1', to: 'BreadcrumbToken', includes: [2] },
|
||||
{ from: 'Unknown2', to: 'CSSInterpolation[]', includes: [1, 4] },
|
||||
{ from: 'Unknown2', to: 'GlobalToken', includes: [2] },
|
||||
{ from: 'Unknown2', to: 'BreadcrumbToken', includes: [3] }
|
||||
],
|
||||
transforms: [
|
||||
{ source: 'class BreadcrumbToken', target: 'partial class BreadcrumbToken : TokenWithCommonCls' },
|
||||
{ source: 'class Breadcrumb', target: 'partial class Breadcrumb' },
|
||||
{ source: 'public CSSInterpolation[] GenComponentStyleHook', target: 'protected override CSSInterpolation[] UseStyle' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Button',
|
||||
src: [
|
||||
'components/button/style/index.ts',
|
||||
'components/button/style/group.ts'
|
||||
],
|
||||
dist: 'components/button/Style.cs',
|
||||
csOptions: {
|
||||
...defaultOptions,
|
||||
defaultClass: 'Button',
|
||||
typeMap: [
|
||||
{ from: 'Unknown1', to: 'ButtonToken', includes: [1] },
|
||||
{ from: 'Unknown3', to: 'CSSObject', includes: [1, 3] },
|
||||
{ from: 'Unknown3', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown4', to: 'CSSObject', includes: [1, 3] },
|
||||
{ from: 'Unknown4', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown5', to: 'CSSObject', includes: [1, 3] },
|
||||
{ from: 'Unknown5', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown6', to: 'CSSObject', includes: [1, 2] },
|
||||
{ from: 'Unknown7', to: 'CSSObject', ranges: [[1, 4]] },
|
||||
{ from: 'Unknown7', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown8', to: 'CSSObject', includes: [1, 3] },
|
||||
{ from: 'Unknown8', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown9', to: 'CSSObject', ranges: [[1, 4]] },
|
||||
{ from: 'Unknown9', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown10', to: 'CSSObject', ranges: [[1, 8]] },
|
||||
{ from: 'Unknown10', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown11', to: 'CSSObject', ranges: [[1, 12]] },
|
||||
{ from: 'Unknown11', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown12', to: 'CSSObject', includes: [1, 3] },
|
||||
{ from: 'Unknown12', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown13', to: 'CSSObject', ranges: [[1, 8]] },
|
||||
{ from: 'Unknown13', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown14', to: 'CSSObject', ranges: [[1, 8]] },
|
||||
{ from: 'Unknown14', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown15', to: 'CSSObject', ranges: [[1, 4]] },
|
||||
{ from: 'Unknown15', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown16', to: 'CSSObject', ranges: [[1, 3]] },
|
||||
{ from: 'Unknown16', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'CSSInterpolation', to: 'CSSInterpolation[]' },
|
||||
{ from: 'Unknown17', to: 'CSSObject', ranges: [[1, 9]] },
|
||||
{ from: 'Unknown18', to: 'CSSInterpolation', includes: [1] },
|
||||
{ from: 'Unknown18', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown19', to: 'CSSInterpolation', includes: [1] },
|
||||
{ from: 'Unknown19', to: 'ButtonToken', includes: [2, 3] },
|
||||
{ from: 'Unknown20', to: 'CSSInterpolation', includes: [1] },
|
||||
{ from: 'Unknown20', to: 'ButtonToken', includes: [2, 3] },
|
||||
{ from: 'Unknown21', to: 'CSSObject', ranges: [[1, 5]] },
|
||||
{ from: 'Unknown21', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown22', to: 'CSSInterpolation', includes: [1] },
|
||||
{ from: 'Unknown22', to: 'TokenWithCommonCls', includes: [2] },
|
||||
{ from: 'Unknown22', to: 'ButtonToken', includes: [3] },
|
||||
{ from: 'Unknown22', to: 'CSSInterpolation[]', includes: [4] },
|
||||
{ from: 'Unknown23', to: 'CSSObject', ranges: [[1, 9]] },
|
||||
{ from: 'Unknown24', to: 'CSSObject', includes: [1, 3], ranges: [[5, 14]] },
|
||||
{ from: 'Unknown24', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown24', to: 'CSSInterpolation[]', includes: [4] },
|
||||
],
|
||||
transforms: [
|
||||
{ source: 'class ButtonToken', target: 'partial class ButtonToken : TokenWithCommonCls' },
|
||||
{ source: 'class Button', target: 'partial class Button' },
|
||||
{ source: 'public CSSObject[] GenComponentStyleHook', target: 'protected override CSSInterpolation[] UseStyle' },
|
||||
{ source: 'CSSObject hoverStyle, CSSObject activeStyle', target: 'CSSObject hoverStyle = default, CSSObject activeStyle = default' }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
name: 'Calendar',
|
||||
src: ['components/calendar/style/index.ts'],
|
||||
|
@ -1413,8 +1251,159 @@ export const data2: Component[] = [
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'BackTop',
|
||||
src: ['components/back-top/style/index.ts'],
|
||||
dist: 'components/back-top/Style.cs',
|
||||
csOptions: {
|
||||
...defaultOptions,
|
||||
defaultClass: 'BackTop',
|
||||
typeMap: [
|
||||
{ from: 'Unknown1', to: 'BackTopToken', includes: [1] },
|
||||
{ from: 'Unknown2', to: 'BackTopToken', includes: [1] },
|
||||
{ from: 'Unknown3', to: 'BackTopToken', includes: [1] },
|
||||
{ from: 'Unknown3', to: 'CSSInterpolation[]', includes: [2] },
|
||||
{ from: 'Unknown3', to: 'BackTopToken', includes: [3] },
|
||||
],
|
||||
transforms: [
|
||||
{ source: 'class ComponentToken', target: 'partial class BackTopToken : TokenWithCommonCls' },
|
||||
{ source: 'class BackTopToken', target: 'partial class BackTopToken' },
|
||||
{ source: 'class BackTop', target: 'partial class BackTop' },
|
||||
{ source: 'controlHeightLG * 1.25', target: '(int)(controlHeightLG * 1.25)' },
|
||||
{ source: 'controlHeightLG * 2.5', target: '(int)(controlHeightLG * 2.5)' },
|
||||
{ source: 'controlHeightLG * 1.5', target: '(int)(controlHeightLG * 1.5)' },
|
||||
{ source: 'controlHeightLG * 0.5', target: '(int)(controlHeightLG * 0.5)' },
|
||||
{ source: 'public UseComponentStyleResult ExportDefault', target: 'protected override UseComponentStyleResult UseComponentStyle' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Badge',
|
||||
src: ['components/badge/style/index.ts'],
|
||||
dist: 'components/badge/Style.cs',
|
||||
csOptions: {
|
||||
...defaultOptions,
|
||||
usings: defaultOptions.usings.concat(['using Keyframes = CssInCSharp.Keyframe;']),
|
||||
defaultClass: 'Badge',
|
||||
typeMap: [
|
||||
{ from: 'Keyframes', to: 'CSSObject' },
|
||||
{ from: 'Unknown7', to: 'CSSObject', includes: [1, 2, 3] },
|
||||
{ from: 'Unknown8', to: 'BadgeToken', includes: [1, 2, 3] },
|
||||
{ from: 'Unknown9', to: 'BadgeToken', includes: [1, 2] },
|
||||
{ from: 'Unknown10', to: 'CSSInterpolation[]', includes: [1] },
|
||||
],
|
||||
transforms: [
|
||||
{ source: 'antStatusProcessing', target: '_antStatusProcessing' },
|
||||
{ source: 'antZoomBadgeIn', target: '_antZoomBadgeIn' },
|
||||
{ source: 'antZoomBadgeOut', target: '_antZoomBadgeOut' },
|
||||
{ source: 'antNoWrapperZoomBadgeIn', target: '_antNoWrapperZoomBadgeIn' },
|
||||
{ source: 'antNoWrapperZoomBadgeOut', target: '_antNoWrapperZoomBadgeOut' },
|
||||
{ source: 'antBadgeLoadingCircle', target: '_antBadgeLoadingCircle' },
|
||||
{ source: 'Bdi', target: '["bdi"]' },
|
||||
{ source: 'class ComponentToken', target: 'partial class BadgeToken' },
|
||||
{ source: 'class BadgeToken', target: 'partial class BadgeToken : TokenWithCommonCls' },
|
||||
{ source: 'class Badge', target: 'partial class Badge' },
|
||||
{ source: 'Math.Round(fontSize * lineHeight)', target: '(int)Math.Round((double)fontSize * lineHeight)' },
|
||||
{ source: 'prepareComponentToken', target: 'PrepareComponentToken' },
|
||||
{ source: 'public UseComponentStyleResult ExportDefault', target: 'protected override UseComponentStyleResult UseComponentStyle' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Breadcrumb',
|
||||
src: ['components/breadcrumb/style/index.ts'],
|
||||
dist: 'components/breadcrumb/Style.cs',
|
||||
csOptions: {
|
||||
...defaultOptions,
|
||||
defaultClass: 'Breadcrumb',
|
||||
typeMap: [
|
||||
{ from: 'Unknown1', to: 'CSSObject', ranges: [[1, 19]] },
|
||||
{ from: 'Unknown1', to: 'BreadcrumbToken', includes: [2] },
|
||||
{ from: 'Unknown2', to: 'BreadcrumbToken', includes: [1, 3] },
|
||||
{ from: 'Unknown2', to: 'CSSInterpolation[]', includes: [2] },
|
||||
],
|
||||
transforms: [
|
||||
{ source: 'class ComponentToken', target: 'partial class BreadcrumbToken' },
|
||||
{ source: 'class BreadcrumbToken', target: 'partial class BreadcrumbToken : TokenWithCommonCls' },
|
||||
{ source: 'class Breadcrumb', target: 'partial class Breadcrumb' },
|
||||
{ source: 'token.LineHeight * token.FontSize', target: '(int)(token.LineHeight * token.FontSize)' },
|
||||
{ source: 'var BreadcrumbToken', target: 'var breadcrumbToken' },
|
||||
{ source: '(BreadcrumbToken)', target: '(breadcrumbToken)' },
|
||||
{ source: 'public UseComponentStyleResult ExportDefault', target: 'protected override UseComponentStyleResult UseComponentStyle' },
|
||||
]
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
// 用于生成的实例,将需要生成的组件配置放到这里
|
||||
export const components: Component[] = [
|
||||
{
|
||||
name: 'Button',
|
||||
src: [
|
||||
'components/button/style/index.ts',
|
||||
'components/button/style/group.ts'
|
||||
],
|
||||
dist: 'components/button/Style.cs',
|
||||
csOptions: {
|
||||
...defaultOptions,
|
||||
defaultClass: 'Button',
|
||||
typeMap: [
|
||||
{ from: 'FontWeight', to: 'int' },
|
||||
{ from: 'PaddingInline<string | number>', to: 'int' },
|
||||
{ from: 'Unknown1', to: 'ButtonToken', includes: [1] },
|
||||
{ from: 'Unknown3', to: 'CSSObject', includes: [1, 3] },
|
||||
{ from: 'Unknown3', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown4', to: 'CSSObject', includes: [1, 3] },
|
||||
{ from: 'Unknown4', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown5', to: 'CSSObject', includes: [1, 3] },
|
||||
{ from: 'Unknown5', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown6', to: 'CSSObject', includes: [1, 2] },
|
||||
{ from: 'Unknown7', to: 'CSSObject', includes: [1, 3, 4] },
|
||||
{ from: 'Unknown7', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown8', to: 'CSSObject', includes: [1, 3] },
|
||||
{ from: 'Unknown8', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown9', to: 'CSSObject', includes: [1, 3, 4] },
|
||||
{ from: 'Unknown9', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown10', to: 'CSSObject', ranges: [[1, 8]] },
|
||||
{ from: 'Unknown10', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown11', to: 'CSSObject', ranges: [[1, 12]] },
|
||||
{ from: 'Unknown11', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown12', to: 'CSSObject', includes: [1, 3] },
|
||||
{ from: 'Unknown12', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown13', to: 'CSSObject', ranges: [[1, 8]] },
|
||||
{ from: 'Unknown13', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown14', to: 'CSSObject', ranges: [[1, 8]] },
|
||||
{ from: 'Unknown14', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown15', to: 'CSSObject', ranges: [[1, 4]] },
|
||||
{ from: 'Unknown15', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown16', to: 'CSSObject', ranges: [[1, 9]] },
|
||||
{ from: 'CSSInterpolation', to: 'CSSInterpolation[]' },
|
||||
{ from: 'Unknown17', to: 'CSSInterpolation', includes: [1] },
|
||||
{ from: 'Unknown17', to: 'ButtonToken', includes: [2, 3] },
|
||||
{ from: 'Unknown18', to: 'CSSInterpolation', includes: [1] },
|
||||
{ from: 'Unknown18', to: 'ButtonToken', includes: [2, 3] },
|
||||
{ from: 'Unknown19', to: 'CSSInterpolation', includes: [1] },
|
||||
{ from: 'Unknown19', to: 'ButtonToken', includes: [2, 3] },
|
||||
{ from: 'Unknown20', to: 'CSSObject', includes: [1, 3, 4, 5] },
|
||||
{ from: 'Unknown20', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown21', to: 'ButtonToken', includes: [1, 2, 3] },
|
||||
{ from: 'Unknown22', to: 'ButtonToken', includes: [1, 2] },
|
||||
{ from: 'Unknown23', to: 'CSSInterpolation[]', includes: [1] },
|
||||
{ from: 'Unknown24', to: 'CSSObject', ranges: [[1, 9]] },
|
||||
{ from: 'Unknown25', to: 'CSSObject', ranges: [[1, 14]] },
|
||||
{ from: 'Unknown25', to: 'ButtonToken', includes: [2] },
|
||||
{ from: 'Unknown25', to: 'CSSInterpolation[]', includes: [4] },
|
||||
],
|
||||
transforms: [
|
||||
{ source: 'class ComponentToken', target: 'partial class ButtonToken' },
|
||||
{ source: 'class ButtonToken', target: 'partial class ButtonToken : TokenWithCommonCls' },
|
||||
{ source: 'class Button', target: 'partial class Button' },
|
||||
{ source: 'CSSObject hoverStyle, CSSObject activeStyle', target: 'CSSObject hoverStyle = default, CSSObject activeStyle = default' },
|
||||
{ source: 'prepareComponentToken', target: 'PrepareComponentToken' },
|
||||
// 实际没有该属性,先注释掉
|
||||
{ source: 'DefaultBorderColorDisabled = token.ColorBorder,', target: '// DefaultBorderColorDisabled = token.ColorBorder,' },
|
||||
{ source: 'public UseComponentStyleResult ExportDefault', target: 'protected override UseComponentStyleResult UseComponentStyle' },
|
||||
]
|
||||
}
|
||||
},
|
||||
]
|
|
@ -3,7 +3,7 @@ import { isString, toPascalCase, castType, castFieldName, castFieldValue, init,
|
|||
export type Transform = {
|
||||
source: string;
|
||||
target: string;
|
||||
regex?: string;
|
||||
regex?: RegExp;
|
||||
}
|
||||
|
||||
export type TypeMap = {
|
||||
|
@ -32,6 +32,7 @@ export enum CsKinds {
|
|||
Func = 5,
|
||||
Action = 6,
|
||||
VariableDeclaration = 7,
|
||||
Identifier = 8,
|
||||
}
|
||||
|
||||
export type ParameterType = {
|
||||
|
@ -243,6 +244,9 @@ export class CsFunction {
|
|||
case CsKinds.VariableDeclaration:
|
||||
codes.push(...this.createVariableDeclaration(tab, x));
|
||||
break;
|
||||
case CsKinds.Identifier:
|
||||
codes.push(`${tab}${x.text}`);
|
||||
break;
|
||||
}
|
||||
});
|
||||
return codes;
|
||||
|
@ -347,7 +351,11 @@ export class CsFunction {
|
|||
codes.push(...funcCodes);
|
||||
break;
|
||||
case CsKinds.Method:
|
||||
const callCodes = (x as CsFunction).format(tab + ' ', end);
|
||||
const methodCodes = (x as CsFunction).format(tab + ' ', end);
|
||||
codes.push(...methodCodes);
|
||||
break;
|
||||
case CsKinds.CallExpression:
|
||||
const callCodes = this.createCallExpression(tab + ' ', x as CallExpression, ');');
|
||||
codes.push(...callCodes);
|
||||
break;
|
||||
}
|
||||
|
@ -493,7 +501,11 @@ export class CsBuilder {
|
|||
if (code == '') continue;
|
||||
const item = this.options.transforms.find(x => code.includes(x.source));
|
||||
if (!item) continue;
|
||||
codes[i] = code.replace(item.source, item.target);
|
||||
if (item.regex) {
|
||||
codes[i] = code.replace(item.regex, item.target);
|
||||
} else {
|
||||
codes[i] = code.replace(item.source, item.target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -162,6 +162,10 @@ function createCallExpression(assignment: string, returnType: string, callExp: t
|
|||
const func = createArrowFunction('', arg as ts.ArrowFunction, CsKinds.Func);
|
||||
callExpression.paramaters.push(func);
|
||||
break;
|
||||
case ts.SyntaxKind.CallExpression:
|
||||
const callExp = createCallExpression('', '', arg as ts.CallExpression);
|
||||
callExpression.paramaters.push(callExp);
|
||||
break;
|
||||
default:
|
||||
callExpression.paramaters.push(arg.getText());
|
||||
break;
|
||||
|
@ -238,6 +242,8 @@ function createArrowFunction(funcName: string, arrowFunc: ts.ArrowFunction, kind
|
|||
statements.push(createArrayExpression(returnType, (rs.expression as any).elements));
|
||||
} else if (rs.expression?.kind === ts.SyntaxKind.CallExpression) {
|
||||
statements.push(createCallExpression('', '', rs.expression as ts.CallExpression, 'return '));
|
||||
} else {
|
||||
statements.push({ kind: CsKinds.Identifier, text: x.getText() });
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -254,6 +260,9 @@ function convertVariableStatement(context: Context<ts.VariableStatement>) {
|
|||
switch (declaration.initializer?.kind) {
|
||||
case ts.SyntaxKind.ArrowFunction:
|
||||
const funcName = declaration.name.getText();
|
||||
if(funcName === 'genSizeBaseButtonStyle') {
|
||||
console.log('')
|
||||
}
|
||||
const func = createArrowFunction(funcName, declaration.initializer as ts.ArrowFunction);
|
||||
context.csBuilder.addFunction(func);
|
||||
break;
|
||||
|
@ -289,6 +298,8 @@ function convertExportAssignment(context: Context<ts.ExportAssignment>) {
|
|||
parameters.push(funBody);
|
||||
} else if (x.kind === ts.SyntaxKind.StringLiteral) {
|
||||
parameters.push(x.getText());
|
||||
} else{
|
||||
parameters.push(x.getText());
|
||||
}
|
||||
});
|
||||
const callExpression: CallExpression = {
|
||||
|
|
Загрузка…
Ссылка в новой задаче