New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@invisionag/iris-react-accordion

Package Overview
Dependencies
Maintainers
12
Versions
166
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@invisionag/iris-react-accordion - npm Package Compare versions

Comparing version 1.1.9 to 1.2.0

styles.js

73

index.js
// @flow
import React from 'react';
import type { Children } from 'react';
import classnames from 'classnames';
import type { Children } from 'react';
import styles from './styles.scss';
import {
animationDuration,
StyledAccordion,
StyledHeaderButton,
StyledInnerAccordion,
StyledOuterAccordion,
} from './styles';

@@ -33,2 +39,4 @@ type Jsx = string | React$Element<any> | number | null;

class Accordion extends React.Component<DefaultProps, Props, State> {
ref: HTMLElement;
static defaultProps = {

@@ -62,3 +70,3 @@ startOpen: false,

})),
parseInt(styles.animationduration, 10),
parseInt(open ? animationDuration : 0, 10),
);

@@ -95,3 +103,3 @@ };

) : (
<button
<StyledHeaderButton
className="iris-accordion__header"

@@ -102,5 +110,24 @@ type="submit"

{this.renderHeader()}
</button>
</StyledHeaderButton>
);
computeHeight = () => {
if (!this.ref) return 0;
// OPEN
if (this.state.open && !this.state.transitioning) {
return 'auto';
}
// OPENING
if (this.state.open && this.state.transitioning) {
return `${this.ref.clientHeight}px`;
}
// CLOSING
if (!this.state.open && this.state.transitioning) {
return `${this.ref.clientHeight}px`;
}
// CLOSED
return 0;
};
render() {

@@ -120,15 +147,31 @@ const {

} = this.props;
const newHeight = this.computeHeight();
const classes = classnames('iris-accordion', className, {
'iris-accordion--is-open': this.state.open,
'iris-accordion--is-transitioning': this.state.transitioning,
});
return (
<div className={classes} {...rest}>
<StyledAccordion
className={classnames('iris-accordion', className)}
{...rest}
>
{this.renderAccordionHeader()}
<div className="iris-accordion__outer">
<div className="iris-accordion__inner">{children}</div>
</div>
</div>
<StyledOuterAccordion
className="iris-accordion__outer"
transitioning={this.state.transitioning}
open={this.state.open}
newHeight={newHeight}
>
<StyledInnerAccordion
className="iris-accordion__inner"
transitioning={this.state.transitioning}
open={this.state.open}
>
<div
ref={ref => {
this.ref = ref;
}}
>
{children}
</div>
</StyledInnerAccordion>
</StyledOuterAccordion>
</StyledAccordion>
);

@@ -135,0 +178,0 @@ }

import React from 'react';
import { mount } from 'enzyme';
import toJson from 'enzyme-to-json';
import Accordion from './';

@@ -9,4 +8,3 @@

const component = mount(<Accordion heading="my heading">test</Accordion>);
const tree = toJson(component);
expect(tree).toMatchSnapshot();
expect(component).toMatchSnapshot();
});

@@ -24,3 +22,3 @@

component
.find('.iris-accordion__header')
.find('button[type="submit"]')
.first()

@@ -46,3 +44,3 @@ .simulate('click', {});

component
.find('.iris-accordion__header')
.find('button[type="submit"]')
.first()

@@ -53,3 +51,3 @@ .text(),

component
.find('.iris-accordion__header')
.find('button[type="submit"]')
.first()

@@ -60,3 +58,3 @@ .simulate('click', {});

component
.find('.iris-accordion__header')
.find('button[type="submit"]')
.first()

@@ -63,0 +61,0 @@ .text(),

{
"name": "@invisionag/iris-react-accordion",
"version": "1.1.9",
"version": "1.2.0",
"main": "index.js",

@@ -8,7 +8,5 @@ "repository": "git@github.com:ivx/iris.git",

"dependencies": {
"@invisionag/iris-colors": "^1.7.4",
"@invisionag/iris-settings": "^1.7.7",
"@invisionag/iris-tools": "^1.6.9",
"classnames": "^2.2.5"
"classnames": "^2.2.5",
"styled-components": "^2.1.2"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc