From 4e0b7783544160babca00075ff4cd9371f9a6d16 Mon Sep 17 00:00:00 2001 From: minnakt <47064971+minnakt@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:43:22 -0400 Subject: [PATCH] EVG-20201: Use new LeafyGreen props in LoadingButton component (#2077) --- .../Buttons/LoadingButton.stories.tsx | 21 ++++++++ src/components/Buttons/LoadingButton.tsx | 9 ++-- src/components/Settings/EventLog/EventLog.tsx | 10 ++-- .../configurePatchCore/index.tsx | 49 ++++++++++--------- .../actionButtons/previousCommits/index.tsx | 16 +++--- 5 files changed, 63 insertions(+), 42 deletions(-) create mode 100644 src/components/Buttons/LoadingButton.stories.tsx diff --git a/src/components/Buttons/LoadingButton.stories.tsx b/src/components/Buttons/LoadingButton.stories.tsx new file mode 100644 index 0000000000..f2252e1fde --- /dev/null +++ b/src/components/Buttons/LoadingButton.stories.tsx @@ -0,0 +1,21 @@ +import { Variant } from "@leafygreen-ui/button"; +import { CustomStoryObj, CustomMeta } from "test_utils/types"; +import { LoadingButton } from "."; + +export default { + component: LoadingButton, +} satisfies CustomMeta; + +export const Default: CustomStoryObj = { + render: (args) => Button text, + args: { + loading: false, + variant: Variant.Default, + }, + argTypes: { + variant: { + options: Object.values(Variant), + control: { type: "select" }, + }, + }, +}; diff --git a/src/components/Buttons/LoadingButton.tsx b/src/components/Buttons/LoadingButton.tsx index ed203e1a55..e4443df704 100644 --- a/src/components/Buttons/LoadingButton.tsx +++ b/src/components/Buttons/LoadingButton.tsx @@ -1,19 +1,20 @@ import { forwardRef } from "react"; import { ExtendableBox } from "@leafygreen-ui/box"; import LeafyGreenButton, { ButtonProps } from "@leafygreen-ui/button"; -import Icon from "components/Icon"; +import { Spinner } from "@leafygreen-ui/loading-indicator"; -type Props = ButtonProps & { +type Props = Omit & { loading?: boolean; }; export const LoadingButton: ExtendableBox< Props & { ref?: React.Ref }, "button" -> = forwardRef(({ leftGlyph, loading = false, ...rest }: Props, ref) => ( +> = forwardRef(({ loading = false, ...rest }: Props, ref) => ( : leftGlyph} + isLoading={loading} + loadingIndicator={} {...rest} /> )); diff --git a/src/components/Settings/EventLog/EventLog.tsx b/src/components/Settings/EventLog/EventLog.tsx index 4ab57ae962..bac0e2cc5b 100644 --- a/src/components/Settings/EventLog/EventLog.tsx +++ b/src/components/Settings/EventLog/EventLog.tsx @@ -1,8 +1,7 @@ import styled from "@emotion/styled"; -import Button from "@leafygreen-ui/button"; import Card from "@leafygreen-ui/card"; -import { Spinner } from "@leafygreen-ui/loading-indicator"; import { Subtitle } from "@leafygreen-ui/typography"; +import { LoadingButton } from "components/Buttons"; import { size } from "constants/tokens"; import { EventDiffTable } from "./EventDiffTable"; import { Header } from "./Header"; @@ -42,15 +41,14 @@ export const EventLog: React.FC = ({ ); })} {!allEventsFetched && !!events.length && ( - + )} {allEventsFetched && {allEventsFetchedCopy}} diff --git a/src/pages/configurePatch/configurePatchCore/index.tsx b/src/pages/configurePatch/configurePatchCore/index.tsx index fe6cee86dd..57c80bfc78 100644 --- a/src/pages/configurePatch/configurePatchCore/index.tsx +++ b/src/pages/configurePatch/configurePatchCore/index.tsx @@ -2,10 +2,10 @@ import { useMemo } from "react"; import { useMutation } from "@apollo/client"; import styled from "@emotion/styled"; import Button from "@leafygreen-ui/button"; -import { Spinner } from "@leafygreen-ui/loading-indicator"; import { Tab } from "@leafygreen-ui/tabs"; import TextInput from "@leafygreen-ui/text-input"; import { useNavigate } from "react-router-dom"; +import { LoadingButton } from "components/Buttons"; import { CodeChanges } from "components/CodeChanges"; import { MetadataCard, @@ -153,28 +153,29 @@ const ConfigurePatchCore: React.FC = ({ patch }) => { value={description} onChange={(e) => setDescription(e.target.value)} /> - {activated && ( - - window.history.state.idx > 0 - ? navigate(-1) - : navigate(getVersionRoute(id)) - } + + {activated && ( + + )} + - Cancel - - )} - } - > - Schedule - + Schedule + + @@ -315,8 +316,10 @@ const StyledInput = styled(TextInput)` width: 100%; `; -const StyledButton = styled(Button)` +const ButtonWrapper = styled.div` margin-top: ${size.m}; + display: flex; + gap: ${size.s}; `; const FlexRow = styled.div` diff --git a/src/pages/task/actionButtons/previousCommits/index.tsx b/src/pages/task/actionButtons/previousCommits/index.tsx index 66f5bbc50d..bca43f6812 100644 --- a/src/pages/task/actionButtons/previousCommits/index.tsx +++ b/src/pages/task/actionButtons/previousCommits/index.tsx @@ -1,11 +1,10 @@ import { useReducer, useEffect } from "react"; import { useLazyQuery, useQuery } from "@apollo/client"; import styled from "@emotion/styled"; -import Button from "@leafygreen-ui/button"; -import { Spinner } from "@leafygreen-ui/loading-indicator"; import { Option, Select } from "@leafygreen-ui/select"; import Tooltip from "@leafygreen-ui/tooltip"; import { useTaskAnalytics } from "analytics"; +import { LoadingButton } from "components/Buttons"; import { ConditionalWrapper } from "components/ConditionalWrapper"; import { finishedTaskStatuses } from "constants/task"; import { size } from "constants/tokens"; @@ -201,22 +200,21 @@ export const PreviousCommits: React.FC = ({ taskId }) => { )} > - + );