@snack-uikit/accordion 0.3.4-preview-85c5f47b.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/LICENSE +201 -0
  3. package/README.md +57 -0
  4. package/dist/components/AccordionPrimary/AccordionPrimary.d.ts +5 -0
  5. package/dist/components/AccordionPrimary/AccordionPrimary.js +21 -0
  6. package/dist/components/AccordionPrimary/index.d.ts +1 -0
  7. package/dist/components/AccordionPrimary/index.js +1 -0
  8. package/dist/components/AccordionPrimary/styles.module.css +7 -0
  9. package/dist/components/AccordionSecondary/AccordionSecondary.d.ts +5 -0
  10. package/dist/components/AccordionSecondary/AccordionSecondary.js +21 -0
  11. package/dist/components/AccordionSecondary/index.d.ts +1 -0
  12. package/dist/components/AccordionSecondary/index.js +1 -0
  13. package/dist/components/AccordionSecondary/styles.module.css +7 -0
  14. package/dist/components/CollapseBlockPrimary/CollapseBlockPrimary.d.ts +2 -0
  15. package/dist/components/CollapseBlockPrimary/CollapseBlockPrimary.js +22 -0
  16. package/dist/components/CollapseBlockPrimary/index.d.ts +1 -0
  17. package/dist/components/CollapseBlockPrimary/index.js +1 -0
  18. package/dist/components/CollapseBlockPrimary/styles.module.css +14 -0
  19. package/dist/components/CollapseBlockSecondary/CollapseBlockSecondary.d.ts +2 -0
  20. package/dist/components/CollapseBlockSecondary/CollapseBlockSecondary.js +22 -0
  21. package/dist/components/CollapseBlockSecondary/index.d.ts +1 -0
  22. package/dist/components/CollapseBlockSecondary/index.js +1 -0
  23. package/dist/components/CollapseBlockSecondary/styles.module.css +18 -0
  24. package/dist/components/index.d.ts +13 -0
  25. package/dist/components/index.js +11 -0
  26. package/dist/helperComponents/Accordion/Accordion.d.ts +2 -0
  27. package/dist/helperComponents/Accordion/Accordion.js +21 -0
  28. package/dist/helperComponents/Accordion/index.d.ts +1 -0
  29. package/dist/helperComponents/Accordion/index.js +1 -0
  30. package/dist/helperComponents/CollapseBlockHeader/CollapseBlockHeader.d.ts +8 -0
  31. package/dist/helperComponents/CollapseBlockHeader/CollapseBlockHeader.js +9 -0
  32. package/dist/helperComponents/CollapseBlockHeader/index.d.ts +1 -0
  33. package/dist/helperComponents/CollapseBlockHeader/index.js +1 -0
  34. package/dist/helperComponents/CollapseBlockHeader/styles.module.css +16 -0
  35. package/dist/helperComponents/CollapseBlockHeaderContainer/CollapseBlockHeaderContainer.d.ts +8 -0
  36. package/dist/helperComponents/CollapseBlockHeaderContainer/CollapseBlockHeaderContainer.js +21 -0
  37. package/dist/helperComponents/CollapseBlockHeaderContainer/index.d.ts +1 -0
  38. package/dist/helperComponents/CollapseBlockHeaderContainer/index.js +1 -0
  39. package/dist/helperComponents/CollapseBlockHeaderContainer/styles.module.css +31 -0
  40. package/dist/helperComponents/CollapseBlockPrivate/CollapseBlockPrivate.d.ts +9 -0
  41. package/dist/helperComponents/CollapseBlockPrivate/CollapseBlockPrivate.js +22 -0
  42. package/dist/helperComponents/CollapseBlockPrivate/index.d.ts +1 -0
  43. package/dist/helperComponents/CollapseBlockPrivate/index.js +1 -0
  44. package/dist/helperComponents/CollapseBlockPrivate/styles.module.css +38 -0
  45. package/dist/helperComponents/index.d.ts +4 -0
  46. package/dist/helperComponents/index.js +4 -0
  47. package/dist/index.d.ts +2 -0
  48. package/dist/index.js +2 -0
  49. package/dist/testIds.d.ts +11 -0
  50. package/dist/testIds.js +11 -0
  51. package/dist/types.d.ts +39 -0
  52. package/dist/types.js +1 -0
  53. package/package.json +45 -0
  54. package/src/components/AccordionPrimary/AccordionPrimary.tsx +13 -0
  55. package/src/components/AccordionPrimary/index.ts +1 -0
  56. package/src/components/AccordionPrimary/styles.module.scss +11 -0
  57. package/src/components/AccordionSecondary/AccordionSecondary.tsx +13 -0
  58. package/src/components/AccordionSecondary/index.ts +1 -0
  59. package/src/components/AccordionSecondary/styles.module.scss +11 -0
  60. package/src/components/CollapseBlockPrimary/CollapseBlockPrimary.tsx +27 -0
  61. package/src/components/CollapseBlockPrimary/index.ts +1 -0
  62. package/src/components/CollapseBlockPrimary/styles.module.scss +14 -0
  63. package/src/components/CollapseBlockSecondary/CollapseBlockSecondary.tsx +27 -0
  64. package/src/components/CollapseBlockSecondary/index.ts +1 -0
  65. package/src/components/CollapseBlockSecondary/styles.module.scss +18 -0
  66. package/src/components/index.ts +21 -0
  67. package/src/helperComponents/Accordion/Accordion.tsx +29 -0
  68. package/src/helperComponents/Accordion/index.ts +1 -0
  69. package/src/helperComponents/CollapseBlockHeader/CollapseBlockHeader.tsx +35 -0
  70. package/src/helperComponents/CollapseBlockHeader/index.ts +1 -0
  71. package/src/helperComponents/CollapseBlockHeader/styles.module.scss +19 -0
  72. package/src/helperComponents/CollapseBlockHeaderContainer/CollapseBlockHeaderContainer.tsx +56 -0
  73. package/src/helperComponents/CollapseBlockHeaderContainer/index.ts +1 -0
  74. package/src/helperComponents/CollapseBlockHeaderContainer/styles.module.scss +47 -0
  75. package/src/helperComponents/CollapseBlockPrivate/CollapseBlockPrivate.tsx +34 -0
  76. package/src/helperComponents/CollapseBlockPrivate/index.ts +1 -0
  77. package/src/helperComponents/CollapseBlockPrivate/styles.module.scss +50 -0
  78. package/src/helperComponents/index.ts +4 -0
  79. package/src/index.ts +2 -0
  80. package/src/testIds.ts +11 -0
  81. package/src/types.ts +46 -0
