The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
chore: drop deprecated Button (#76296)
Uladzimir Havenchyk6787014a5524
diff --git a/frontend/src/metabase/common/components/Button/Button.styled.tsx b/frontend/src/metabase/common/components/Button/Button.styled.tsxdeleted file mode 100644index 31c196478b4..00000000000--- a/frontend/src/metabase/common/components/Button/Button.styled.tsx+++ /dev/null@@ -1,101 +0,0 @@-// eslint-disable-next-line no-restricted-imports-import { css } from "@emotion/react";-// eslint-disable-next-line no-restricted-imports-import styled from "@emotion/styled";--interface ButtonRootProps {- onlyText?: boolean;- light?: boolean;-}--export const ButtonRoot = styled.button<ButtonRootProps>`- transition: all 200ms linear;- flex-shrink: 0;-- @media (prefers-reduced-motion) {- &,- &:hover {- transition: none;- }- }-- ${({ onlyText }) =>- onlyText &&- css`- border: none;- padding: 0;- color: var(--mb-color-core-brand);-- &:hover {- background-color: unset;- }- `}-- ${({ light }) =>- light &&- css`- border: none;- height: fit-content;- line-height: 1.5rem;- padding: 0.5rem;- color: var(--mb-color-core-brand);-- &:hover {- background-color: var(--mb-color-background-secondary);- }- `}-`;--interface ButtonContentProps {- iconVertical?: boolean;-}--export const ButtonContent = styled.div<ButtonContentProps>`- display: flex;- flex-direction: ${(props) => (props.iconVertical ? "column" : "row")};- align-items: center;- justify-content: center;- min-width: ${(props) => (props.iconVertical ? "60px" : "")};-`;--interface ButtonTextContainerProps {- iconVertical: boolean;- hasIcon: boolean;- hasRightIcon: boolean;-}--const verticalTopIconCSS = css`- margin-top: 0.5rem;-`;--const verticalBottomIconCSS = css`- margin-bottom: 0.5rem;-`;--const horizontalLeftIconCSS = css`- margin-left: 0.5rem;-`;--const horizontalRightIconCSS = css`- margin-right: 0.5rem;-`;--export const ButtonTextContainer = styled.div<ButtonTextContainerProps>`- text-overflow: ellipsis;- overflow: hidden;- white-space: nowrap;-- ${(props) => {- if (props.hasIcon) {- return props.iconVertical ? verticalTopIconCSS : horizontalLeftIconCSS;- }- }}-- ${(props) => {- if (props.hasRightIcon) {- return props.iconVertical- ? verticalBottomIconCSS- : horizontalRightIconCSS;- }- }}-`;diff --git a/frontend/src/metabase/common/components/Button/Button.tsx b/frontend/src/metabase/common/components/Button/Button.tsxdeleted file mode 100644index 91c34c1e04a..00000000000--- a/frontend/src/metabase/common/components/Button/Button.tsx+++ /dev/null@@ -1,178 +0,0 @@-// eslint-disable-next-line no-restricted-imports-import styled from "@emotion/styled";-import cx from "classnames";-import type { ButtonHTMLAttributes, ElementType, ReactNode, Ref } from "react";-import { forwardRef } from "react";-import _ from "underscore";--import ButtonsS from "metabase/css/components/buttons.module.css";-import CS from "metabase/css/core/index.css";-import SpacingS from "metabase/css/core/spacing.module.css";-import { Icon } from "metabase/ui";-import type { ColorName } from "metabase/ui/colors/types";-import { isNotNull } from "metabase/utils/types";-import type { IconName } from "metabase-types/api";--import {- ButtonContent,- ButtonRoot,- ButtonTextContainer,-} from "./Button.styled";--const BUTTON_VARIANTS = [- "small",- "medium",- "large",- "round",- "primary",- "danger",- "warning",- "cancel",- "success",- "white",- "borderless",- "onlyIcon",- "fullWidth",-] as const;--const VARIANT_TO_CLASS_MAP: {- [key: string]: string;-} = {- small: ButtonsS.ButtonSmall,- medium: ButtonsS.ButtonMedium,- large: ButtonsS.ButtonLarge,- round: ButtonsS.ButtonRound,- primary: ButtonsS.ButtonPrimary,- danger: ButtonsS.ButtonDanger,- warning: ButtonsS.ButtonWarning,- cancel: ButtonsS.ButtonCancel,- success: ButtonsS.ButtonSuccess,- white: ButtonsS.ButtonWhite,- borderless: ButtonsS.ButtonBorderless,- onlyIcon: ButtonsS.ButtonOnlyIcon,- fullWidth: ButtonsS.ButtonFullWidth,-};--export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {- as?: ElementType;- className?: string;- to?: string;- tooltip?: string; // available when using as={Link}- href?: string;-- icon?: IconName | ReactNode;- iconSize?: number;- iconColor?: ColorName;- iconRight?: IconName;- iconVertical?: boolean;- labelBreakpoint?: "sm";- children?: ReactNode;-- small?: boolean;- medium?: boolean;- large?: boolean;-- primary?: boolean;- success?: boolean;- danger?: boolean;- warning?: boolean;- cancel?: boolean;- white?: boolean;-- disabled?: boolean;- round?: boolean;- borderless?: boolean;- onlyIcon?: boolean;- fullWidth?: boolean;- onlyText?: boolean;- light?: boolean;-- classNames?: {- root?: string;- icon?: string;- };-}--const BaseButton = forwardRef(function BaseButton(- {- as,- className,- icon,- iconRight,- iconSize,- iconColor,- iconVertical = false,- labelBreakpoint,- children,- classNames = {},- ...props- }: ButtonProps,- ref: Ref<HTMLButtonElement>,-) {- const variantClasses = BUTTON_VARIANTS.filter((variant) => props[variant])- .map((variant) => VARIANT_TO_CLASS_MAP[variant])- .filter(isNotNull);-- return (- <ButtonRoot- ref={ref}- as={as}- {..._.omit(props, ...BUTTON_VARIANTS)}- className={cx(- ButtonsS.Button,- classNames.root,- variantClasses,- {- [SpacingS.p1]: !children,- },- className,- )}- >- <ButtonContent iconVertical={iconVertical}>- {icon && typeof icon === "string" ? (- <Icon- className={classNames.icon}- c={iconColor}- name={icon as unknown as IconName}- size={iconSize ? iconSize : 16}- />- ) : (- icon- )}- {children && (- <ButtonTextContainer- hasIcon={!!icon}- hasRightIcon={!!iconRight}- iconVertical={iconVertical}- className={- labelBreakpoint === "sm" ? cx(CS.hide, CS.smShow) : undefined- }- >- {children}- </ButtonTextContainer>- )}- {iconRight && (- <Icon- className={classNames.icon}- c={iconColor}- name={iconRight}- size={iconSize ? iconSize : 16}- />- )}- </ButtonContent>- </ButtonRoot>- );-});--const StyledButton = styled(BaseButton)``;--StyledButton.displayName = "Button";--/**- * @deprecated: use Button from "metabase/ui"- */-export const Button = Object.assign(StyledButton, {- Root: ButtonRoot,- Content: ButtonContent,- TextContainer: ButtonTextContainer,-});diff --git a/frontend/src/metabase/common/components/Button/Button.unit.spec.tsx b/frontend/src/metabase/common/components/Button/Button.unit.spec.tsxdeleted file mode 100644index 9733e273696..00000000000--- a/frontend/src/metabase/common/components/Button/Button.unit.spec.tsx+++ /dev/null@@ -1,28 +0,0 @@-import userEvent from "@testing-library/user-event";--import { render, screen } from "__support__/ui";--import { Button } from "./Button";--describe("Button", () => {- const title = "Click";-- it("should render correctly", () => {- render(<Button>{title}</Button>);-- expect(screen.getByRole("button", { name: title })).toBeInTheDocument();- });-- it("should render correctly with an icon", () => {- render(<Button icon="star">{title}</Button>);-- expect(screen.getByRole("img", { name: "star icon" })).toBeInTheDocument();- });-- it("should receive focus on tab", async () => {- render(<Button>{title}</Button>);- await userEvent.tab();-- expect(screen.getByRole("button")).toHaveFocus();- });-});diff --git a/frontend/src/metabase/common/components/Button/index.ts b/frontend/src/metabase/common/components/Button/index.tsdeleted file mode 100644index 1c3bdccf404..00000000000--- a/frontend/src/metabase/common/components/Button/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { Button } from "./Button";-export type { ButtonProps } from "./Button";