diff --git a/.changeset/rich-tools-cry.md b/.changeset/rich-tools-cry.md new file mode 100644 index 00000000000..8057603a1ed --- /dev/null +++ b/.changeset/rich-tools-cry.md @@ -0,0 +1,5 @@ +--- +"@primer/react": patch +--- + +Remove link button from the new button diff --git a/docs/content/drafts/Button2.mdx b/docs/content/drafts/Button2.mdx index f33d782f723..95dfde29c8b 100644 --- a/docs/content/drafts/Button2.mdx +++ b/docs/content/drafts/Button2.mdx @@ -9,7 +9,7 @@ description: Use button for the main actions on a page or form. import {Props} from '../../src/props' import {ComponentChecklist} from '../../src/component-checklist' -import {Button, IconButton, LinkButton} from '@primer/react/drafts' +import {Button} from '@primer/react/drafts' ## Usage @@ -85,29 +85,12 @@ It is recommended to use an octicon here. ### Icon only button A separate component called `IconButton` is used if the action shows only an icon with no text. This button will remain square in shape. +Read more at [IconButton docs](/drafts/IconButton) ```jsx live drafts Search ``` -### Different sized icon buttons - -`IconButton` also supports the three different sizes. `small`, `medium`, `large`. - -```jsx live drafts -<> - - Search - - - Search - - - Search - - -``` - ### Counter component A common use case for primer is a button with a counter component which shows the child count value. diff --git a/docs/content/drafts/LinkButton.mdx b/docs/content/drafts/LinkButton.mdx deleted file mode 100644 index 23cad9811a5..00000000000 --- a/docs/content/drafts/LinkButton.mdx +++ /dev/null @@ -1,111 +0,0 @@ ---- -title: LinkButton -status: Alpha -source: https://github.com/primer/react/tree/main/src/Button2 -storybook: '/react/storybook?path=/story/composite-components-button2' -description: It is a combination of a button and link. Use this to make your link look like a button. ---- - -import {Props} from '../../src/props' -import {ComponentChecklist} from '../../src/component-checklist' -import {ArrowRightIcon} from '@primer/octicons-react' - -## Usage - -### Installation - -```js -import {LinkButton} from '@primer/react/drafts' -``` - -### Default - -The `LinkButton` can be considered an extension of `Button` component. It accepts all of the same props along with new link specific props like `to` and `href`. - -```jsx live drafts - - Link to Primer - -``` - -### Other examples of using a LinkButton - -`LinkButton` also - -- supports the three different sizes. `small`, `medium`, `large`. -- supports the different variants in [Button]('../Button2') -- supports leadingIcon and trailingIcon - -```jsx live drafts - - Small link - - Large link - - - Invisible link - - - Danger link - - - Link with arrow - - -``` - -## API reference - -Native ` - + - + - + - + - + - + ) diff --git a/src/Button2/ButtonBase.tsx b/src/Button2/ButtonBase.tsx deleted file mode 100644 index b19781a36ae..00000000000 --- a/src/Button2/ButtonBase.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import React, {ComponentPropsWithRef, forwardRef} from 'react' -import {ForwardRefComponent as PolymorphicForwardRefComponent} from '@radix-ui/react-polymorphic' -import Box from '../Box' -import {merge, SxProp} from '../sx' -import {useTheme} from '../ThemeProvider' -import {ButtonProps, StyledButton} from './types' -import {getVariantStyles, getSizeStyles, getButtonStyles} from './styles' - -const ButtonBase = forwardRef( - ({children, as: Component = 'button', sx: sxProp = {}, ...props}, forwardedRef): JSX.Element => { - const {leadingIcon: LeadingIcon, trailingIcon: TrailingIcon, variant = 'default', size = 'medium'} = props - const {theme} = useTheme() - const iconWrapStyles = { - display: 'inline-block' - } - const sxStyles = merge.all([ - getButtonStyles(theme), - getSizeStyles(size, variant, false), - getVariantStyles(variant, theme), - sxProp as SxProp - ]) - return ( - - {LeadingIcon && ( - - - - )} - {children && {children}} - {TrailingIcon && ( - - - - )} - - ) - } -) as PolymorphicForwardRefComponent<'button' | 'a', ButtonProps> - -export type ButtonBaseProps = ComponentPropsWithRef - -export {ButtonBase} diff --git a/src/Button2/LinkButton.tsx b/src/Button2/LinkButton.tsx deleted file mode 100644 index 88fab03c809..00000000000 --- a/src/Button2/LinkButton.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import React, {forwardRef} from 'react' -import {merge, SxProp} from '../sx' -import {LinkButtonProps} from './types' -import {ButtonBase, ButtonBaseProps} from './ButtonBase' -import {ForwardRefComponent as PolymorphicForwardRefComponent} from '@radix-ui/react-polymorphic' - -type MyProps = LinkButtonProps & ButtonBaseProps - -const LinkButton = forwardRef( - ({children, as: Component = 'a', sx = {}, ...props}, forwardedRef): JSX.Element => { - const style = { - width: 'fit-content', - '&:hover:not([disabled])': { - textDecoration: 'underline' - }, - // focus must come before :active so that the active box shadow overrides - '&:focus:not([disabled])': { - textDecoration: 'underline' - }, - '&:active:not([disabled])': { - textDecoration: 'underline' - } - } - const sxStyle = merge.all([style, sx as SxProp]) - return ( - - {children} - - ) - } -) as PolymorphicForwardRefComponent<'a', ButtonBaseProps> - -export {LinkButton} diff --git a/src/Button2/index.ts b/src/Button2/index.ts index 6aef1f6f8f8..c3dfb26e727 100644 --- a/src/Button2/index.ts +++ b/src/Button2/index.ts @@ -1,10 +1,11 @@ -import {ButtonComponent} from './Button' +import {Button as ButtonComponent} from './Button' import {Counter} from './ButtonCounter' import {IconButton} from './IconButton' -import {LinkButton} from './LinkButton' export type {ButtonProps, IconButtonProps} from './types' -export {IconButton, LinkButton} +export {IconButton} export const Button = Object.assign(ButtonComponent, { Counter }) + +Button.displayName = 'Button' diff --git a/src/Button2/types.ts b/src/Button2/types.ts index 9f391f7b122..c41fbe49bad 100644 --- a/src/Button2/types.ts +++ b/src/Button2/types.ts @@ -1,4 +1,4 @@ -import React, {HTMLAttributes, ComponentPropsWithRef} from 'react' +import React, {HTMLAttributes, ComponentPropsWithRef, ComponentType} from 'react' import styled from 'styled-components' import {IconProps} from '@primer/octicons-react' import sx, {SxProp} from '../sx' @@ -24,8 +24,10 @@ export type ButtonBaseProps = { * Items that are disabled can not be clicked, selected, or navigated through. */ disabled?: boolean + // eslint-disable-next-line @typescript-eslint/no-explicit-any + as?: string | ComponentType | undefined } & SxProp & - HTMLAttributes & + HTMLAttributes & StyledButtonProps export type ButtonProps = {