This file was never truly necessary and has never actually been used in the history of Tailscale's open source releases. A Brief History of AUTHORS files --- The AUTHORS file was a pattern developed at Google, originally for Chromium, then adopted by Go and a bunch of other projects. The problem was that Chromium originally had a copyright line only recognizing Google as the copyright holder. Because Google (and most open source projects) do not require copyright assignemnt for contributions, each contributor maintains their copyright. Some large corporate contributors then tried to add their own name to the copyright line in the LICENSE file or in file headers. This quickly becomes unwieldy, and puts a tremendous burden on anyone building on top of Chromium, since the license requires that they keep all copyright lines intact. The compromise was to create an AUTHORS file that would list all of the copyright holders. The LICENSE file and source file headers would then include that list by reference, listing the copyright holder as "The Chromium Authors". This also become cumbersome to simply keep the file up to date with a high rate of new contributors. Plus it's not always obvious who the copyright holder is. Sometimes it is the individual making the contribution, but many times it may be their employer. There is no way for the proejct maintainer to know. Eventually, Google changed their policy to no longer recommend trying to keep the AUTHORS file up to date proactively, and instead to only add to it when requested: https://opensource.google/docs/releasing/authors. They are also clear that: > Adding contributors to the AUTHORS file is entirely within the > project's discretion and has no implications for copyright ownership. It was primarily added to appease a small number of large contributors that insisted that they be recognized as copyright holders (which was entirely their right to do). But it's not truly necessary, and not even the most accurate way of identifying contributors and/or copyright holders. In practice, we've never added anyone to our AUTHORS file. It only lists Tailscale, so it's not really serving any purpose. It also causes confusion because Tailscalars put the "Tailscale Inc & AUTHORS" header in other open source repos which don't actually have an AUTHORS file, so it's ambiguous what that means. Instead, we just acknowledge that the contributors to Tailscale (whoever they are) are copyright holders for their individual contributions. We also have the benefit of using the DCO (developercertificate.org) which provides some additional certification of their right to make the contribution. The source file changes were purely mechanical with: git ls-files | xargs sed -i -e 's/\(Tailscale Inc &\) AUTHORS/\1 contributors/g' Updates #cleanup Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <will@tailscale.com>
150 lines
5.7 KiB
TypeScript
150 lines
5.7 KiB
TypeScript
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
import cx from "classnames"
|
|
import React, { HTMLProps } from "react"
|
|
import LoadingDots from "src/ui/loading-dots"
|
|
|
|
type Props = {
|
|
type?: "button" | "submit" | "reset"
|
|
sizeVariant?: "input" | "small" | "medium" | "large"
|
|
/**
|
|
* variant is the visual style of the button. By default, this is a filled
|
|
* button. For a less prominent button, use minimal.
|
|
*/
|
|
variant?: Variant
|
|
/**
|
|
* intent describes the semantic meaning of the button's action. For
|
|
* dangerous or destructive actions, use danger. For actions that should
|
|
* be the primary focus, use primary.
|
|
*/
|
|
intent?: Intent
|
|
|
|
active?: boolean
|
|
/**
|
|
* prefixIcon is an icon or piece of content shown at the start of a button.
|
|
*/
|
|
prefixIcon?: React.ReactNode
|
|
/**
|
|
* suffixIcon is an icon or piece of content shown at the end of a button.
|
|
*/
|
|
suffixIcon?: React.ReactNode
|
|
/**
|
|
* loading displays a loading indicator inside the button when set to true.
|
|
* The sizing of the button is not affected by this prop.
|
|
*/
|
|
loading?: boolean
|
|
/**
|
|
* iconOnly indicates that the button contains only an icon. This is used to
|
|
* adjust styles to be appropriate for an icon-only button.
|
|
*/
|
|
iconOnly?: boolean
|
|
/**
|
|
* textAlign align the text center or left. If left aligned, any icons will
|
|
* move to the sides of the button.
|
|
*/
|
|
textAlign?: "center" | "left"
|
|
} & HTMLProps<HTMLButtonElement>
|
|
|
|
export type Variant = "filled" | "minimal"
|
|
export type Intent = "base" | "primary" | "warning" | "danger" | "black"
|
|
|
|
const Button = React.forwardRef<HTMLButtonElement, Props>((props, ref) => {
|
|
const {
|
|
className,
|
|
variant = "filled",
|
|
intent = "base",
|
|
sizeVariant = "large",
|
|
disabled,
|
|
children,
|
|
loading,
|
|
active,
|
|
iconOnly,
|
|
prefixIcon,
|
|
suffixIcon,
|
|
textAlign,
|
|
...rest
|
|
} = props
|
|
|
|
const hasIcon = Boolean(prefixIcon || suffixIcon)
|
|
|
|
return (
|
|
<button
|
|
className={cx(
|
|
"button",
|
|
{
|
|
// base filled
|
|
"bg-gray-0 border-gray-300 enabled:hover:bg-gray-100 enabled:hover:border-gray-300 enabled:hover:text-gray-900 disabled:border-gray-200 disabled:text-gray-400":
|
|
intent === "base" && variant === "filled",
|
|
"enabled:bg-gray-200 enabled:border-gray-300":
|
|
intent === "base" && variant === "filled" && active,
|
|
// primary filled
|
|
"bg-blue-500 border-blue-500 text-white enabled:hover:bg-blue-600 enabled:hover:border-blue-600 disabled:text-blue-50 disabled:bg-blue-300 disabled:border-blue-300":
|
|
intent === "primary" && variant === "filled",
|
|
// danger filled
|
|
"bg-red-400 border-red-400 text-white enabled:hover:bg-red-500 enabled:hover:border-red-500 disabled:text-red-50 disabled:bg-red-300 disabled:border-red-300":
|
|
intent === "danger" && variant === "filled",
|
|
// warning filled
|
|
"bg-yellow-300 border-yellow-300 text-white enabled:hover:bg-yellow-400 enabled:hover:border-yellow-400 disabled:text-yellow-50 disabled:bg-yellow-200 disabled:border-yellow-200":
|
|
intent === "warning" && variant === "filled",
|
|
// black filled
|
|
"bg-gray-800 border-gray-800 text-white enabled:hover:bg-gray-900 enabled:hover:border-gray-900 disabled:opacity-75":
|
|
intent === "black" && variant === "filled",
|
|
|
|
// minimal button (base variant, black is also included because its not supported for minimal buttons)
|
|
"bg-transparent border-transparent shadow-none disabled:border-transparent disabled:text-gray-400":
|
|
variant === "minimal",
|
|
"text-gray-700 enabled:focus-visible:bg-gray-100 enabled:hover:bg-gray-100 enabled:hover:text-gray-800":
|
|
variant === "minimal" && (intent === "base" || intent === "black"),
|
|
"enabled:bg-gray-200 border-gray-300":
|
|
variant === "minimal" &&
|
|
(intent === "base" || intent === "black") &&
|
|
active,
|
|
// primary minimal
|
|
"text-blue-600 enabled:focus-visible:bg-blue-0 enabled:hover:bg-blue-0 enabled:hover:text-blue-800":
|
|
variant === "minimal" && intent === "primary",
|
|
// danger minimal
|
|
"text-red-600 enabled:focus-visible:bg-red-0 enabled:hover:bg-red-0 enabled:hover:text-red-800":
|
|
variant === "minimal" && intent === "danger",
|
|
// warning minimal
|
|
"text-yellow-600 enabled:focus-visible:bg-orange-0 enabled:hover:bg-orange-0 enabled:hover:text-orange-800":
|
|
variant === "minimal" && intent === "warning",
|
|
|
|
// sizeVariants
|
|
"px-3 py-[0.35rem]": sizeVariant === "medium",
|
|
"h-input": sizeVariant === "input",
|
|
"px-3 text-sm py-[0.35rem]": sizeVariant === "small",
|
|
"button-active relative z-10": active === true,
|
|
"px-3":
|
|
iconOnly && (sizeVariant === "large" || sizeVariant === "input"),
|
|
"px-2":
|
|
iconOnly && (sizeVariant === "medium" || sizeVariant === "small"),
|
|
"icon-parent gap-2": hasIcon,
|
|
},
|
|
className
|
|
)}
|
|
ref={ref}
|
|
disabled={disabled || loading}
|
|
{...rest}
|
|
>
|
|
{prefixIcon && <span className="flex-shrink-0">{prefixIcon}</span>}
|
|
{loading && (
|
|
<LoadingDots className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-current" />
|
|
)}
|
|
{children && (
|
|
<span
|
|
className={cx({
|
|
"text-transparent": loading === true,
|
|
"text-left flex-1": textAlign === "left",
|
|
})}
|
|
>
|
|
{children}
|
|
</span>
|
|
)}
|
|
{suffixIcon && <span className="flex-shrink-0">{suffixIcon}</span>}
|
|
</button>
|
|
)
|
|
})
|
|
|
|
export default Button
|