@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
370 lines (319 loc) • 8.34 kB
JavaScript
import { controlHeight } from "../controlSize.mjs";
import { focusRing } from "../focusRing.mjs";
import { createStaticStyles } from "antd-style";
//#region src/base-ui/Button/style.ts
const buttonPaddingInline = {
large: 16,
middle: 14,
small: 8
};
const styles = createStaticStyles(({ css, cssVar }) => ({
base: css`
cursor: pointer;
position: relative;
display: inline-flex;
gap: 6px;
align-items: center;
justify-content: center;
box-sizing: border-box;
border: 1px solid ${cssVar.colorBorder};
font-weight: 500;
line-height: 1;
text-decoration: none;
white-space: nowrap;
transition:
color 160ms cubic-bezier(0.32, 0.72, 0, 1),
background 160ms cubic-bezier(0.32, 0.72, 0, 1),
border-color 160ms cubic-bezier(0.32, 0.72, 0, 1),
box-shadow 160ms cubic-bezier(0.32, 0.72, 0, 1);
${focusRing};
&:disabled,
&[aria-disabled='true'] {
pointer-events: none;
cursor: not-allowed;
opacity: 0.5;
}
`,
sizeSmall: css`
--button-padding-inline: ${buttonPaddingInline.small}px;
height: ${controlHeight.small}px;
padding-inline: var(--button-padding-inline);
border-radius: ${cssVar.borderRadiusSM};
font-size: 12px;
`,
sizeMiddle: css`
--button-padding-inline: ${buttonPaddingInline.middle}px;
height: ${controlHeight.middle}px;
padding-inline: var(--button-padding-inline);
border-radius: ${cssVar.borderRadiusSM};
font-size: 13px;
`,
sizeLarge: css`
--button-padding-inline: ${buttonPaddingInline.large}px;
height: ${controlHeight.large}px;
padding-inline: var(--button-padding-inline);
border-radius: ${cssVar.borderRadius};
font-size: 14px;
`,
outdentStart: css`
margin-inline-start: calc(var(--button-padding-inline) * -1);
`,
outdentEnd: css`
margin-inline-end: calc(var(--button-padding-inline) * -1);
`,
shapeCircle: css`
padding-inline: 0;
border-radius: 50%;
`,
shapeRound: css`
border-radius: 999px;
`,
block: css`
width: 100%;
`,
iconEnd: css`
flex-direction: row-reverse;
`,
iconOnlySmall: css`
--button-padding-inline: 0px;
width: 24px;
padding-inline: 0;
`,
iconOnlyMiddle: css`
--button-padding-inline: 0px;
width: 32px;
padding-inline: 0;
`,
iconOnlyLarge: css`
--button-padding-inline: 0px;
width: 40px;
padding-inline: 0;
`,
iconBox: css`
display: inline-flex;
align-items: center;
justify-content: center;
`,
spinnerSlot: css`
overflow: hidden;
width: 0;
margin-inline-end: -6px;
opacity: 0;
transition:
width 380ms cubic-bezier(0.22, 1, 0.36, 1),
margin 380ms cubic-bezier(0.22, 1, 0.36, 1),
opacity 260ms cubic-bezier(0.22, 1, 0.36, 1);
`,
spinnerSlotEnd: css`
margin-inline: -6px 0;
`,
spinnerSlotShow: css`
width: 12px;
margin-inline: 0;
opacity: 1;
`,
variantDefault: css`
background: ${cssVar.colorBgContainer};
/* &:hover/&:active included so the anchor form outranks antd's global a:hover/a:active link color */
&,
&:hover,
&:active {
color: ${cssVar.colorText};
}
&:hover:not(:disabled, [aria-disabled='true']) {
border-color: ${cssVar.colorPrimaryBorder};
color: ${cssVar.colorPrimaryText};
}
`,
variantPrimary: css`
border-color: ${cssVar.colorPrimary};
background: ${cssVar.colorPrimary};
&,
&:hover,
&:active {
color: ${cssVar.colorBgLayout};
}
&:hover:not(:disabled, [aria-disabled='true']) {
border-color: ${cssVar.colorPrimaryHover};
background: ${cssVar.colorPrimaryHover};
}
&:active:not(:disabled, [aria-disabled='true']) {
border-color: ${cssVar.colorPrimaryActive};
background: ${cssVar.colorPrimaryActive};
}
`,
variantDashed: css`
border-style: dashed;
background: ${cssVar.colorBgContainer};
&,
&:hover,
&:active {
color: ${cssVar.colorText};
}
&:hover:not(:disabled, [aria-disabled='true']) {
border-color: ${cssVar.colorPrimaryBorder};
color: ${cssVar.colorPrimaryText};
}
`,
variantFill: css`
border-color: transparent;
background: ${cssVar.colorFillTertiary};
&,
&:hover,
&:active {
color: ${cssVar.colorText};
}
&:hover:not(:disabled, [aria-disabled='true']) {
background: ${cssVar.colorFillSecondary};
}
&:active:not(:disabled, [aria-disabled='true']) {
background: ${cssVar.colorFill};
}
`,
variantText: css`
border-color: transparent;
background: transparent;
&,
&:hover,
&:active {
color: ${cssVar.colorText};
}
&:hover:not(:disabled, [aria-disabled='true']) {
background: ${cssVar.colorFillSecondary};
}
`,
variantLink: css`
padding-inline: 0;
border-color: transparent;
background: transparent;
&,
&:hover,
&:active {
color: ${cssVar.colorPrimary};
}
&:hover:not(:disabled, [aria-disabled='true']) {
color: ${cssVar.colorPrimaryHover};
background: transparent;
}
`,
dangerOutlined: css`
border-color: ${cssVar.colorError};
background: ${cssVar.colorBgContainer};
&,
&:hover,
&:active {
color: ${cssVar.colorError};
}
&:hover:not(:disabled, [aria-disabled='true']) {
border-color: ${cssVar.colorErrorHover};
color: ${cssVar.colorErrorHover};
background: ${cssVar.colorBgContainer};
}
`,
dangerSolid: css`
border-color: ${cssVar.colorError};
background: ${cssVar.colorError};
&,
&:hover,
&:active {
color: ${cssVar.colorBgLayout};
}
&:hover:not(:disabled, [aria-disabled='true']) {
border-color: ${cssVar.colorErrorHover};
background: ${cssVar.colorErrorHover};
}
&:active:not(:disabled, [aria-disabled='true']) {
border-color: ${cssVar.colorErrorActive};
background: ${cssVar.colorErrorActive};
}
`,
dangerFill: css`
border-color: transparent;
color: ${cssVar.colorError};
background: ${cssVar.colorErrorBg};
&:hover:not(:disabled, [aria-disabled='true']) {
color: ${cssVar.colorErrorHover};
background: ${cssVar.colorErrorBgHover};
}
&:active:not(:disabled, [aria-disabled='true']) {
color: ${cssVar.colorErrorActive};
background: ${cssVar.colorErrorBgHover};
}
`,
dangerInline: css`
&,
&:hover,
&:active {
color: ${cssVar.colorError};
}
&:hover:not(:disabled, [aria-disabled='true']) {
color: ${cssVar.colorErrorHover};
}
`,
ghostDefault: css`
border-color: transparent;
background: transparent;
&,
&:hover,
&:active {
color: ${cssVar.colorText};
}
&:hover:not(:disabled, [aria-disabled='true']) {
background: ${cssVar.colorFillSecondary};
}
&:active:not(:disabled, [aria-disabled='true']) {
background: ${cssVar.colorFill};
}
`,
ghostPrimary: css`
border-color: transparent;
background: transparent;
&,
&:hover,
&:active {
color: ${cssVar.colorPrimary};
}
&:hover:not(:disabled, [aria-disabled='true']) {
color: ${cssVar.colorPrimaryHover};
background: ${cssVar.colorFillSecondary};
}
&:active:not(:disabled, [aria-disabled='true']) {
color: ${cssVar.colorPrimaryActive};
background: ${cssVar.colorFill};
}
`,
ghostDanger: css`
border-color: transparent;
background: transparent;
&,
&:hover,
&:active {
color: ${cssVar.colorError};
}
&:hover:not(:disabled, [aria-disabled='true']) {
color: ${cssVar.colorErrorHover};
background: ${cssVar.colorFillSecondary};
}
&:active:not(:disabled, [aria-disabled='true']) {
color: ${cssVar.colorErrorActive};
background: ${cssVar.colorFill};
}
`,
spinner: css`
@keyframes base-button-spin {
to {
transform: rotate(360deg);
}
}
display: inline-block;
width: 12px;
height: 12px;
border: 1.5px solid currentcolor;
border-block-start-color: transparent;
border-radius: 50%;
animation: base-button-spin 0.6s linear infinite;
`
}));
//#endregion
export { buttonPaddingInline, styles };
//# sourceMappingURL=style.mjs.map