From 219e991da5f96b6942a36e91f1929c4cadc550be Mon Sep 17 00:00:00 2001 From: pavelpashkovsky Date: Thu, 8 Sep 2022 10:46:56 +0300 Subject: [PATCH 1/4] feat: collapse box --- .../pages/TagExplorerView.module.scss | 11 +---- webapp/javascript/pages/TagExplorerView.tsx | 7 ++- webapp/javascript/ui/Box.module.scss | 48 +++++++++++++++++++ webapp/javascript/ui/Box.tsx | 41 +++++++++++++++- 4 files changed, 93 insertions(+), 14 deletions(-) diff --git a/webapp/javascript/pages/TagExplorerView.module.scss b/webapp/javascript/pages/TagExplorerView.module.scss index 9ff7d3531e..a15d1472d0 100644 --- a/webapp/javascript/pages/TagExplorerView.module.scss +++ b/webapp/javascript/pages/TagExplorerView.module.scss @@ -23,15 +23,8 @@ .tableDescription { display: flex; - justify-content: space-between; - margin: 0 10px 10px; - } - - .title { - display: inline-block; - font-weight: 500; - font-size: 18px; - margin-right: 5px; + justify-content: flex-end; + margin: 0 0 10px 10px; } .buttons { diff --git a/webapp/javascript/pages/TagExplorerView.tsx b/webapp/javascript/pages/TagExplorerView.tsx index 7793936c8c..0b01e05125 100644 --- a/webapp/javascript/pages/TagExplorerView.tsx +++ b/webapp/javascript/pages/TagExplorerView.tsx @@ -5,7 +5,7 @@ import type { ClickEvent } from '@szhsin/react-menu'; import Color from 'color'; import type { Profile } from '@pyroscope/models/src'; -import Box from '@webapp/ui/Box'; +import Box, { CollapseBox } from '@webapp/ui/Box'; import Toolbar from '@webapp/components/Toolbar'; import ExportData from '@webapp/components/ExportData'; import TimelineChartWrapper, { @@ -238,7 +238,7 @@ function TagExplorerView() { )} - + - +
{type === 'loading' ? ( @@ -377,7 +377,6 @@ function Table({ return ( <>
- {appName} Descriptive Statistics
); } + +export interface CollapseBoxProps { + title: string; + children: React.ReactNode; +} + +export function CollapseBox({ title, children }: CollapseBoxProps) { + const [collapsed, toggleCollapse] = useState(false); + + return ( +
+
toggleCollapse((c) => !c)} + className={styles.collapseTitle} + aria-hidden + > + {title} + +
+ + {children} + +
+ ); +} From 2244f33727003309a524ca03670cbac864fe6f10 Mon Sep 17 00:00:00 2001 From: pavelpashkovsky Date: Thu, 8 Sep 2022 11:03:13 +0300 Subject: [PATCH 2/4] fix: .title --- webapp/javascript/pages/TagExplorerView.module.scss | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/webapp/javascript/pages/TagExplorerView.module.scss b/webapp/javascript/pages/TagExplorerView.module.scss index a15d1472d0..8599cd9c76 100644 --- a/webapp/javascript/pages/TagExplorerView.module.scss +++ b/webapp/javascript/pages/TagExplorerView.module.scss @@ -27,6 +27,13 @@ margin: 0 0 10px 10px; } + .title { + display: inline-block; + font-weight: 500; + font-size: 18px; + margin-right: 5px; + } + .buttons { position: relative; From 40c0bfc5a0137a69db1949e670df09cea50439ca Mon Sep 17 00:00:00 2001 From: pavelpashkovsky Date: Fri, 9 Sep 2022 11:01:18 +0300 Subject: [PATCH 3/4] refactor: styles adjustements, added stories --- stories/Box.stories.tsx | 14 +++++++++++++- webapp/javascript/pages/TagExplorerView.tsx | 6 +++++- webapp/javascript/ui/Box.module.scss | 7 ++----- webapp/javascript/ui/Box.tsx | 3 ++- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/stories/Box.stories.tsx b/stories/Box.stories.tsx index 750e7a9654..81b5884729 100644 --- a/stories/Box.stories.tsx +++ b/stories/Box.stories.tsx @@ -1,6 +1,6 @@ /* eslint-disable react/jsx-props-no-spreading */ import React from 'react'; -import Box from '@ui/Box'; +import Box, { CollapseBox } from '@ui/Box'; import Button from '@ui/Button'; import { ComponentMeta } from '@storybook/react'; import '../webapp/sass/profile.scss'; @@ -24,3 +24,15 @@ export const BoxWithButtonNoPadding = () => (

Hello, world

); + +export const CollapseBoxWithContent = () => ( + +

Hello, world

+
+); + +export const CollapseBoxWhenTitleIsEmptyString = () => ( + +

Hello, world

+
+); diff --git a/webapp/javascript/pages/TagExplorerView.tsx b/webapp/javascript/pages/TagExplorerView.tsx index 0b01e05125..17d253cab9 100644 --- a/webapp/javascript/pages/TagExplorerView.tsx +++ b/webapp/javascript/pages/TagExplorerView.tsx @@ -238,7 +238,11 @@ function TagExplorerView() { )}
- + `${a} Descriptive Statistics`) + .unwrapOr('')}`} + >
- {title} +
{title}
Date: Fri, 9 Sep 2022 13:53:33 -0300 Subject: [PATCH 4/4] fix tsdoc --- webapp/javascript/pages/TagExplorerView.tsx | 2 +- webapp/javascript/ui/Box.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/javascript/pages/TagExplorerView.tsx b/webapp/javascript/pages/TagExplorerView.tsx index 17d253cab9..3572eb34ce 100644 --- a/webapp/javascript/pages/TagExplorerView.tsx +++ b/webapp/javascript/pages/TagExplorerView.tsx @@ -241,7 +241,7 @@ function TagExplorerView() { `${a} Descriptive Statistics`) - .unwrapOr('')}`} + .unwrapOr('Descriptive Statistics')}`} >