@axinom/mosaic-ui 0.59.0 → 0.60.0-rc.4
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/dist/components/Accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
- package/dist/index.es.js +4 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Accordion/AccordionItem/AccordionItem.scss +9 -6
- package/src/components/Accordion/AccordionItem/AccordionItem.spec.tsx +8 -16
- package/src/components/Accordion/AccordionItem/AccordionItem.tsx +2 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.60.0-rc.4",
|
|
4
4
|
"description": "UI components for building Axinom Mosaic applications",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"publishConfig": {
|
|
109
109
|
"access": "public"
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "949fed291c809ae8c58cf5b09771abb397843d25"
|
|
112
112
|
}
|
|
@@ -29,13 +29,15 @@
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
.container {
|
|
32
|
-
|
|
33
|
-
transition:
|
|
34
|
-
|
|
32
|
+
display: grid;
|
|
33
|
+
transition: grid-template-rows 200ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
34
|
+
grid-template-rows: 0fr;
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
&.expanded {
|
|
37
|
+
grid-template-rows: 1fr;
|
|
38
|
+
border-bottom: var(--accordion-item-border, $accordion-item-border);
|
|
39
|
+
margin-top: 1px;
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
.content {
|
|
@@ -47,6 +49,7 @@
|
|
|
47
49
|
$accordion-item-background-color
|
|
48
50
|
);
|
|
49
51
|
color: var(--accordion-item-text-color, $accordion-item-text-color);
|
|
52
|
+
overflow: hidden;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
.button {
|
|
@@ -74,36 +74,28 @@ describe('AccordionItem', () => {
|
|
|
74
74
|
expect(children).toHaveLength(1);
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
it(`
|
|
77
|
+
it(`should set expanded class when 'isExpanded' is true`, () => {
|
|
78
78
|
const wrapper = mount(
|
|
79
|
-
<AccordionItem header={<b>Item 1</b>} isExpanded={
|
|
79
|
+
<AccordionItem header={<b>Item 1</b>} isExpanded={true}>
|
|
80
80
|
<div></div>
|
|
81
81
|
</AccordionItem>,
|
|
82
82
|
);
|
|
83
83
|
|
|
84
|
-
const
|
|
85
|
-
.find('.container')
|
|
86
|
-
.last()
|
|
87
|
-
.prop('style') as React.CSSProperties;
|
|
84
|
+
const expanded = wrapper.find('.expanded');
|
|
88
85
|
|
|
89
|
-
expect(
|
|
86
|
+
expect(expanded).toHaveLength(1);
|
|
90
87
|
});
|
|
91
88
|
|
|
92
|
-
it(`
|
|
93
|
-
jest.spyOn(Element.prototype, 'scrollHeight', 'get').mockReturnValue(100);
|
|
94
|
-
|
|
89
|
+
it(`should not set expanded class when 'isExpanded' is true`, () => {
|
|
95
90
|
const wrapper = mount(
|
|
96
|
-
<AccordionItem header={<b>Item 1</b>} isExpanded={
|
|
91
|
+
<AccordionItem header={<b>Item 1</b>} isExpanded={false}>
|
|
97
92
|
<div></div>
|
|
98
93
|
</AccordionItem>,
|
|
99
94
|
);
|
|
100
95
|
|
|
101
|
-
const
|
|
102
|
-
.find('.container')
|
|
103
|
-
.last()
|
|
104
|
-
.prop('style') as React.CSSProperties;
|
|
96
|
+
const expanded = wrapper.find('.expanded');
|
|
105
97
|
|
|
106
|
-
expect(
|
|
98
|
+
expect(expanded).toHaveLength(0);
|
|
107
99
|
});
|
|
108
100
|
|
|
109
101
|
it('creates a class based off of the className prop', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { Button, ButtonContext } from '../../Buttons';
|
|
4
4
|
import { IconName } from '../../Icons';
|
|
5
5
|
import classes from './AccordionItem.scss';
|
|
@@ -39,15 +39,6 @@ export const AccordionItem: React.FC<AccordionItemProps> = ({
|
|
|
39
39
|
sticky = false,
|
|
40
40
|
className,
|
|
41
41
|
}) => {
|
|
42
|
-
const [scrollHeight, setScrollHeight] = useState<number>(0);
|
|
43
|
-
const elementRef = useRef<HTMLDivElement>(null);
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (elementRef.current) {
|
|
47
|
-
setScrollHeight(elementRef.current.scrollHeight);
|
|
48
|
-
}
|
|
49
|
-
}, [scrollHeight, children]);
|
|
50
|
-
|
|
51
42
|
return (
|
|
52
43
|
<div data-test-id="accordion-item" className={className}>
|
|
53
44
|
<div
|
|
@@ -72,13 +63,7 @@ export const AccordionItem: React.FC<AccordionItemProps> = ({
|
|
|
72
63
|
</div>
|
|
73
64
|
<div
|
|
74
65
|
data-test-id="accordion-item-content"
|
|
75
|
-
|
|
76
|
-
className={
|
|
77
|
-
isExpanded
|
|
78
|
-
? clsx(classes.container, classes.expanded)
|
|
79
|
-
: classes.container
|
|
80
|
-
}
|
|
81
|
-
style={{ maxHeight: isExpanded ? scrollHeight : 0 }}
|
|
66
|
+
className={clsx(classes.container, isExpanded && classes.expanded)}
|
|
82
67
|
>
|
|
83
68
|
<div
|
|
84
69
|
className={classes.content}
|