diff --git a/redisinsight/ui/src/components/base/forms/button-group/ButtonGroup.tsx b/redisinsight/ui/src/components/base/forms/button-group/ButtonGroup.tsx new file mode 100644 index 0000000000..507fbd4b5e --- /dev/null +++ b/redisinsight/ui/src/components/base/forms/button-group/ButtonGroup.tsx @@ -0,0 +1,5 @@ +import { ButtonGroup, ButtonGroupProps } from '@redis-ui/components' + +export { ButtonGroup } + +export type { ButtonGroupProps } diff --git a/redisinsight/ui/src/packages/redistimeseries-app/src/components/Chart/ChartConfigForm.tsx b/redisinsight/ui/src/packages/redistimeseries-app/src/components/Chart/ChartConfigForm.tsx index 77a1fb06cb..df923a80e0 100644 --- a/redisinsight/ui/src/packages/redistimeseries-app/src/components/Chart/ChartConfigForm.tsx +++ b/redisinsight/ui/src/packages/redistimeseries-app/src/components/Chart/ChartConfigForm.tsx @@ -1,7 +1,6 @@ import React, { useState } from 'react' -import { EuiButtonGroup, EuiButtonGroupProps } from '@elastic/eui' -import { SwitchInput, TextInput } from 'uiSrc/components/base/inputs' +import { SwitchInput, TextInput } from 'uiSrc/components/base/inputs' import { FormFieldset } from 'uiSrc/components/base/forms/fieldset' import { AxisScale, GraphMode, ChartConfigFormProps } from './interfaces' import { @@ -9,13 +8,18 @@ import { Y_LABEL_MAX_LENGTH, TITLE_MAX_LENGTH, } from './constants' +import { RiAccordion } from 'uiSrc/components/base/display/accordion/RiAccordion' +import { + ButtonGroup, + ButtonGroupProps, +} from 'uiSrc/components/base/forms/button-group/ButtonGroup' const NewEnumSelect = ({ selected, values, onClick, }: { - select: string + selected: string values: string[] onClick: (v: string) => void }) => ( @@ -25,6 +29,7 @@ const NewEnumSelect = ({ title={v.charAt(0).toUpperCase() + v.slice(1)} onClick={() => onClick(v)} className={`button-point ${selected === v ? 'button-selected' : null}`} + key={v} > {v} @@ -37,9 +42,20 @@ export default function ChartConfigForm(props: ChartConfigFormProps) { const { onChange, value } = props + const yAxisButtonGroupItems = [ + { + label: 'Left', + value: false, + }, + { + label: 'Right', + value: true, + }, + ] + return (
-
+
onChange('fill', checked)} /> - setMoreOptions(isOpen)} - buttonContent={moreOptions ? 'Less options' : 'More options'} - > - -
- {moreOptions && ( -
-
- - onChange('title', value)} - aria-label="Title" - maxLength={parseInt(TITLE_MAX_LENGTH)} - /> - - - onChange('xlabel', value)} - aria-label="X Label" - maxLength={parseInt(X_LABEL_MAX_LENGTH)} - /> - -
-
-
-
- onChange('yAxis2', checked)} + +
+ + onChange('title', value)} + aria-label="Title" + maxLength={parseInt(TITLE_MAX_LENGTH)} + /> -
- {value.yAxis2 && ( -
- {Object.keys(value.keyToY2Axis).map((key) => ( -
-
{key}
- ({ - id: v, - label: v, - }))} - onChange={(id) => - onChange('keyToY2Axis', { - ...value.keyToY2Axis, - [key]: id === 'right', - }) - } - idSelected={ - value.keyToY2Axis[key] === true ? 'right' : 'left' - } - isFullWidth - /> -
- ))} + + + onChange('xlabel', value)} + aria-label="X Label" + maxLength={parseInt(X_LABEL_MAX_LENGTH)} + /> + +
+
+
+
+ onChange('yAxis2', checked)} + />
- )} -
-
-
- onChange('yAxisConfig', v)} - isLeftYAxis={true} - value={value.yAxisConfig} - /> - {value.yAxis2 && ( + {value.yAxis2 && ( +
+ {Object.keys(value.keyToY2Axis).map((key) => ( +
+
{key}
+ + {yAxisButtonGroupItems.map((item) => ( + + onChange('keyToY2Axis', { + ...value.keyToY2Axis, + [key]: item.value, + }) + } + > + {item.label} + + ))} + +
+ ))} +
+ )} +
+ +
onChange('yAxis2Config', v)} - isLeftYAxis={false} - value={value.yAxis2Config} + label="Left Y Axis" + onChange={(v: any) => onChange('yAxisConfig', v)} + isLeftYAxis={true} + value={value.yAxisConfig} /> - )} -
-
- )} + {value.yAxis2 && ( + onChange('yAxis2Config', v)} + isLeftYAxis={false} + value={value.yAxis2Config} + /> + )} + + + } + /> ) } @@ -169,6 +183,8 @@ const YAxisConfigForm = ({ value, onChange, label }: any) => ( ) +const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1) + interface EnumSelectProps { enumType: any inputLabel: string @@ -178,13 +194,18 @@ const EnumSelect = ({ enumType, inputLabel, ...props -}: EnumSelectProps & EuiButtonGroupProps) => ( - ({ id: v, label: v }))} - onChange={(id) => props.onChange({ target: { value: id } } as any)} - idSelected={props.value.toString()} - isFullWidth - /> +}: EnumSelectProps & ButtonGroupProps) => ( + + {Object.values(enumType).map((v) => ( + + props.onChange?.({ target: { value: String(v) } } as any) + } + > + {capitalize(String(v))} + + ))} + ) diff --git a/redisinsight/ui/src/packages/redistimeseries-app/src/styles/styles.scss b/redisinsight/ui/src/packages/redistimeseries-app/src/styles/styles.scss index c1a9097d33..37b5b85865 100644 --- a/redisinsight/ui/src/packages/redistimeseries-app/src/styles/styles.scss +++ b/redisinsight/ui/src/packages/redistimeseries-app/src/styles/styles.scss @@ -9,112 +9,6 @@ div.plotly-notifier { --body-color: white; --text-color: #B5B6C0; - // Text field - .euiFieldText { - color: #B5B6C0; - font-size: 14px; - height: 30px; - width: 240px; - - &:focus { - background-image: unset; - } - } - - // Text legend - .euiFormLegend { - font-size: 13px medium; - color: #B5B6C0; - } - .euiFormLegend:not(.euiFormLegend-isHidden) { - margin-bottom: 6px; - } - - // accordion - .euiAccordion__button { - font-size: 13px; - color: #B5B6C0; - } - .euiAccordion__buttonReverse .euiAccordion__iconWrapper { - display: flex; - align-items: center; - - svg { - height: 10px; - width: 10px; - } - } - .euiAccordion__button:focus .euiAccordion__iconWrapper { - animation: unset !important; - color: inherit; - -webkit-animation: unset !important; - } - - - // toggle button group - .euiButtonGroupButton .euiButton__text { - text-transform: capitalize; - } - .euiButtonGroup--compressed .euiButtonGroupButton { - height: 30px; - width: 66px; - } - .euiButtonGroupButton.euiButtonGroupButton--text:not([class*=isDisabled]).euiButtonGroupButton-isSelected { - background-color: #292F47; - color: #8BA2FF; - font-size: 13px; - padding: 0px; - font-weight: normal; - border-color: #465282; - } - .euiButtonGroupButton.euiButtonGroupButton--text:not([class*=isDisabled]).euiButtonGroupButton-isSelected:hover { - background-color: #292F47; - text-decoration: unset; - outline: unset; - } - .euiButtonGroup--compressed .euiButtonGroup__buttons { - label:first-child { - border: 1px solid #465282; - border-radius: 4px; - border-right: 0px; - border-top-right-radius: 0px; - border-bottom-right-radius: 0px; - width: 68px; - font-size: 13px; - } - label:last-child { - font-size: 13px; - width: 68px; - border: 1px solid #465282; - border-radius: 4px; - border-top-left-radius: 0px; - border-bottom-left-radius: 0px; - } - } - - .euiButtonGroup--compressed .euiButtonGroupButton { - padding: 0px; - } - - .euiButtonGroupButton.euiButtonGroupButton--text:not([class*=isDisabled]).euiButtonGroupButton-isSelected:focus { - background-color: #292F47; - text-decoration: unset; - outline: unset; - } - .euiButtonGroupButton.euiButtonGroupButton--text:not([class*=isDisabled]).euiButtonGroupButton-isSelected:focus-within { - background-color: #292F47; - border-color: #465282; - text-decoration: unset; - outline: unset; - } - .euiButtonGroupButton.euiButtonGroupButton--text:not([class*=isDisabled]) { - color: var(--wbTextColor); - background: black; - border-radius: 1px; - text-decoration: none; - } - - .rangeslider-mask-min, .rangeslider-mask-max { fill: #161617 !important; fill-opacity: 1 !important; @@ -152,116 +46,6 @@ div.plotly-notifier { fill-opacity: 1 !important; } - // Text field - .euiFieldText { - color: #415681; - font-size: 14px; - height: 30px; - width: 240px; - - &:focus { - background-image: unset; - } - } - - // Text legend - .euiFormLegend { - font-size: 13px medium; - color: #527298; - } - .euiFormLegend:not(.euiFormLegend-isHidden) { - margin-bottom: 6px; - } - - // accordion - .euiAccordion__button { - font-size: 13px; - color: #527298; - } - .euiAccordion__buttonReverse .euiAccordion__iconWrapper { - display: flex; - align-items: center; - - svg { - height: 10px; - width: 10px; - } - } - .euiAccordion__button:focus .euiAccordion__iconWrapper { - animation: unset !important; - color: inherit; - -webkit-animation: unset !important; - } - - // toggle button group - .euiButtonGroupButton .euiButton__text { - text-transform: capitalize; - } - .euiButtonGroup--compressed .euiButtonGroupButton { - height: 30px; - width: 66px; - } - .euiButtonGroupButton.euiButtonGroupButton--text:not([class*=isDisabled]).euiButtonGroupButton-isSelected { - background-color: #D7E3FA; - color: #3163D8; - font-size: 13px; - padding: 0px; - font-weight: normal; - border-color: #243DAC; - } - .euiButtonGroupButton.euiButtonGroupButton--text:not([class*=isDisabled]).euiButtonGroupButton-isSelected:hover { - background-color: #D7E3FA; - text-decoration: unset; - outline: unset; - } - - .euiButtonGroup--compressed .euiButtonGroup__buttons { - label:first-child { - border: 1px solid #243DAC; - border-radius: 4px; - border-right: 0px; - border-top-right-radius: 0px; - border-bottom-right-radius: 0px; - width: 68px; - font-size: 13px; - } - label:last-child { - font-size: 13px; - width: 68px; - border: 1px solid #243DAC; - border-radius: 4px; - border-top-left-radius: 0px; - border-bottom-left-radius: 0px; - } - } - .euiButtonGroup--compressed .euiButtonGroupButton { - padding: 0px; - } - - .euiButtonGroupButton.euiButtonGroupButton--text:not([class*=isDisabled]) { - &:focus, &:focus-within, &:hover { - background-color: #D7E3FA; - } - } - - .euiButtonGroupButton.euiButtonGroupButton--text:not([class*=isDisabled]).euiButtonGroupButton-isSelected:focus { - background-color: #D7E3FA; - text-decoration: unset; - outline: unset; - } - .euiButtonGroupButton.euiButtonGroupButton--text:not([class*=isDisabled]).euiButtonGroupButton-isSelected:focus-within { - background-color: #D7E3FA; - border-color: #243DAC; - text-decoration: unset; - outline: unset; - } - .euiButtonGroupButton.euiButtonGroupButton--text:not([class*=isDisabled]) { - background: white; - border-radius: 1px; - text-decoration: none; - } - - .chart-config-form { .more-options { section { @@ -304,68 +88,60 @@ body { .y-axis-config { fieldset { width: 100%; - .euiButtonGroup__buttons label { - width: 100%; - } } } .chart-config-form { - + width: 50%; + min-width: fit-content; display: flex; flex-direction: column; - justify-content: center; - - .chart-top-form { + .chart-form-top { display: flex; justify-content: center; - align-items: center; - padding-bottom: 12px; - - fieldset { - min-width: 150px; - } - - & > * { - padding-right: 36px; + & > :not(:first-child) { + margin-left: 36px; } } - .more-options { - section { - display: flex; - padding-top: 24px; - padding-bottom: 36px; - padding-left: 30px; - margin-bottom: 5px; - - & > * { - padding-right: 30px; - } + .chart-form-accordion { + margin-top: 20px; - .right-y-axis { + .more-options { + width: 100%; + section { display: flex; + padding: 15px; justify-content: space-between; - width: 100%; + gap: 10px; - .switch-wrapper { - width: 100%; + &:not(:first-child) { + margin-top: 10px; } - - } - - .y-axis-2 { - width: 100%; - .y-axis-2-item { + + .right-y-axis { display: flex; - align-items: center; justify-content: space-between; - font-size: 13px; - padding-bottom: 10px; + align-items: center; + width: 100%; + + .switch-wrapper { + width: 100%; + } + } + + .y-axis-2 { + width: 100%; + .y-axis-2-item { + display: flex; + align-items: center; + justify-content: space-between; + font-size: 13px; + gap: 5px; + } } } - } } }