mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 17:02:20 +08:00
Grafana UI: Apply disabled styles to LinkButton (#25693)
* Grafana UI: Apply disabled styles to LinkButton * Grafana UI: Add disabled knob
This commit is contained in:
@ -72,6 +72,12 @@ export interface StyleProps {
|
||||
hasText: boolean;
|
||||
}
|
||||
|
||||
const disabledStyles = css`
|
||||
cursor: not-allowed;
|
||||
opacity: 0.65;
|
||||
box-shadow: none;
|
||||
`;
|
||||
|
||||
export const getButtonStyles = stylesFactory((props: StyleProps) => {
|
||||
const { theme, variant } = props;
|
||||
const { padding, fontSize, height } = getPropertiesForButtonSize(props);
|
||||
@ -98,9 +104,7 @@ export const getButtonStyles = stylesFactory((props: StyleProps) => {
|
||||
|
||||
&[disabled],
|
||||
&:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.65;
|
||||
box-shadow: none;
|
||||
${disabledStyles};
|
||||
}
|
||||
`,
|
||||
getFocusStyle(theme),
|
||||
@ -157,7 +161,7 @@ Button.displayName = 'Button';
|
||||
|
||||
type ButtonLinkProps = CommonProps & ButtonHTMLAttributes<HTMLButtonElement> & AnchorHTMLAttributes<HTMLAnchorElement>;
|
||||
export const LinkButton = React.forwardRef<HTMLAnchorElement, ButtonLinkProps>(
|
||||
({ variant, icon, children, className, ...otherProps }, ref) => {
|
||||
({ variant, icon, children, className, disabled, ...otherProps }, ref) => {
|
||||
const theme = useContext(ThemeContext);
|
||||
const styles = getButtonStyles({
|
||||
theme,
|
||||
@ -167,8 +171,22 @@ export const LinkButton = React.forwardRef<HTMLAnchorElement, ButtonLinkProps>(
|
||||
hasIcon: icon !== undefined,
|
||||
});
|
||||
|
||||
const linkButtonStyles =
|
||||
disabled &&
|
||||
cx(
|
||||
disabledStyles,
|
||||
css`
|
||||
pointer-events: none;
|
||||
`
|
||||
);
|
||||
|
||||
return (
|
||||
<a className={cx(styles.button, className)} {...otherProps} ref={ref}>
|
||||
<a
|
||||
className={cx(styles.button, linkButtonStyles, className)}
|
||||
{...otherProps}
|
||||
ref={ref}
|
||||
tabIndex={disabled ? -1 : 0}
|
||||
>
|
||||
<ButtonContent icon={icon} size={otherProps.size}>
|
||||
{children}
|
||||
</ButtonContent>
|
||||
|
Reference in New Issue
Block a user