From 77484257adf9dc623f39a2f75763ba20b2952900 Mon Sep 17 00:00:00 2001 From: Michelle Zhang <56095982+michellewzhang@users.noreply.github.com> Date: Fri, 13 Oct 2023 09:54:46 -0700 Subject: [PATCH] ref: move accordion to components (#58009) Closes https://github.com/getsentry/team-replay/issues/242 --- .../accordion}/accordion.spec.tsx | 2 +- .../accordion}/accordion.tsx | 49 ++++++++++++------- .../widgets/widgets/lineChartListWidget.tsx | 2 +- .../widgets/stackedAreaChartListWidget.tsx | 2 +- .../landing/widgets/widgets/trendsWidget.tsx | 2 +- .../landing/widgets/widgets/vitalWidget.tsx | 2 +- .../deadRageClick/deadRageSelectorCards.tsx | 3 +- 7 files changed, 37 insertions(+), 25 deletions(-) rename static/app/{views/performance/landing/widgets/components => components/accordion}/accordion.spec.tsx (91%) rename static/app/{views/performance/landing/widgets/components => components/accordion}/accordion.tsx (76%) diff --git a/static/app/views/performance/landing/widgets/components/accordion.spec.tsx b/static/app/components/accordion/accordion.spec.tsx similarity index 91% rename from static/app/views/performance/landing/widgets/components/accordion.spec.tsx rename to static/app/components/accordion/accordion.spec.tsx index 75d33806d26fac..d868a58f37dd44 100644 --- a/static/app/views/performance/landing/widgets/components/accordion.spec.tsx +++ b/static/app/components/accordion/accordion.spec.tsx @@ -1,6 +1,6 @@ import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary'; -import Accordion from 'sentry/views/performance/landing/widgets/components/accordion'; +import Accordion from 'sentry/components/accordion/accordion'; const items = [ {header: () =>

header

, content: () =>

first content

}, diff --git a/static/app/views/performance/landing/widgets/components/accordion.tsx b/static/app/components/accordion/accordion.tsx similarity index 76% rename from static/app/views/performance/landing/widgets/components/accordion.tsx rename to static/app/components/accordion/accordion.tsx index e0f6a63f5c5908..53a6297f51e7af 100644 --- a/static/app/views/performance/landing/widgets/components/accordion.tsx +++ b/static/app/components/accordion/accordion.tsx @@ -16,6 +16,7 @@ interface Props { items: AccordionItemContent[]; setExpandedIndex: (index: number) => void; buttonOnLeft?: boolean; + collapsible?: boolean; } export default function Accordion({ @@ -23,6 +24,7 @@ export default function Accordion({ setExpandedIndex, items, buttonOnLeft, + collapsible = true, }: Props) { return ( @@ -34,6 +36,7 @@ export default function Accordion({ content={item.content()} setExpandedIndex={setExpandedIndex} buttonOnLeft={buttonOnLeft} + collapsible={collapsible} > {item.header()} @@ -49,6 +52,7 @@ function AccordionItem({ setExpandedIndex, content, buttonOnLeft, + collapsible, }: { children: ReactNode; content: ReactNode; @@ -56,20 +60,35 @@ function AccordionItem({ isExpanded: boolean; setExpandedIndex: (index: number) => void; buttonOnLeft?: boolean; + collapsible?: boolean; }) { + const button = collapsible ? ( +