diff --git a/src/components/Collapse/Collapse.styles.ts b/src/components/Collapse/Collapse.styles.ts deleted file mode 100644 index 016fadc..0000000 --- a/src/components/Collapse/Collapse.styles.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { css } from '@emotion/css'; -import { GrafanaTheme2 } from '@grafana/data'; - -/** - * Styles - */ -export const getStyles = (theme: GrafanaTheme2) => { - return { - root: css` - border: 1px solid ${theme.colors.border.weak}; - background-color: ${theme.colors.background.primary}; - `, - header: css` - label: Header; - padding: ${theme.spacing(0.5, 0.5)}; - min-height: ${theme.spacing(4)}; - display: flex; - align-items: center; - justify-content: space-between; - white-space: nowrap; - - &:focus { - outline: none; - } - `, - title: css` - font-weight: ${theme.typography.fontWeightBold}; - margin-left: ${theme.spacing(0.5)}; - overflow: hidden; - text-overflow: ellipsis; - `, - collapseIcon: css` - margin-left: ${theme.spacing(0.5)}; - color: ${theme.colors.text.disabled}; - `, - actions: css` - margin-left: auto; - display: flex; - align-items: center; - `, - content: css` - padding: ${theme.spacing(1)}; - `, - }; -}; diff --git a/src/components/Collapse/Collapse.test.tsx b/src/components/Collapse/Collapse.test.tsx deleted file mode 100644 index 10bfd30..0000000 --- a/src/components/Collapse/Collapse.test.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { fireEvent, render, screen } from '@testing-library/react'; -import React from 'react'; - -import { Collapse } from './Collapse'; - -type Props = React.ComponentProps; - -/** - * In Test Ids - */ -const InTestIds = { - header: 'data-testid header', - content: 'data-testid content', - buttonRemove: 'data-testid button-remove', -}; - -describe('Collapse', () => { - /** - * Get Tested Component - */ - const getComponent = (props: Partial) => { - return ; - }; - - it('Should expand content', () => { - const { rerender } = render(getComponent({ isOpen: false })); - - expect(screen.queryByTestId(InTestIds.content)).not.toBeInTheDocument(); - - rerender(getComponent({ isOpen: true })); - - expect(screen.getByTestId(InTestIds.content)).toBeInTheDocument(); - }); - - it('Actions should not affect collapse state', () => { - const onToggle = jest.fn(); - - render(getComponent({ onToggle, actions: })); - - fireEvent.click(screen.getByTestId(InTestIds.buttonRemove)); - - expect(onToggle).not.toHaveBeenCalled(); - }); -}); diff --git a/src/components/Collapse/Collapse.tsx b/src/components/Collapse/Collapse.tsx deleted file mode 100644 index dfdd224..0000000 --- a/src/components/Collapse/Collapse.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import { IconButton, useStyles2 } from '@grafana/ui'; -import React from 'react'; - -import { getStyles } from './Collapse.styles'; - -/** - * Properties - */ -interface Props { - /** - * Title - */ - title?: React.ReactElement | string; - - /** - * Actions - */ - actions?: React.ReactElement; - - /** - * Children - */ - children?: React.ReactElement | string; - - /** - * Is Open? - */ - isOpen?: boolean; - - /** - * On Toggle - */ - onToggle?: () => void; - - /** - * Header Test Id - */ - headerTestId?: string; - - /** - * Content Test Id - */ - contentTestId?: string; -} - -/** - * Collapse - */ -export const Collapse: React.FC = ({ - title, - actions, - children, - isOpen = false, - onToggle, - headerTestId, - contentTestId, -}) => { - /** - * Styles - */ - const styles = useStyles2(getStyles); - - return ( -
-
- -
{title}
- {actions && ( -
event.stopPropagation()}> - {actions} -
- )} -
- {isOpen && ( -
- {children} -
- )} -
- ); -}; diff --git a/src/components/Collapse/index.ts b/src/components/Collapse/index.ts deleted file mode 100644 index 5fda998..0000000 --- a/src/components/Collapse/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Collapse'; diff --git a/src/components/SeriesEditor/SeriesEditor.tsx b/src/components/SeriesEditor/SeriesEditor.tsx index c5322bb..08e7533 100644 --- a/src/components/SeriesEditor/SeriesEditor.tsx +++ b/src/components/SeriesEditor/SeriesEditor.tsx @@ -1,4 +1,5 @@ import { Button, Icon, InlineField, InlineFieldRow, Input, useTheme2 } from '@grafana/ui'; +import { Collapse } from '@volkovlabs/components'; import React, { useCallback, useMemo, useState } from 'react'; import { DragDropContext, @@ -12,7 +13,6 @@ import { import { TEST_IDS } from '../../constants'; import { DatasetItem, SeriesItem, SeriesType } from '../../types'; import { getSeriesUniqueId, getSeriesWithNewType, reorder } from '../../utils'; -import { Collapse } from '../Collapse'; import { SeriesItemEditor } from '../SeriesItemEditor'; import { getStyles } from './SeriesEditor.styles'; @@ -150,13 +150,15 @@ export const SeriesEditor: React.FC = ({ value, onChange, dataset }) => { className={styles.item} > onToggleItem(item)} title={ <> {item.name} [{item.id}] } - headerTestId={TEST_IDS.seriesEditor.itemHeader(item.id)} - contentTestId={TEST_IDS.seriesEditor.itemContent(item.id)} actions={ <>