Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(components): deprecate button #5816

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
11 changes: 10 additions & 1 deletion app/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:storybook/recommended"
"plugin:storybook/recommended",
],
overrides: [],
parser: "@typescript-eslint/parser",
Expand All @@ -22,6 +22,7 @@ module.exports = {
"simple-import-sort",
"@typescript-eslint",
"eslint-plugin-react-compiler",
"deprecate",
],
rules: {
"react/no-unknown-property": ["error", { ignore: ["css"] }],
Expand Down Expand Up @@ -51,6 +52,14 @@ module.exports = {
],
},
],
"deprecate/import": [
"error",
{
name: "Button",
module: "@arizeai/components",
use: "@phoenix/components/button",
},
],
},
settings: {
react: {
Expand Down
7 changes: 3 additions & 4 deletions app/global-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ async function globalSetup(config: FullConfig) {
page.goto(`${baseURL}/login`);
await page.getByLabel("Email").fill("admin@localhost");
await page.getByLabel("Password").fill("admin");
await page.getByRole("button", { name: "Login", exact: true }).click();
await page.getByRole("button", { name: "Log In", exact: true }).click();

// Reset admin password
await page.waitForURL("**/reset-password");
await page.getByLabel("Old Password").fill("admin");
await page.getByLabel("New Password").fill("admin123");
await page.getByLabel("Confirm Password").fill("admin123");
await page.getByRole("button", { name: "Reset Password" }).click();

await page.goto(`${baseURL}/login`);

await page.getByLabel("Email").fill("admin@localhost");
await page.getByLabel("Password").fill("admin123");
await page.getByRole("button", { name: "Login", exact: true }).click();
await page.getByRole("button", { name: "Log In", exact: true }).click();
await page.waitForURL("**/projects");
await page.goto(`${baseURL}/settings`);
await page.waitForURL("**/settings");
Expand All @@ -46,7 +45,7 @@ async function globalSetup(config: FullConfig) {
page.goto(`${baseURL}/login`);
await page.getByLabel("Email").fill("[email protected]");
await page.getByLabel("Password").fill("member");
await page.getByRole("button", { name: "Login", exact: true }).click();
await page.getByRole("button", { name: "Log In", exact: true }).click();

// Reset member password
await page.waitForURL("**/reset-password");
Expand Down
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"chromatic": "^11.20.0",
"cpy-cli": "^5.0.0",
"eslint": "^8.57.0",
"eslint-plugin-deprecate": "^0.8.5",
"eslint-plugin-react": "^7.34.4",
"eslint-plugin-react-compiler": "0.0.0-experimental-42acc6a-20241001",
"eslint-plugin-react-hooks": "^4.6.2",
Expand Down
12 changes: 12 additions & 0 deletions app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 7 additions & 16 deletions app/src/components/ConfirmNavigation.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
import React, { ReactNode } from "react";
import { Blocker } from "react-router";

import {
Button,
Dialog,
DialogContainer,
Flex,
Text,
View,
} from "@arizeai/components";
import { Dialog, DialogContainer, Flex, Text, View } from "@arizeai/components";

import { Button } from "@phoenix/components";

function ConfirmNavigationDialogFooter({ blocker }: { blocker: Blocker }) {
return (
<View padding={"size-100"} borderTopColor={"dark"} borderTopWidth={"thin"}>
<Flex justifyContent={"end"} gap={"size-100"}>
<Button
variant={"default"}
onClick={() => blocker.reset && blocker.reset()}
size={"compact"}
>
<Button onPress={() => blocker.reset && blocker.reset()} size="S">
Cancel
</Button>
<Button
variant={"primary"}
onClick={() => blocker.proceed && blocker.proceed()}
size={"compact"}
variant="primary"
onPress={() => blocker.proceed && blocker.proceed()}
size="S"
>
Confirm
</Button>
Expand Down
47 changes: 24 additions & 23 deletions app/src/components/CopyToClipboardButton.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import React, { useCallback, useState } from "react";
import copy from "copy-to-clipboard";

import {
Button,
ButtonProps,
Icon,
Icons,
Tooltip,
TooltipTrigger,
} from "@arizeai/components";
import { Icon, Icons, Tooltip, TooltipTrigger } from "@arizeai/components";

const SHOW_COPIED_TIMEOUT_MS = 2000;

import { Button, ButtonProps } from "@phoenix/components";

export type CopyToClipboardButtonProps = Omit<
ButtonProps,
"icon" | "onPress" | "size"
> & {
/**
* The size of the button
* @default S
*/
size?: ButtonProps["size"];
/**
* The text to copy to the clipboard
*/
text: string;
};

/**
* An Icon button that copies the given text to the clipboard when clicked.
*/
export function CopyToClipboardButton({
text,
size = "compact",
disabled = false,
}: {
text: string;

size?: ButtonProps["size"];
disabled?: boolean;
}) {
export function CopyToClipboardButton(props: CopyToClipboardButtonProps) {
const { text, size = "S", ...otherProps } = props;
const [isCopied, setIsCopied] = useState(false);

const onClick = useCallback(() => {
const onPress = useCallback(() => {
copy(text);
setIsCopied(true);
setTimeout(() => {
Expand All @@ -38,15 +40,14 @@ export function CopyToClipboardButton({
<div className="copy-to-clipboard-button">
<TooltipTrigger delay={0} offset={5}>
<Button
variant="default"
disabled={disabled}
size={size}
icon={
<Icon
svg={isCopied ? <Icons.Checkmark /> : <Icons.ClipboardCopy />}
/>
}
size={size}
onClick={onClick}
onPress={onPress}
{...otherProps}
/>
<Tooltip>Copy</Tooltip>
</TooltipTrigger>
Expand Down
15 changes: 5 additions & 10 deletions app/src/components/auth/CreateAPIKeyDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import { Controller, useForm } from "react-hook-form";
import { Form } from "react-router-dom";
import { isValid as dateIsValid, parseISO } from "date-fns";

import {
Button,
Dialog,
Flex,
TextArea,
TextField,
View,
} from "@arizeai/components";
import { Dialog, Flex, TextArea, TextField, View } from "@arizeai/components";

import { Button } from "@phoenix/components";

export type APIKeyFormParams = {
name: string;
Expand Down Expand Up @@ -129,8 +124,8 @@ export function CreateAPIKeyDialog(props: {
<Button
variant={isDirty ? "primary" : "default"}
type="submit"
size="compact"
disabled={!isValid || isCommitting}
size="S"
isDisabled={!isValid || isCommitting}
>
{isCommitting ? "Creating..." : "Create Key"}
</Button>
Expand Down
9 changes: 5 additions & 4 deletions app/src/components/auth/DeleteAPIKeyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { ReactNode, useState } from "react";

import {
Button,
Dialog,
DialogContainer,
Flex,
Expand All @@ -11,6 +10,8 @@ import {
View,
} from "@arizeai/components";

import { Button } from "@phoenix/components";

export function DeleteAPIKeyButton({
handleDelete,
}: {
Expand All @@ -36,7 +37,7 @@ export function DeleteAPIKeyButton({
<Flex direction="row" justifyContent="end">
<Button
variant="danger"
onClick={() => {
onPress={() => {
handleDelete();
setDialog(null);
}}
Expand All @@ -52,10 +53,10 @@ export function DeleteAPIKeyButton({
<>
<Button
variant="danger"
size="compact"
size="S"
icon={<Icon svg={<Icons.TrashOutline />} />}
aria-label="Delete System Key"
onClick={onDelete}
onPress={onDelete}
/>
<DialogContainer
isDismissable
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/auth/OneTimeAPIKeyDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function OneTimeAPIKeyDialog(props: { jwt: string }) {
<View padding="size-200">
<Flex direction="row" gap="size-100" alignItems="end">
<TextField label="API Key" isReadOnly value={jwt} minWidth="100%" />
<CopyToClipboardButton text={jwt} size="default" />
<CopyToClipboardButton text={jwt} />
</Flex>
</View>
<View padding="size-200" borderTopColor="light" borderTopWidth="thin">
Expand Down
1 change: 1 addition & 0 deletions app/src/components/button/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Button";
4 changes: 4 additions & 0 deletions app/src/components/code/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export const readOnlyCodeMirrorCSS = css`

export const codeBlockWithCopyCSS = css`
position: relative;
min-height: 47px;
display: flex;
flex-direction: row;
align-items: center;
.copy-to-clipboard-button {
position: absolute;
top: var(--ac-global-dimension-size-100);
Expand Down
21 changes: 9 additions & 12 deletions app/src/components/dataset/DatasetForm.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import React from "react";
import { Controller, useForm } from "react-hook-form";

import {
Button,
Flex,
Form,
TextArea,
TextField,
View,
} from "@arizeai/components";
import { Flex, Form, TextArea, TextField, View } from "@arizeai/components";

import { Button } from "@phoenix/components";
import { CodeEditorFieldWrapper, JSONEditor } from "@phoenix/components/code";
import { isJSONObjectString } from "@phoenix/utils/jsonUtils";

Expand Down Expand Up @@ -129,11 +123,14 @@ export function DatasetForm({
<Button
// Only allow submission if the form is dirty for edits
// When creating allow the user to click create without any changes as the form will be prefilled with valid values
disabled={formMode === "edit" ? !isDirty : false}
isDisabled={
(formMode === "edit" ? !isDirty : false) || isSubmitting
}
variant={isDirty ? "primary" : "default"}
size="compact"
loading={isSubmitting}
onClick={handleSubmit(onSubmit)}
size="S"
onPress={() => {
handleSubmit(onSubmit)();
}}
>
{submitButtonText}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/dataset/NewDatasetButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React, { useState } from "react";

import {
Alert,
Button,
Card,
Icon,
Icons,
PopoverTrigger,
View,
} from "@arizeai/components";

import { Button } from "@phoenix/components";
import { useNotifySuccess } from "@phoenix/contexts";

import { CreateDatasetForm } from "./CreateDatasetForm";
Expand Down
3 changes: 3 additions & 0 deletions app/src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ export * from "./LoadingMask";
export * from "./Loading";
export * from "./ViewSummaryAside";
export * from "./CopyToClipboardButton";

// design system based components
export * from "./combobox";
export * from "./button";
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react";

// eslint-disable-next-line deprecate/import
import {
Button,
Button as LegacyButton,
DropdownMenu,
DropdownTrigger,
Flex,
Expand All @@ -20,8 +21,8 @@ export function CanvasDisplaySettingsDropdown() {
const pointSizeScale = usePointCloudContext((state) => state.pointSizeScale);
return (
<DropdownTrigger placement="bottom left">
<Button
variant={"default"}
<LegacyButton
variant="default"
size="compact"
icon={<Icon svg={<Icons.OptionsOutline />} />}
aria-label="Display Settings"
Expand Down
Loading
Loading