From 0917b7c52f993373053b36e10ab6a13e8f50e527 Mon Sep 17 00:00:00 2001
From: Ariella Vu <20778143+digiwand@users.noreply.github.com>
Date: Thu, 13 Jul 2023 22:38:42 +0200
Subject: [PATCH] Add alternative summary UI with arrow icon to the Disclosure
component (#19770)
* disclosure: add isArrowSummary option w/ UI
* disclosure.scss: add missing trailing semicolon
* Disclosure: replace isArrowSummary -> type prop
* Disclosure: alphabetize props
* Disclosure: add cursor: pointer
* storybook: add Disclosure - Type Arrow
* Disclosure: margin-left: 0 arrow type content
* Disclosure: fix margin-left: 0 arrow type
* Disclosure: support Text media query for Arrow
* Disclosure: clean rn type -> variant
* Disclosure: use size prop for arrow summary text
* Disclosure: update rest of type -> variant
* Disclosure: 1 more type -> variant
* Disclosure: TypeArrow -> VariantArrow
---
.../ui/disclosure/disclosure.constants.ts | 4 ++
ui/components/ui/disclosure/disclosure.js | 63 +++++++++++++++----
ui/components/ui/disclosure/disclosure.scss | 28 +++++++++
.../ui/disclosure/disclosure.stories.js | 20 ++++--
4 files changed, 98 insertions(+), 17 deletions(-)
create mode 100644 ui/components/ui/disclosure/disclosure.constants.ts
diff --git a/ui/components/ui/disclosure/disclosure.constants.ts b/ui/components/ui/disclosure/disclosure.constants.ts
new file mode 100644
index 000000000..4326545de
--- /dev/null
+++ b/ui/components/ui/disclosure/disclosure.constants.ts
@@ -0,0 +1,4 @@
+export enum DisclosureVariant {
+ Default = 'default',
+ Arrow = 'arrow',
+}
diff --git a/ui/components/ui/disclosure/disclosure.js b/ui/components/ui/disclosure/disclosure.js
index e20746308..297646c09 100644
--- a/ui/components/ui/disclosure/disclosure.js
+++ b/ui/components/ui/disclosure/disclosure.js
@@ -1,9 +1,53 @@
import React, { useState, useRef, useEffect } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
-import { Icon, IconName, IconSize } from '../../component-library';
+import { Icon, IconName, IconSize, Text } from '../../component-library';
+import { Color, TextVariant } from '../../../helpers/constants/design-system';
+import { DisclosureVariant } from './disclosure.constants';
-const Disclosure = ({ children, title, size }) => {
+/**
+ * @param {string} variant
+ * @param {string} title
+ * @param {string} size
+ * @returns {JSX.Element}
+ */
+const renderSummaryByType = (variant, title, size) => {
+ switch (variant) {
+ case DisclosureVariant.Arrow: {
+ const textVariant =
+ size === 'small' ? TextVariant.bodySm : TextVariant.bodyMd;
+
+ return (
+