@scality/core-ui 0.146.0 → 0.148.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/github-pages.yml +4 -4
- package/.github/workflows/tests.yaml +11 -11
- package/.storybook/main.ts +18 -1
- package/.storybook/preview.js +2 -1
- package/dist/components/IconHelper.d.ts +1 -1
- package/dist/components/IconHelper.d.ts.map +1 -1
- package/dist/components/UnsuccessfulResult.component.d.ts +2 -3
- package/dist/components/UnsuccessfulResult.component.d.ts.map +1 -1
- package/dist/components/accordion/Accordion.component.d.ts +9 -0
- package/dist/components/accordion/Accordion.component.d.ts.map +1 -0
- package/dist/components/accordion/Accordion.component.js +47 -0
- package/dist/components/areachart/AreaChart.component.d.ts +1 -2
- package/dist/components/areachart/AreaChart.component.d.ts.map +1 -1
- package/dist/components/banner/Banner.component.d.ts +1 -2
- package/dist/components/banner/Banner.component.d.ts.map +1 -1
- package/dist/components/barchart/BarChart.component.d.ts +1 -2
- package/dist/components/barchart/BarChart.component.d.ts.map +1 -1
- package/dist/components/box/Box.d.ts +1 -3
- package/dist/components/box/Box.d.ts.map +1 -1
- package/dist/components/breadcrumb/Breadcrumb.component.d.ts +1 -2
- package/dist/components/breadcrumb/Breadcrumb.component.d.ts.map +1 -1
- package/dist/components/button/Button.component.d.ts +1 -2
- package/dist/components/button/Button.component.d.ts.map +1 -1
- package/dist/components/buttonv2/Buttonv2.component.d.ts +2 -11
- package/dist/components/buttonv2/Buttonv2.component.d.ts.map +1 -1
- package/dist/components/buttonv2/CopyButton.component.d.ts +3 -13
- package/dist/components/buttonv2/CopyButton.component.d.ts.map +1 -1
- package/dist/components/card/Card.component.d.ts +7 -7
- package/dist/components/card/Card.component.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.component.d.ts +5 -5
- package/dist/components/checkbox/Checkbox.component.d.ts.map +1 -1
- package/dist/components/chips/Chips.component.d.ts +1 -2
- package/dist/components/chips/Chips.component.d.ts.map +1 -1
- package/dist/components/circularprogressbar/CircularProgressBar.component.d.ts +1 -2
- package/dist/components/circularprogressbar/CircularProgressBar.component.d.ts.map +1 -1
- package/dist/components/circularprogressbar/CircularProgressBar.component.style.d.ts +1 -1
- package/dist/components/circularprogressbar/CircularProgressBar.component.style.d.ts.map +1 -1
- package/dist/components/cloudprogressbar/CloudProgressBar.component.d.ts +1 -2
- package/dist/components/cloudprogressbar/CloudProgressBar.component.d.ts.map +1 -1
- package/dist/components/collapsiblepanel/CollapsiblePanel.component.d.ts +1 -2
- package/dist/components/collapsiblepanel/CollapsiblePanel.component.d.ts.map +1 -1
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts +0 -1
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts.map +1 -1
- package/dist/components/coreuithemeprovider/CoreUiThemeProvider.d.ts +1 -1
- package/dist/components/coreuithemeprovider/CoreUiThemeProvider.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.d.ts +1 -2
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/dropdown/Dropdown.component.d.ts +1 -2
- package/dist/components/dropdown/Dropdown.component.d.ts.map +1 -1
- package/dist/components/dropzone/Dropzone.d.ts +1 -2
- package/dist/components/dropzone/Dropzone.d.ts.map +1 -1
- package/dist/components/emptystate/Emptystate.component.d.ts +1 -2
- package/dist/components/emptystate/Emptystate.component.d.ts.map +1 -1
- package/dist/components/emptytable/Emptytable.component.d.ts +1 -1
- package/dist/components/emptytable/Emptytable.component.d.ts.map +1 -1
- package/dist/components/error-pages/ErrorPage401.component.d.ts +1 -1
- package/dist/components/error-pages/ErrorPage401.component.d.ts.map +1 -1
- package/dist/components/error-pages/ErrorPage404.component.d.ts +1 -1
- package/dist/components/error-pages/ErrorPage404.component.d.ts.map +1 -1
- package/dist/components/error-pages/ErrorPage500.component.d.ts +1 -1
- package/dist/components/error-pages/ErrorPage500.component.d.ts.map +1 -1
- package/dist/components/error-pages/ErrorPageAuth.component.d.ts +1 -2
- package/dist/components/error-pages/ErrorPageAuth.component.d.ts.map +1 -1
- package/dist/components/form/Form.component.d.ts +5 -5
- package/dist/components/form/Form.component.d.ts.map +1 -1
- package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts +1 -2
- package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts.map +1 -1
- package/dist/components/globalhealthbar/tooltip/index.d.ts.map +1 -1
- package/dist/components/healthselectorv2/HealthSelector.component.d.ts +12 -13
- package/dist/components/healthselectorv2/HealthSelector.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.d.ts +3 -3
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/infomessage/InfoMessage.component.d.ts +1 -1
- package/dist/components/infomessage/InfoMessage.component.d.ts.map +1 -1
- package/dist/components/infomessage/InfoMessageUtils.d.ts +0 -1
- package/dist/components/infomessage/InfoMessageUtils.d.ts.map +1 -1
- package/dist/components/inlineinput/InlineInput.d.ts +1 -2
- package/dist/components/inlineinput/InlineInput.d.ts.map +1 -1
- package/dist/components/inputlist/InputButtons.d.ts +2 -3
- package/dist/components/inputlist/InputButtons.d.ts.map +1 -1
- package/dist/components/inputlist/InputList.component.d.ts +8 -8
- package/dist/components/inputlist/InputList.component.d.ts.map +1 -1
- package/dist/components/inputv2/inputv2.d.ts +5 -5
- package/dist/components/inputv2/inputv2.d.ts.map +1 -1
- package/dist/components/lateralnavbarlayout/LateralNavbarLayout.component.d.ts +1 -2
- package/dist/components/lateralnavbarlayout/LateralNavbarLayout.component.d.ts.map +1 -1
- package/dist/components/layout/Layout.component.d.ts +1 -2
- package/dist/components/layout/Layout.component.d.ts.map +1 -1
- package/dist/components/layout/v2/AppContainer.d.ts +14 -13
- package/dist/components/layout/v2/AppContainer.d.ts.map +1 -1
- package/dist/components/layout/v2/index.d.ts +1 -1
- package/dist/components/layout/v2/index.d.ts.map +1 -1
- package/dist/components/layout/v2/panels.d.ts +2 -2
- package/dist/components/layout/v2/panels.d.ts.map +1 -1
- package/dist/components/linechart/LineChart.component.d.ts +1 -2
- package/dist/components/linechart/LineChart.component.d.ts.map +1 -1
- package/dist/components/linetemporalchart/ChartUtil.d.ts.map +1 -1
- package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts +1 -2
- package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts.map +1 -1
- package/dist/components/linetemporalchart/MetricTimespanProvider.d.ts +1 -1
- package/dist/components/linetemporalchart/MetricTimespanProvider.d.ts.map +1 -1
- package/dist/components/linetemporalchart/tooltip/index.d.ts.map +1 -1
- package/dist/components/loader/Loader.component.d.ts +1 -2
- package/dist/components/loader/Loader.component.d.ts.map +1 -1
- package/dist/components/multiselect/MultiSelect.component.d.ts +1 -2
- package/dist/components/multiselect/MultiSelect.component.d.ts.map +1 -1
- package/dist/components/navbar/Navbar.component.d.ts +1 -2
- package/dist/components/navbar/Navbar.component.d.ts.map +1 -1
- package/dist/components/notifications/Notification.component.d.ts +1 -2
- package/dist/components/notifications/Notification.component.d.ts.map +1 -1
- package/dist/components/notifications/Notifications.component.d.ts +1 -2
- package/dist/components/notifications/Notifications.component.d.ts.map +1 -1
- package/dist/components/prettybytes/PrettyBytes.component.d.ts +1 -2
- package/dist/components/prettybytes/PrettyBytes.component.d.ts.map +1 -1
- package/dist/components/progressbar/ProgressBar.component.d.ts +1 -2
- package/dist/components/progressbar/ProgressBar.component.d.ts.map +1 -1
- package/dist/components/scrollbarwrapper/ScrollbarWrapper.component.d.ts +1 -1
- package/dist/components/scrollbarwrapper/ScrollbarWrapper.component.d.ts.map +1 -1
- package/dist/components/select/Select.component.d.ts +1 -2
- package/dist/components/select/Select.component.d.ts.map +1 -1
- package/dist/components/selectv2/Selectv2.component.d.ts +1 -1
- package/dist/components/selectv2/Selectv2.component.d.ts.map +1 -1
- package/dist/components/sidebar/Sidebar.component.d.ts +1 -2
- package/dist/components/sidebar/Sidebar.component.d.ts.map +1 -1
- package/dist/components/sparkline/SparkLine.component.d.ts +1 -2
- package/dist/components/sparkline/SparkLine.component.d.ts.map +1 -1
- package/dist/components/statuswrapper/Statuswrapper.component.d.ts +1 -1
- package/dist/components/statuswrapper/Statuswrapper.component.d.ts.map +1 -1
- package/dist/components/steppers/Stepper.component.d.ts +0 -2
- package/dist/components/steppers/Stepper.component.d.ts.map +1 -1
- package/dist/components/steppers/Steppers.component.d.ts +1 -2
- package/dist/components/steppers/Steppers.component.d.ts.map +1 -1
- package/dist/components/tablev2/MultiSelectableContent.d.ts +1 -2
- package/dist/components/tablev2/MultiSelectableContent.d.ts.map +1 -1
- package/dist/components/tablev2/Search.d.ts +3 -4
- package/dist/components/tablev2/Search.d.ts.map +1 -1
- package/dist/components/tablev2/SearchWithQueryParams.d.ts +1 -2
- package/dist/components/tablev2/SearchWithQueryParams.d.ts.map +1 -1
- package/dist/components/tablev2/SingleSelectableContent.d.ts +1 -1
- package/dist/components/tablev2/SingleSelectableContent.d.ts.map +1 -1
- package/dist/components/tablev2/TableCommon.d.ts +2 -2
- package/dist/components/tablev2/TableCommon.d.ts.map +1 -1
- package/dist/components/tablev2/Tablestyle.d.ts +2 -3
- package/dist/components/tablev2/Tablestyle.d.ts.map +1 -1
- package/dist/components/tablev2/Tablev2.component.d.ts +12 -13
- package/dist/components/tablev2/Tablev2.component.d.ts.map +1 -1
- package/dist/components/tablev2/useCheckbox.d.ts.map +1 -1
- package/dist/components/tablev2/useSyncedScroll.d.ts +0 -1
- package/dist/components/tablev2/useSyncedScroll.d.ts.map +1 -1
- package/dist/components/tabsv2/StyledTabs.d.ts +9 -9
- package/dist/components/tabsv2/StyledTabs.d.ts.map +1 -1
- package/dist/components/tabsv2/Tab.d.ts +0 -1
- package/dist/components/tabsv2/Tab.d.ts.map +1 -1
- package/dist/components/tabsv2/Tabsv2.component.d.ts +1 -1
- package/dist/components/tabsv2/Tabsv2.component.d.ts.map +1 -1
- package/dist/components/tabsv2/Tabsv2.component.js +1 -5
- package/dist/components/tabsv2/useScrollingTabs.d.ts +0 -1
- package/dist/components/tabsv2/useScrollingTabs.d.ts.map +1 -1
- package/dist/components/text/Text.component.d.ts +15 -15
- package/dist/components/text/Text.component.d.ts.map +1 -1
- package/dist/components/textarea/TextArea.component.d.ts +3 -3
- package/dist/components/textarea/TextArea.component.d.ts.map +1 -1
- package/dist/components/textbadge/TextBadge.component.d.ts +1 -1
- package/dist/components/textbadge/TextBadge.component.d.ts.map +1 -1
- package/dist/components/toast/DurationBasedProgressBar.d.ts +1 -2
- package/dist/components/toast/DurationBasedProgressBar.d.ts.map +1 -1
- package/dist/components/toast/Toast.component.d.ts +1 -1
- package/dist/components/toast/Toast.component.d.ts.map +1 -1
- package/dist/components/toast/useMutationsHandler.d.ts.map +1 -1
- package/dist/components/toggle/Toggle.component.d.ts +1 -1
- package/dist/components/toggle/Toggle.component.d.ts.map +1 -1
- package/dist/components/tooltip/Tooltip.component.d.ts +1 -1
- package/dist/components/tooltip/Tooltip.component.d.ts.map +1 -1
- package/dist/components/vegachart/VegaChart.component.d.ts +1 -2
- package/dist/components/vegachart/VegaChart.component.d.ts.map +1 -1
- package/dist/components/vegachartv2/SyncedCursorCharts.d.ts +1 -1
- package/dist/components/vegachartv2/SyncedCursorCharts.d.ts.map +1 -1
- package/dist/icons/branding-logo.d.ts +1 -2
- package/dist/icons/branding-logo.d.ts.map +1 -1
- package/dist/icons/branding.d.ts +1 -2
- package/dist/icons/branding.d.ts.map +1 -1
- package/dist/icons/scality-loading.d.ts +1 -2
- package/dist/icons/scality-loading.d.ts.map +1 -1
- package/dist/next.d.ts +1 -0
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +1 -0
- package/dist/organisms/attachments/AttachmentConfirmationModal.d.ts +1 -1
- package/dist/organisms/attachments/AttachmentConfirmationModal.d.ts.map +1 -1
- package/dist/organisms/attachments/AttachmentTable.d.ts +4 -3
- package/dist/organisms/attachments/AttachmentTable.d.ts.map +1 -1
- package/dist/organisms/attachments/AttachmentTable.js +1 -0
- package/dist/spacing.d.ts +5 -7
- package/dist/spacing.d.ts.map +1 -1
- package/dist/testUtils.d.ts +1 -2
- package/dist/testUtils.d.ts.map +1 -1
- package/package.json +16 -15
- package/src/lib/components/accordion/Accordion.component.tsx +99 -0
- package/src/lib/components/accordion/Accordion.test.tsx +52 -0
- package/src/lib/components/tabsv2/Tabsv2.component.tsx +0 -1
- package/src/lib/next.ts +1 -0
- package/src/lib/organisms/attachments/AttachmentTable.tsx +3 -2
- package/stories/Accordion/accordion.guideline.mdx +33 -0
- package/stories/Accordion/accordion.stories.tsx +88 -0
- package/stories/form.stories.tsx +179 -0
- /package/stories/{spacing.stories.mdx → spacing.mdx} +0 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { spacing, Stack } from '../../spacing';
|
|
4
|
+
import { Box } from '../box/Box';
|
|
5
|
+
import { Icon } from '../icon/Icon.component';
|
|
6
|
+
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
|
|
9
|
+
import { Text } from '../text/Text.component';
|
|
10
|
+
|
|
11
|
+
export type AccordionProps = {
|
|
12
|
+
title: string;
|
|
13
|
+
id: string;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const AccordionHeader = styled.button`
|
|
19
|
+
-webkit-appearance: none;
|
|
20
|
+
-moz-appearance: none;
|
|
21
|
+
appearance: none;
|
|
22
|
+
border: none;
|
|
23
|
+
width: 100%;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
background-color: transparent;
|
|
26
|
+
color: ${(props) => props.theme.textPrimary};
|
|
27
|
+
padding: 0;
|
|
28
|
+
`;
|
|
29
|
+
const AccordionContainer = styled.div<{
|
|
30
|
+
isOpen: boolean;
|
|
31
|
+
}>`
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
opacity: ${(props) => (props.isOpen ? 1 : 0)};
|
|
34
|
+
transition:
|
|
35
|
+
height 0.3s ease-in,
|
|
36
|
+
opacity 0.3s ease-in,
|
|
37
|
+
visibility 0.3s;
|
|
38
|
+
visibility: ${(props) => (props.isOpen ? 'visible' : 'hidden')};
|
|
39
|
+
`;
|
|
40
|
+
const Wrapper = styled.div`
|
|
41
|
+
padding: ${spacing.r8} 0 ${spacing.r8} ${spacing.r20};
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export const Accordion = ({ title, id, style, children }: AccordionProps) => {
|
|
45
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
46
|
+
|
|
47
|
+
const handleToggleContent = (
|
|
48
|
+
e:
|
|
49
|
+
| React.MouseEvent<HTMLButtonElement>
|
|
50
|
+
| React.KeyboardEvent<HTMLButtonElement>,
|
|
51
|
+
) => {
|
|
52
|
+
setIsOpen((prev) => !prev);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<Box style={{ width: '100%', height: 'auto' }}>
|
|
57
|
+
<h3 style={{ margin: 0 }}>
|
|
58
|
+
<AccordionHeader
|
|
59
|
+
type="button"
|
|
60
|
+
id={`Accordion-header-${id}`}
|
|
61
|
+
onClick={handleToggleContent}
|
|
62
|
+
aria-controls={id}
|
|
63
|
+
aria-expanded={isOpen}
|
|
64
|
+
onKeyDown={(e) =>
|
|
65
|
+
(e.key === 'Enter' || e.key === ' ') && handleToggleContent
|
|
66
|
+
}
|
|
67
|
+
>
|
|
68
|
+
<Stack direction="horizontal" gap="r8">
|
|
69
|
+
<Icon
|
|
70
|
+
name="Chevron-up"
|
|
71
|
+
size="lg"
|
|
72
|
+
style={{
|
|
73
|
+
transform: isOpen ? 'rotate(0deg)' : 'rotate(180deg)',
|
|
74
|
+
transition: 'transform 0.3s ease-in',
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
<Text isEmphazed>{title}</Text>
|
|
78
|
+
</Stack>
|
|
79
|
+
</AccordionHeader>
|
|
80
|
+
</h3>
|
|
81
|
+
|
|
82
|
+
<AccordionContainer
|
|
83
|
+
ref={(element) => {
|
|
84
|
+
if (isOpen) {
|
|
85
|
+
element?.style.setProperty('height', element.scrollHeight + 'px');
|
|
86
|
+
} else {
|
|
87
|
+
element?.style.setProperty('height', '0px');
|
|
88
|
+
}
|
|
89
|
+
}}
|
|
90
|
+
isOpen={isOpen}
|
|
91
|
+
id={id}
|
|
92
|
+
aria-labelledby={`Accordion-header-${id}`}
|
|
93
|
+
role="region"
|
|
94
|
+
>
|
|
95
|
+
<Wrapper style={style}>{children}</Wrapper>
|
|
96
|
+
</AccordionContainer>
|
|
97
|
+
</Box>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Accordion } from './Accordion.component';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
6
|
+
|
|
7
|
+
describe('Accordion', () => {
|
|
8
|
+
const selectors = {
|
|
9
|
+
accordionToggle: () => screen.getByRole('button'),
|
|
10
|
+
accordionContainer: () => screen.getByRole('region'),
|
|
11
|
+
accordionContent: () => screen.queryByText(/Test content/i),
|
|
12
|
+
};
|
|
13
|
+
const renderAccordion = () => {
|
|
14
|
+
const queryClient = new QueryClient();
|
|
15
|
+
render(
|
|
16
|
+
<QueryClientProvider client={queryClient}>
|
|
17
|
+
<Accordion title="Advanced Testings" id="test-accordion">
|
|
18
|
+
<div>Test content</div>
|
|
19
|
+
</Accordion>
|
|
20
|
+
</QueryClientProvider>,
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
it('should render the Accordion component with title and content', () => {
|
|
24
|
+
renderAccordion();
|
|
25
|
+
|
|
26
|
+
const accordionToggle = selectors.accordionToggle();
|
|
27
|
+
expect(accordionToggle).toBeInTheDocument();
|
|
28
|
+
const accordionContent = selectors.accordionContent();
|
|
29
|
+
expect(accordionContent).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should toggle the content when clicking on the accordion header', () => {
|
|
33
|
+
renderAccordion();
|
|
34
|
+
const accordionToggle = selectors.accordionToggle();
|
|
35
|
+
const accordionContent = selectors.accordionContent();
|
|
36
|
+
expect(accordionContent).not.toBeVisible();
|
|
37
|
+
userEvent.click(accordionToggle);
|
|
38
|
+
expect(accordionContent).toBeVisible();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should toggle the content when pressing the enter key or space key on the accordion header', () => {
|
|
42
|
+
renderAccordion();
|
|
43
|
+
const accordionToggle = selectors.accordionToggle();
|
|
44
|
+
const accordionContent = selectors.accordionContent();
|
|
45
|
+
expect(accordionContent).not.toBeVisible();
|
|
46
|
+
accordionToggle.focus();
|
|
47
|
+
userEvent.keyboard('{enter}');
|
|
48
|
+
expect(accordionContent).toBeVisible();
|
|
49
|
+
userEvent.keyboard('{space}');
|
|
50
|
+
expect(accordionContent).not.toBeVisible();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -186,7 +186,6 @@ function Tabs({
|
|
|
186
186
|
return (
|
|
187
187
|
<TabsContext.Provider value={true}>
|
|
188
188
|
<TabsContainer
|
|
189
|
-
// @ts-expect-error containerType is not yet a valid prop for react
|
|
190
189
|
style={{ containerType: 'size' }}
|
|
191
190
|
className={['sc-tabs', className].join(' ')}
|
|
192
191
|
tabLineColor={tabLineColor}
|
package/src/lib/next.ts
CHANGED
|
@@ -15,3 +15,4 @@ export { HealthSelector } from './components/healthselectorv2/HealthSelector.com
|
|
|
15
15
|
export { CoreUiThemeProvider } from './components/coreuithemeprovider/CoreUiThemeProvider';
|
|
16
16
|
export { Box } from './components/box/Box';
|
|
17
17
|
export { Input } from './components/inputv2/inputv2';
|
|
18
|
+
export { Accordion } from './components/accordion/Accordion.component';
|
|
@@ -97,8 +97,8 @@ const MenuContainer = styled.ul<{
|
|
|
97
97
|
border: 1px solid ${props.theme.selectedActive};
|
|
98
98
|
`
|
|
99
99
|
: props.searchInputIsFocused
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
? `border-bottom: 1px solid ${props.theme.selectedActive};`
|
|
101
|
+
: ''}
|
|
102
102
|
border-top: 0;
|
|
103
103
|
li {
|
|
104
104
|
padding: ${spacing.r8};
|
|
@@ -497,6 +497,7 @@ export const AttachmentTable = <
|
|
|
497
497
|
flex: 1.5,
|
|
498
498
|
marginRight: '1.5rem',
|
|
499
499
|
},
|
|
500
|
+
//@ts-expect-error
|
|
500
501
|
Cell: ({
|
|
501
502
|
value,
|
|
502
503
|
row: { original: entity },
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Meta,
|
|
3
|
+
Story,
|
|
4
|
+
Canvas,
|
|
5
|
+
Primary,
|
|
6
|
+
Controls,
|
|
7
|
+
Unstyled,
|
|
8
|
+
Source,
|
|
9
|
+
Title,
|
|
10
|
+
} from '@storybook/blocks';
|
|
11
|
+
import { Accordion } from '../../src/lib/components/accordion/Accordion.component';
|
|
12
|
+
|
|
13
|
+
import * as Stories from './accordion.stories';
|
|
14
|
+
|
|
15
|
+
<Meta of={Stories} name="Guideline" />
|
|
16
|
+
|
|
17
|
+
# Accordion
|
|
18
|
+
|
|
19
|
+
Accordions are used to toggle the visibility of content.
|
|
20
|
+
It is used to hide non essential information or to reduce the amount of information displayed on the screen.
|
|
21
|
+
|
|
22
|
+
## Style
|
|
23
|
+
|
|
24
|
+
Accordion component comes with a style prop that can be used to customize the appearance of the accordion content.
|
|
25
|
+
The default style of the accordion container only includes padding.
|
|
26
|
+
|
|
27
|
+
<Canvas of={Stories.WithCustomStyle} />
|
|
28
|
+
|
|
29
|
+
## Playground
|
|
30
|
+
|
|
31
|
+
<Canvas of={Stories.Playground} layout="fullscreen" />
|
|
32
|
+
|
|
33
|
+
<Controls of={Stories.Playground} />
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useTheme } from 'styled-components';
|
|
4
|
+
import {
|
|
5
|
+
Accordion,
|
|
6
|
+
AccordionProps,
|
|
7
|
+
} from '../../src/lib/components/accordion/Accordion.component';
|
|
8
|
+
import { Button } from '../../src/lib/components/buttonv2/Buttonv2.component';
|
|
9
|
+
import { spacing, Stack } from '../../src/lib/spacing';
|
|
10
|
+
import { Text } from '../../src/lib';
|
|
11
|
+
|
|
12
|
+
type AccordionStory = StoryObj<AccordionProps>;
|
|
13
|
+
|
|
14
|
+
const meta: Meta<AccordionProps> = {
|
|
15
|
+
title: 'Components/Accordion',
|
|
16
|
+
component: Accordion,
|
|
17
|
+
args: {
|
|
18
|
+
title: 'Accordion title',
|
|
19
|
+
children: (
|
|
20
|
+
<Stack direction="vertical" gap="r8">
|
|
21
|
+
<div>This is the content of the accordion.</div>
|
|
22
|
+
<Button label={'Check'} onClick={() => console.log('click')}></Button>
|
|
23
|
+
</Stack>
|
|
24
|
+
),
|
|
25
|
+
},
|
|
26
|
+
argTypes: {
|
|
27
|
+
children: {
|
|
28
|
+
control: { disable: true },
|
|
29
|
+
description: 'Content of the accordion',
|
|
30
|
+
table: {
|
|
31
|
+
type: { summary: 'React.ReactNode' },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
title: {
|
|
35
|
+
control: { type: 'text' },
|
|
36
|
+
description: 'Title of the accordion',
|
|
37
|
+
table: {
|
|
38
|
+
type: { summary: 'string' },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
style: {
|
|
42
|
+
control: { disable: true },
|
|
43
|
+
description: 'Use this to style the accordion content container',
|
|
44
|
+
table: { type: { summary: 'CSSProperties' } },
|
|
45
|
+
},
|
|
46
|
+
id: {
|
|
47
|
+
control: { disable: true },
|
|
48
|
+
table: { type: { summary: 'string' } },
|
|
49
|
+
description: 'Unique id for the accordion content container',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default meta;
|
|
55
|
+
|
|
56
|
+
export const Playground: AccordionStory = {};
|
|
57
|
+
|
|
58
|
+
export const Stacked: AccordionStory = {
|
|
59
|
+
render: (args) => (
|
|
60
|
+
<Stack direction="vertical" gap="r8">
|
|
61
|
+
<Accordion {...args} />
|
|
62
|
+
<Accordion {...args} />
|
|
63
|
+
<Accordion {...args} />
|
|
64
|
+
</Stack>
|
|
65
|
+
),
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const WithCustomStyle: AccordionStory = {
|
|
69
|
+
render: (args) => {
|
|
70
|
+
const { title } = args;
|
|
71
|
+
const theme = useTheme();
|
|
72
|
+
|
|
73
|
+
const style = {
|
|
74
|
+
backgroundColor: theme.statusHealthy,
|
|
75
|
+
borderRadius: spacing.r4,
|
|
76
|
+
padding: spacing.r16,
|
|
77
|
+
margin: spacing.r8,
|
|
78
|
+
};
|
|
79
|
+
return (
|
|
80
|
+
<Accordion {...args} style={style} title={title}>
|
|
81
|
+
<Text>The container of this accordion has a custom style</Text>
|
|
82
|
+
</Accordion>
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
args: {
|
|
86
|
+
title: 'Accordion with custom style',
|
|
87
|
+
},
|
|
88
|
+
};
|
package/stories/form.stories.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import { Text } from '../src/lib/components/text/Text.component';
|
|
|
13
13
|
import { Toggle } from '../src/lib/components/toggle/Toggle.component';
|
|
14
14
|
import { Stack } from '../src/lib/spacing';
|
|
15
15
|
import { iconArgType } from './controls';
|
|
16
|
+
import { Accordion } from '../src/lib/next';
|
|
16
17
|
|
|
17
18
|
export default {
|
|
18
19
|
title: 'Templates/Form',
|
|
@@ -251,3 +252,181 @@ export const PageFormWithIcon = {
|
|
|
251
252
|
},
|
|
252
253
|
},
|
|
253
254
|
};
|
|
255
|
+
|
|
256
|
+
export const FormWithAccordion = {
|
|
257
|
+
render: ({ kind, title, subTitle, icon, requireMode }) => {
|
|
258
|
+
const layout = {
|
|
259
|
+
kind,
|
|
260
|
+
title,
|
|
261
|
+
subTitle,
|
|
262
|
+
icon,
|
|
263
|
+
};
|
|
264
|
+
const [toggle, setToggle] = useState(true);
|
|
265
|
+
return (
|
|
266
|
+
<>
|
|
267
|
+
<Form
|
|
268
|
+
layout={layout}
|
|
269
|
+
requireMode={requireMode}
|
|
270
|
+
rightActions={
|
|
271
|
+
<Stack gap={'r16'}>
|
|
272
|
+
<Button variant="outline" label="Cancel" />
|
|
273
|
+
<Button
|
|
274
|
+
variant="primary"
|
|
275
|
+
label="Save"
|
|
276
|
+
icon={<Icon name="Save" />}
|
|
277
|
+
/>
|
|
278
|
+
</Stack>
|
|
279
|
+
}
|
|
280
|
+
banner={
|
|
281
|
+
<Banner
|
|
282
|
+
variant="danger"
|
|
283
|
+
icon={<Icon name="Exclamation-circle" />}
|
|
284
|
+
title={'Error'}
|
|
285
|
+
>
|
|
286
|
+
There is an error
|
|
287
|
+
</Banner>
|
|
288
|
+
}
|
|
289
|
+
>
|
|
290
|
+
<FormSection
|
|
291
|
+
title={{
|
|
292
|
+
name: 'First part entity data',
|
|
293
|
+
helpTooltip: 'Tooltip of the first entity',
|
|
294
|
+
icon: 'Search',
|
|
295
|
+
}}
|
|
296
|
+
>
|
|
297
|
+
<FormGroup
|
|
298
|
+
direction="vertical"
|
|
299
|
+
label="Name"
|
|
300
|
+
id="name"
|
|
301
|
+
labelHelpTooltip="Name Tooltip"
|
|
302
|
+
content={<Input id="name" />}
|
|
303
|
+
help="Optional helper text"
|
|
304
|
+
required
|
|
305
|
+
disabled
|
|
306
|
+
></FormGroup>
|
|
307
|
+
<FormGroup
|
|
308
|
+
direction="horizontal"
|
|
309
|
+
label="Email"
|
|
310
|
+
id="email"
|
|
311
|
+
labelHelpTooltip="Email Tooltip"
|
|
312
|
+
content={<Input id="email" />}
|
|
313
|
+
error="Invalid email format. Try with a better format."
|
|
314
|
+
helpErrorPosition="right"
|
|
315
|
+
required
|
|
316
|
+
></FormGroup>
|
|
317
|
+
</FormSection>
|
|
318
|
+
<FormSection
|
|
319
|
+
title={{
|
|
320
|
+
name: 'Second part entity data',
|
|
321
|
+
helpTooltip: 'Tooltip of the Second entity',
|
|
322
|
+
icon: 'Search',
|
|
323
|
+
}}
|
|
324
|
+
>
|
|
325
|
+
<FormGroup
|
|
326
|
+
direction="horizontal"
|
|
327
|
+
label="Name"
|
|
328
|
+
id="name1"
|
|
329
|
+
labelHelpTooltip="Name Tooltip"
|
|
330
|
+
content={
|
|
331
|
+
<Toggle
|
|
332
|
+
onChange={() => {
|
|
333
|
+
setToggle(!toggle);
|
|
334
|
+
}}
|
|
335
|
+
toggle={toggle}
|
|
336
|
+
name="toggle"
|
|
337
|
+
/>
|
|
338
|
+
}
|
|
339
|
+
help="Optional helper text"
|
|
340
|
+
required={false}
|
|
341
|
+
></FormGroup>
|
|
342
|
+
<FormGroup
|
|
343
|
+
direction="horizontal"
|
|
344
|
+
label="Email"
|
|
345
|
+
id="email1"
|
|
346
|
+
labelHelpTooltip="Email Tooltip"
|
|
347
|
+
content={<Input id="email1" />}
|
|
348
|
+
error="Invalid email format. Try with a better format."
|
|
349
|
+
helpErrorPosition="right"
|
|
350
|
+
required={false}
|
|
351
|
+
></FormGroup>
|
|
352
|
+
<FormGroup
|
|
353
|
+
direction="horizontal"
|
|
354
|
+
label="Email long long long"
|
|
355
|
+
id="email-long1"
|
|
356
|
+
labelHelpTooltip="Email Tooltip"
|
|
357
|
+
content={<Input id="email-long1" />}
|
|
358
|
+
help="optional helper text"
|
|
359
|
+
helpErrorPosition="bottom"
|
|
360
|
+
required={false}
|
|
361
|
+
></FormGroup>
|
|
362
|
+
</FormSection>
|
|
363
|
+
<FormSection>
|
|
364
|
+
<Accordion title="Advanced Settings" id="advanced-settings">
|
|
365
|
+
<FormGroup
|
|
366
|
+
direction="vertical"
|
|
367
|
+
label="Object Lock Mode"
|
|
368
|
+
id="object_lock_mode"
|
|
369
|
+
labelHelpTooltip="S3 Object Lock Retention"
|
|
370
|
+
content={
|
|
371
|
+
<Stack direction="vertical">
|
|
372
|
+
<Stack direction="vertical">
|
|
373
|
+
<Stack>
|
|
374
|
+
<input
|
|
375
|
+
type="radio"
|
|
376
|
+
name="locktype"
|
|
377
|
+
id="locktype-governance"
|
|
378
|
+
value="governance"
|
|
379
|
+
/>
|
|
380
|
+
<label htmlFor="locktype-governance">Governance</label>
|
|
381
|
+
</Stack>
|
|
382
|
+
<Text isEmphazed color="textSecondary" variant="Smaller">
|
|
383
|
+
An user with a specific IAM permissions can
|
|
384
|
+
overwrite/delete protected object versions during the
|
|
385
|
+
retention period.
|
|
386
|
+
</Text>
|
|
387
|
+
</Stack>
|
|
388
|
+
<Stack>
|
|
389
|
+
<input
|
|
390
|
+
type="radio"
|
|
391
|
+
name="locktype"
|
|
392
|
+
id="locktype-compliance"
|
|
393
|
+
value="compliance"
|
|
394
|
+
/>
|
|
395
|
+
<label htmlFor="locktype-compliance">Compliance</label>
|
|
396
|
+
</Stack>
|
|
397
|
+
<Text isEmphazed color="textSecondary" variant="Smaller">
|
|
398
|
+
No one can overwrite protected object versions during the
|
|
399
|
+
retention period.
|
|
400
|
+
</Text>
|
|
401
|
+
</Stack>
|
|
402
|
+
}
|
|
403
|
+
required={true}
|
|
404
|
+
></FormGroup>
|
|
405
|
+
<FormGroup
|
|
406
|
+
id="value-example"
|
|
407
|
+
label="Choose a value"
|
|
408
|
+
helpErrorPosition="bottom"
|
|
409
|
+
required
|
|
410
|
+
content={
|
|
411
|
+
<Select
|
|
412
|
+
id="value-example"
|
|
413
|
+
placeholder="Select an option..."
|
|
414
|
+
onChange={() => {}}
|
|
415
|
+
value={'value-1'}
|
|
416
|
+
>
|
|
417
|
+
<Select.Option value={'value-1'}>Value 1</Select.Option>
|
|
418
|
+
<Select.Option value={'value-2'}>Value 2</Select.Option>
|
|
419
|
+
<Select.Option value={'value-3'}>Value 3</Select.Option>
|
|
420
|
+
</Select>
|
|
421
|
+
}
|
|
422
|
+
/>
|
|
423
|
+
</Accordion>
|
|
424
|
+
</FormSection>
|
|
425
|
+
</Form>
|
|
426
|
+
</>
|
|
427
|
+
);
|
|
428
|
+
},
|
|
429
|
+
args: {
|
|
430
|
+
requireMode: 'partial',
|
|
431
|
+
},
|
|
432
|
+
};
|
|
File without changes
|