mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-22 11:52:00 +00:00
* Add prettier before commit and during CI * Add workflow * Reverse merge main to branch * dry run prettier * dry run prettier * [warn] jsxBracketSameLine is deprecated so replaced it to bracketSameLine * Revert "[warn] jsxBracketSameLine is deprecated so replaced it to bracketSameLine" This reverts commit43dbe9ed3f. * Revert "dry run prettier" This reverts commitb62948042c. * Revert "dry run prettier" This reverts commit382f9a4691. * Revert "Reverse merge main to branch" This reverts commit43667eaf29. * [warn] jsxBracketSameLine is deprecated so replaced it to bracketSameLine
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*/
|
|
|
|
import * as React from 'react';
|
|
import cn from 'classnames';
|
|
|
|
interface ButtonProps {
|
|
children: React.ReactNode;
|
|
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
active: boolean;
|
|
className?: string;
|
|
style?: Record<string, string>;
|
|
}
|
|
|
|
export function Button({
|
|
children,
|
|
onClick,
|
|
active,
|
|
className,
|
|
style,
|
|
}: ButtonProps) {
|
|
return (
|
|
<button
|
|
style={style}
|
|
onMouseDown={(evt) => {
|
|
evt.preventDefault();
|
|
evt.stopPropagation();
|
|
}}
|
|
onClick={onClick}
|
|
className={cn(
|
|
className,
|
|
'text-base leading-tight font-bold border rounded-lg py-2 px-4 focus:ring-1 focus:ring-offset-2 focus:ring-link active:bg-link active:border-link active:text-white active:ring-0 active:ring-offset-0 outline-none inline-flex items-center my-1',
|
|
{
|
|
'bg-link border-link text-white hover:bg-link focus:bg-link active:bg-link':
|
|
active,
|
|
'bg-transparent text-secondary dark:text-secondary-dark bg-secondary-button dark:bg-secondary-button-dark hover:text-link focus:text-link border-transparent':
|
|
!active,
|
|
}
|
|
)}>
|
|
{children}
|
|
</button>
|
|
);
|
|
}
|
|
|
|
Button.defaultProps = {
|
|
active: false,
|
|
style: {},
|
|
};
|
|
|
|
export default Button;
|