@axinom/mosaic-ui 0.60.0-rc.3 → 0.60.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-ui",
3
- "version": "0.60.0-rc.3",
3
+ "version": "0.60.0",
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": "2aec80d2fa9c0c6fddee8f8e95a3b1f1acbc8e6d"
111
+ "gitHead": "58604ad774aebcf65a42fdb979f780785a86264a"
112
112
  }
@@ -29,13 +29,15 @@
29
29
  }
30
30
 
31
31
  .container {
32
- overflow: hidden;
33
- transition: max-height 200ms cubic-bezier(0.4, 0, 0.2, 1);
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
- .expanded {
37
- border-bottom: var(--accordion-item-border, $accordion-item-border);
38
- margin-top: 1px;
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(`content maxHeight should be 0 when 'isExpanded' is false`, () => {
77
+ it(`should set expanded class when 'isExpanded' is true`, () => {
78
78
  const wrapper = mount(
79
- <AccordionItem header={<b>Item 1</b>} isExpanded={false}>
79
+ <AccordionItem header={<b>Item 1</b>} isExpanded={true}>
80
80
  <div></div>
81
81
  </AccordionItem>,
82
82
  );
83
83
 
84
- const containerStyles = wrapper
85
- .find('.container')
86
- .last()
87
- .prop('style') as React.CSSProperties;
84
+ const expanded = wrapper.find('.expanded');
88
85
 
89
- expect(containerStyles).toEqual({ maxHeight: 0 });
86
+ expect(expanded).toHaveLength(1);
90
87
  });
91
88
 
92
- it(`content maxHeight should be scrollHeight when 'isExpanded' is true`, () => {
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={true}>
91
+ <AccordionItem header={<b>Item 1</b>} isExpanded={false}>
97
92
  <div></div>
98
93
  </AccordionItem>,
99
94
  );
100
95
 
101
- const containerStyles = wrapper
102
- .find('.container')
103
- .last()
104
- .prop('style') as React.CSSProperties;
96
+ const expanded = wrapper.find('.expanded');
105
97
 
106
- expect(containerStyles).toEqual({ maxHeight: 100 });
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, { useEffect, useRef, useState } from '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
- ref={elementRef}
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}