@@ -0,0 +1,16 @@
1
+ .headline{
2
+ gap:var(--space-accordion-collapse-block-title-headline-gap, 4px);
3
+ display:flex;
4
+ align-items:center;
5
+ max-width:100%;
6
+ }
7
+
8
+ .title{
9
+ max-width:100%;
10
+ color:var(--sys-neutral-text-main, #333333);
11
+ }
12
+
13
+ .subtitle{
14
+ max-width:100%;
15
+ color:var(--sys-neutral-text-support, #565656);
16
+ }
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ export type CollapseBlockHeaderContainerProps = {
3
+ children: ReactNode;
4
+ toggleExpanded(): void;
5
+ expanded: boolean;
6
+ actions?: ReactNode;
7
+ };
8
+ export declare function CollapseBlockHeaderContainer({ children, toggleExpanded, expanded, actions, }: CollapseBlockHeaderContainerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { ButtonFunction } from '@snack-uikit/button';
4
+ import { ChevronDownSVG } from '@snack-uikit/icons';
5
+ import { TEST_IDS } from '../../testIds';
6
+ import styles from './styles.module.css';
7
+ export function CollapseBlockHeaderContainer({ children, toggleExpanded, expanded, actions, }) {
8
+ const functionLayoutRef = useRef(null);
9
+ const [width, setWidth] = useState('0px');
10
+ useEffect(() => {
11
+ setWidth(() => {
12
+ if (functionLayoutRef.current) {
13
+ return getComputedStyle(functionLayoutRef.current, null).getPropertyValue('width');
14
+ }
15
+ return '0px';
16
+ });
17
+ }, [functionLayoutRef]);
18
+ return (
19
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
20
+ _jsxs("div", Object.assign({ className: styles.header, "data-test-id": TEST_IDS.header, onClick: toggleExpanded }, { children: [_jsx("div", Object.assign({ className: styles.text, style: { '--width': width } }, { children: children })), _jsxs("div", Object.assign({ className: styles.functionLayout, ref: functionLayoutRef }, { children: [actions, _jsx(ButtonFunction, { className: styles.button, "data-expanded": expanded || undefined, icon: _jsx(ChevronDownSVG, {}), size: ButtonFunction.sizes.Xs, "data-test-id": TEST_IDS.chevron })] }))] })));
21
+ }
@@ -0,0 +1 @@
1
+ export * from './CollapseBlockHeaderContainer';
@@ -0,0 +1 @@
1
+ export * from './CollapseBlockHeaderContainer';
@@ -0,0 +1,31 @@
1
+ .button[data-expanded] svg{
2
+ transform:rotate(180deg);
3
+ }
4
+
5
+ .header{
6
+ gap:var(--space-accordion-collapse-block-title-gap, 16px);
7
+ cursor:pointer;
8
+ display:flex;
9
+ align-items:flex-start;
10
+ justify-content:space-between;
11
+ margin:calc(0px - var(--accordion-header-padding-vertical, 0px)) calc(0px - var(--accordion-header-padding-horizontal, 0px));
12
+ padding:var(--accordion-header-padding-vertical, 0px) var(--accordion-header-padding-horizontal, 0px);
13
+ }
14
+ .header > *{
15
+ cursor:pointer;
16
+ }
17
+ .header:hover .button span{
18
+ color:var(--sys-neutral-accent-hovered, #666666);
19
+ }
20
+
21
+ .text{
22
+ display:flex;
23
+ flex-direction:column;
24
+ max-width:calc(100% - var(--width, 0px) - var(--space-accordion-collapse-block-title-gap, 16px));
25
+ }
26
+
27
+ .functionLayout{
28
+ gap:var(--space-accordion-collapse-block-title-function-layout, 8px);
29
+ display:flex;
30
+ flex-shrink:0;
31
+ }
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ import { WithSupportProps } from '@snack-uikit/utils';
3
+ export type CollapseBlockPrivateProps = WithSupportProps<{
4
+ children: ReactNode;
5
+ header: ReactNode;
6
+ expanded: boolean;
7
+ className?: string;
8
+ }>;
9
+ export declare function CollapseBlockPrivate({ children, expanded, className, header, ...rest }: CollapseBlockPrivateProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,22 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import cn from 'classnames';
14
+ import { extractSupportProps } from '@snack-uikit/utils';
15
+ import { TEST_IDS } from '../../testIds';
16
+ import styles from './styles.module.css';
17
+ export function CollapseBlockPrivate(_a) {
18
+ var { children, expanded, className, header } = _a, rest = __rest(_a, ["children", "expanded", "className", "header"]);
19
+ return (_jsxs("div", Object.assign({ className: cn(styles.accordion, className),
20
+ // eslint-disable-next-line jsx-a11y/aria-role
21
+ role: 'accordion', "aria-expanded": expanded }, extractSupportProps(rest), { children: [header, _jsx("div", Object.assign({ className: styles.contentWrapper, "aria-hidden": !expanded, "data-test-id": TEST_IDS.content }, { children: _jsx("div", Object.assign({ className: styles.content, "data-content": true }, { children: children })) }))] })));
22
+ }
@@ -0,0 +1 @@
1
+ export * from './CollapseBlockPrivate';
@@ -0,0 +1 @@
1
+ export * from './CollapseBlockPrivate';
@@ -0,0 +1,38 @@
1
+ .accordion{
2
+ display:flex;
3
+ flex-direction:column;
4
+ box-sizing:border-box;
5
+ transition:gap 300ms;
6
+ }
7
+ .accordion::-webkit-scrollbar{
8
+ width:0;
9
+ }
10
+ .accordion[aria-expanded=false]{
11
+ gap:0;
12
+ }
13
+
14
+ .contentWrapper{
15
+ display:grid;
16
+ grid-template-rows:0fr;
17
+ box-sizing:border-box;
18
+ width:100%;
19
+ transition:grid-template-rows 300ms;
20
+ }
21
+ .contentWrapper[aria-hidden=true]{
22
+ overflow:hidden;
23
+ }
24
+ .contentWrapper[aria-hidden=false]{
25
+ grid-template-rows:1fr;
26
+ }
27
+ .contentWrapper[aria-hidden=false] > div[data-content]{
28
+ visibility:visible;
29
+ }
30
+
31
+ .content{
32
+ overflow:hidden;
33
+ box-sizing:border-box;
34
+ width:100%;
35
+ min-height:0;
36
+ visibility:hidden;
37
+ transition:visibility 300ms;
38
+ }
@@ -0,0 +1,4 @@
1
+ export * from './CollapseBlockPrivate';
2
+ export * from './CollapseBlockHeader';
3
+ export * from './Accordion';
4
+ export * from './CollapseBlockHeaderContainer';
@@ -0,0 +1,4 @@
1
+ export * from './CollapseBlockPrivate';
2
+ export * from './CollapseBlockHeader';
3
+ export * from './Accordion';
4
+ export * from './CollapseBlockHeaderContainer';
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './types';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './types';
@@ -0,0 +1,11 @@
1
+ export declare const TEST_IDS: {
2
+ accordion: string;
3
+ tooltip: string;
4
+ chevron: string;
5
+ title: string;
6
+ description: string;
7
+ content: string;
8
+ collapseBlock: string;
9
+ header: string;
10
+ actions: string;
11
+ };
@@ -0,0 +1,11 @@
1
+ export const TEST_IDS = {
2
+ accordion: 'accordion',
3
+ tooltip: 'accordion__collapse-block__tooltip',
4
+ chevron: 'accordion__collapse-block__chevron',
5
+ title: 'accordion__collapse-block__title',
6
+ description: 'accordion__collapse-block__description',
7
+ content: 'accordion__collapse-block__content',
8
+ collapseBlock: 'accordion__collapse-block',
9
+ header: 'accordion__collapse-block__header',
10
+ actions: 'accordion__collapse-block__actions',
11
+ };
@@ -0,0 +1,39 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ import { ToggleGroup } from '@snack-uikit/toggles';
3
+ import { WithSupportProps } from '@snack-uikit/utils';
4
+ export type CollapseBlockProps = WithSupportProps<{
5
+ /** Уникальный id блока */
6
+ id: string;
7
+ /** Заголовок */
8
+ header: ReactNode;
9
+ /** Дополнительные действия */
10
+ actions?: ReactNode;
11
+ /** Вложенный контент */
12
+ children: ReactNode;
13
+ /** CSS-класс */
14
+ className?: string;
15
+ }>;
16
+ export type AccordionProps = WithSupportProps<{
17
+ /** Вложенный контент */
18
+ children: ReactElement<CollapseBlockProps> | ReactElement<CollapseBlockProps>[];
19
+ /** CSS-класс */
20
+ className?: string;
21
+ }> & ({
22
+ /** Начальное состояние */
23
+ expandedDefault?: string;
24
+ /** Controlled состояние */
25
+ expanded?: string;
26
+ /** Controlled обработчик измения состояния */
27
+ onExpandedChange?(value: (string | undefined) | string): void;
28
+ /** Режим работы аккордиона */
29
+ selectionMode?: typeof ToggleGroup.selectionModes.Single;
30
+ } | {
31
+ /** Начальное состояние */
32
+ expandedDefault?: string[];
33
+ /** Controlled состояние */
34
+ expanded?: string[];
35
+ /** Controlled обработчик измения состояния */
36
+ onExpandedChange?(value: (string[] | undefined) | string[]): void;
37
+ /** Режим работы аккордиона */
38
+ selectionMode: typeof ToggleGroup.selectionModes.Multiple;
39
+ });
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@snack-uikit/accordion",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "title": "Accordion",
7
+ "version": "0.3.4-preview-85c5f47b.0",
8
+ "sideEffects": [
9
+ "*.css",
10
+ "*.woff",
11
+ "*.woff2"
12
+ ],
13
+ "description": "",
14
+ "main": "./dist/index.js",
15
+ "module": "./dist/index.js",
16
+ "homepage": "https://github.com/cloud-ru-tech/snack-uikit/tree/master/packages/accordion",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/cloud-ru-tech/snack-uikit.git",
20
+ "directory": "packages/accordion"
21
+ },
22
+ "author": "Nikita Ershov <niershov@cloud.ru>",
23
+ "contributors": [
24
+ "Nikita Ershov <niershov@cloud.ru>"
25
+ ],
26
+ "files": [
27
+ "dist",
28
+ "src",
29
+ "./CHANGELOG.md",
30
+ "./LICENSE"
31
+ ],
32
+ "license": "Apache-2.0",
33
+ "scripts": {},
34
+ "dependencies": {
35
+ "@snack-uikit/button": "0.13.7-preview-85c5f47b.0",
36
+ "@snack-uikit/icons": "0.18.2-preview-85c5f47b.0",
37
+ "@snack-uikit/toggles": "0.7.1-preview-85c5f47b.0",
38
+ "@snack-uikit/tooltip": "0.8.1-preview-85c5f47b.0",
39
+ "@snack-uikit/truncate-string": "0.2.17-preview-85c5f47b.0",
40
+ "@snack-uikit/typography": "0.4.5-preview-85c5f47b.0",
41
+ "@snack-uikit/utils": "2.0.2-preview-85c5f47b.0",
42
+ "classnames": "2.3.2"
43
+ },
44
+ "gitHead": "6a7eef41d780d945f64f791448eaa72b9e0ae72d"
45
+ }
@@ -0,0 +1,13 @@
1
+ import cn from 'classnames';
2
+
3
+ import { ToggleGroup } from '@snack-uikit/toggles';
4
+
5
+ import { Accordion } from '../../helperComponents';
6
+ import { AccordionProps } from '../../types';
7
+ import styles from './styles.module.scss';
8
+
9
+ export function AccordionPrimary({ className, ...rest }: AccordionProps) {
10
+ return <Accordion className={cn(styles.accordionPrimary, className)} {...rest} />;
11
+ }
12
+
13
+ AccordionPrimary.selectionModes = ToggleGroup.selectionModes;
@@ -0,0 +1 @@
1
+ export * from './AccordionPrimary';
@@ -0,0 +1,11 @@
1
+ @import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-accordion';
2
+
3
+ .accordionPrimary {
4
+ --accordion-header-padding-horizontal: #{$space-accordion-collapse-block-primary-horizontal-padding};
5
+ --accordion-header-padding-vertical: #{$space-accordion-collapse-block-primary-vertical-padding};
6
+
7
+ @include composite-var($accordion-primary);
8
+
9
+ display: flex;
10
+ flex-direction: column;
11
+ }
@@ -0,0 +1,13 @@
1
+ import cn from 'classnames';
2
+
3
+ import { ToggleGroup } from '@snack-uikit/toggles';
4
+
5
+ import { Accordion } from '../../helperComponents';
6
+ import { AccordionProps } from '../../types';
7
+ import styles from './styles.module.scss';
8
+
9
+ export function AccordionSecondary({ className, ...rest }: AccordionProps) {
10
+ return <Accordion className={cn(styles.accordionSecondary, className)} {...rest} />;
11
+ }
12
+
13
+ AccordionSecondary.selectionModes = ToggleGroup.selectionModes;
@@ -0,0 +1 @@
1
+ export * from './AccordionSecondary';
@@ -0,0 +1,11 @@
1
+ @import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-accordion';
2
+
3
+ .accordionSecondary {
4
+ --accordion-header-padding-horizontal: #{$space-accordion-collapse-block-secondary-horizontal-padding};
5
+ --accordion-header-padding-vertical: #{$space-accordion-collapse-block-secondary-vertical-padding};
6
+
7
+ @include composite-var($accordion-secondary);
8
+
9
+ display: flex;
10
+ flex-direction: column;
11
+ }
@@ -0,0 +1,27 @@
1
+ import cn from 'classnames';
2
+
3
+ import { useToggleGroup } from '@snack-uikit/toggles';
4
+ import { extractSupportProps } from '@snack-uikit/utils';
5
+
6
+ import { CollapseBlockHeaderContainer, CollapseBlockPrivate } from '../../helperComponents';
7
+ import { CollapseBlockProps } from '../../types';
8
+ import styles from './styles.module.scss';
9
+
10
+ export function CollapseBlockPrimary({ id, header, children, actions, className, ...rest }: CollapseBlockProps) {
11
+ const { isChecked: isExpanded, handleClick: handleExpandedChange } = useToggleGroup({ value: id });
12
+
13
+ return (
14
+ <CollapseBlockPrivate
15
+ className={cn(styles.container, className)}
16
+ header={
17
+ <CollapseBlockHeaderContainer expanded={isExpanded} toggleExpanded={handleExpandedChange} actions={actions}>
18
+ {header}
19
+ </CollapseBlockHeaderContainer>
20
+ }
21
+ expanded={isExpanded}
22
+ {...extractSupportProps(rest)}
23
+ >
24
+ {children}
25
+ </CollapseBlockPrivate>
26
+ );
27
+ }
@@ -0,0 +1 @@
1
+ export * from './CollapseBlockPrimary';
@@ -0,0 +1,14 @@
1
+ @import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-accordion';
2
+
3
+ .container {
4
+ @include composite-var($collapse-block-container-primary);
5
+
6
+ max-width: 100%;
7
+ background-color: $sys-neutral-background1-level;
8
+
9
+ &:focus-within,
10
+ &:hover{
11
+ background-color: $sys-neutral-background2-level;
12
+ box-shadow: $box-shadow-elevation-level2;
13
+ }
14
+ }
@@ -0,0 +1,27 @@
1
+ import cn from 'classnames';
2
+
3
+ import { useToggleGroup } from '@snack-uikit/toggles';
4
+ import { extractSupportProps } from '@snack-uikit/utils';
5
+
6
+ import { CollapseBlockHeaderContainer, CollapseBlockPrivate } from '../../helperComponents';
7
+ import { CollapseBlockProps } from '../../types';
8
+ import styles from './styles.module.scss';
9
+
10
+ export function CollapseBlockSecondary({ header, children, id, actions, className, ...rest }: CollapseBlockProps) {
11
+ const { isChecked: isExpanded, handleClick: handleExpandedChange } = useToggleGroup({ value: id });
12
+
13
+ return (
14
+ <CollapseBlockPrivate
15
+ className={cn(styles.container, className)}
16
+ header={
17
+ <CollapseBlockHeaderContainer expanded={isExpanded} toggleExpanded={handleExpandedChange} actions={actions}>
18
+ {header}
19
+ </CollapseBlockHeaderContainer>
20
+ }
21
+ expanded={isExpanded}
22
+ {...extractSupportProps(rest)}
23
+ >
24
+ {children}
25
+ </CollapseBlockPrivate>
26
+ );
27
+ }
@@ -0,0 +1 @@
1
+ export * from './CollapseBlockSecondary';
@@ -0,0 +1,18 @@
1
+ @import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-accordion';
2
+
3
+ .container {
4
+ @include composite-var($collapse-block-container-secondary);
5
+
6
+ box-sizing: border-box;
7
+ max-width: 100%;
8
+
9
+ border-color: $sys-neutral-decor-default;
10
+ border-style: solid;
11
+ border-top: 0;
12
+ border-right: 0;
13
+ border-left: 0;
14
+
15
+ &:hover {
16
+ border-color: $sys-neutral-accent-hovered;
17
+ }
18
+ }
@@ -0,0 +1,21 @@
1
+ import { CollapseBlockHeader } from '../helperComponents';
2
+ import { AccordionPrimary as AccordionPrimaryComponent } from './AccordionPrimary';
3
+ import { AccordionSecondary as AccordionSecondaryComponent } from './AccordionSecondary';
4
+ import { CollapseBlockPrimary } from './CollapseBlockPrimary';
5
+ import { CollapseBlockSecondary } from './CollapseBlockSecondary';
6
+
7
+ export const AccordionPrimary = AccordionPrimaryComponent as typeof AccordionPrimaryComponent & {
8
+ CollapseBlock: typeof CollapseBlockPrimary;
9
+ CollapseBlockHeader: typeof CollapseBlockHeader;
10
+ };
11
+
12
+ AccordionPrimary.CollapseBlock = CollapseBlockPrimary;
13
+ AccordionPrimary.CollapseBlockHeader = CollapseBlockHeader;
14
+
15
+ export const AccordionSecondary = AccordionSecondaryComponent as typeof AccordionSecondaryComponent & {
16
+ CollapseBlock: typeof CollapseBlockSecondary;
17
+ CollapseBlockHeader: typeof CollapseBlockHeader;
18
+ };
19
+
20
+ AccordionSecondary.CollapseBlock = CollapseBlockSecondary;
21
+ AccordionSecondary.CollapseBlockHeader = CollapseBlockHeader;
@@ -0,0 +1,29 @@
1
+ import { ToggleGroup } from '@snack-uikit/toggles';
2
+ import { extractSupportProps } from '@snack-uikit/utils';
3
+
4
+ import { AccordionProps } from '../../types';
5
+
6
+ export function Accordion({
7
+ children,
8
+ expanded,
9
+ onExpandedChange,
10
+ expandedDefault,
11
+ selectionMode = ToggleGroup.selectionModes.Single,
12
+ className,
13
+ ...rest
14
+ }: AccordionProps) {
15
+ return (
16
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
17
+ // @ts-ignore
18
+ <ToggleGroup
19
+ value={expanded}
20
+ defaultValue={expandedDefault}
21
+ onChange={onExpandedChange}
22
+ selectionMode={selectionMode}
23
+ >
24
+ <div className={className} {...extractSupportProps(rest)}>
25
+ {children}
26
+ </div>
27
+ </ToggleGroup>
28
+ );
29
+ }
@@ -0,0 +1 @@
1
+ export * from './Accordion';
@@ -0,0 +1,35 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ import { QuestionTooltip } from '@snack-uikit/tooltip';
4
+ import { TruncateString } from '@snack-uikit/truncate-string';
5
+ import { Typography } from '@snack-uikit/typography';
6
+ import { WithSupportProps } from '@snack-uikit/utils';
7
+
8
+ import { TEST_IDS } from '../../testIds';
9
+ import styles from './styles.module.scss';
10
+
11
+ export type CollapseBlockHeaderProps = WithSupportProps<{
12
+ title: string;
13
+ description?: string;
14
+ tip?: ReactNode;
15
+ }>;
16
+
17
+ export function CollapseBlockHeader({ title, description, tip }: CollapseBlockHeaderProps) {
18
+ return (
19
+ <>
20
+ <div className={styles.headline}>
21
+ <Typography.SansTitleM className={styles.title} data-test-id={TEST_IDS.title}>
22
+ <TruncateString text={title} maxLines={1} />
23
+ </Typography.SansTitleM>
24
+
25
+ {tip && <QuestionTooltip size={QuestionTooltip.sizes.S} tip={tip} triggerDataTestId={TEST_IDS.tooltip} />}
26
+ </div>
27
+
28
+ {description && (
29
+ <Typography.SansBodyM className={styles.subtitle} data-test-id={TEST_IDS.description}>
30
+ <TruncateString text={description} maxLines={2} />
31
+ </Typography.SansBodyM>
32
+ )}
33
+ </>
34
+ );
35
+ }
@@ -0,0 +1 @@
1
+ export * from './CollapseBlockHeader';
@@ -0,0 +1,19 @@
1
+ @import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-accordion';
2
+
3
+ .headline {
4
+ @include composite-var($collapse-block-container-header-headline);
5
+
6
+ display: flex;
7
+ align-items: center;
8
+ max-width: 100%;
9
+ }
10
+
11
+ .title {
12
+ max-width: 100%;
13
+ color: $sys-neutral-text-main;
14
+ }
15
+
16
+ .subtitle {
17
+ max-width: 100%;
18
+ color: $sys-neutral-text-support;
19
+ }
@@ -0,0 +1,56 @@
1
+ import { ReactNode, useEffect, useRef, useState } from 'react';
2
+
3
+ import { ButtonFunction } from '@snack-uikit/button';
4
+ import { ChevronDownSVG } from '@snack-uikit/icons';
5
+
6
+ import { TEST_IDS } from '../../testIds';
7
+ import styles from './styles.module.scss';
8
+
9
+ export type CollapseBlockHeaderContainerProps = {
10
+ children: ReactNode;
11
+ toggleExpanded(): void;
12
+ expanded: boolean;
13
+ actions?: ReactNode;
14
+ };
15
+
16
+ export function CollapseBlockHeaderContainer({
17
+ children,
18
+ toggleExpanded,
19
+ expanded,
20
+ actions,
21
+ }: CollapseBlockHeaderContainerProps) {
22
+ const functionLayoutRef = useRef<HTMLDivElement>(null);
23
+
24
+ const [width, setWidth] = useState<string>('0px');
25
+
26
+ useEffect(() => {
27
+ setWidth(() => {
28
+ if (functionLayoutRef.current) {
29
+ return getComputedStyle(functionLayoutRef.current, null).getPropertyValue('width');
30
+ }
31
+
32
+ return '0px';
33
+ });
34
+ }, [functionLayoutRef]);
35
+
36
+ return (
37
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
38
+ <div className={styles.header} data-test-id={TEST_IDS.header} onClick={toggleExpanded}>
39
+ <div className={styles.text} style={{ '--width': width }}>
40
+ {children}
41
+ </div>
42
+
43
+ <div className={styles.functionLayout} ref={functionLayoutRef}>
44
+ {actions}
45
+
46
+ <ButtonFunction
47
+ className={styles.button}
48
+ data-expanded={expanded || undefined}
49
+ icon={<ChevronDownSVG />}
50
+ size={ButtonFunction.sizes.Xs}
51
+ data-test-id={TEST_IDS.chevron}
52
+ />
53
+ </div>
54
+ </div>
55
+ );
56
+ }
@@ -0,0 +1 @@
1
+ export * from './CollapseBlockHeaderContainer';