Skip to content

Commit 6edc266

Browse files
committed
Plugin and Collapsable visual updates
1 parent 3b0a4e3 commit 6edc266

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

src/components/Collapsable/__tests__/Collapsable.test.cypress.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('Collapsable test', () => {
2222
);
2323

2424
// check that the component renders correctly in default closed state
25-
cy.get('[data-testid="collapsable-header"]').find('.icon-arrowDown').invoke('attr', 'rotate').should('eq', '0');
25+
cy.get('[data-testid="collapsable-header"]').find('.icon-arrowDown').invoke('attr', 'rotate').should('eq', '-90');
2626
cy.get('[data-testid="collapsable-content"]').not('visbile');
2727

2828
// check that the component renders correctly when opened
@@ -32,15 +32,15 @@ describe('Collapsable test', () => {
3232
cy.get('[data-testid="collapsable-header"]')
3333
.find('.icon-arrowDown')
3434
.invoke('attr', 'rotate')
35-
.should('eq', '180');
35+
.should('eq', '0');
3636
cy.get('[data-testid="collapsable-content"]').should('be.visible');
3737
});
3838

3939
// check that the component renders correctly when closed
4040
cy.get('[data-testid="collapsable-header"]')
4141
.click()
4242
.then(() => {
43-
cy.get('[data-testid="collapsable-header"]').find('.icon-arrowDown').invoke('attr', 'rotate').should('eq', '0');
43+
cy.get('[data-testid="collapsable-header"]').find('.icon-arrowDown').invoke('attr', 'rotate').should('eq', '-90');
4444
cy.get('[data-testid="collapsable-content"]').not('visible');
4545
});
4646
});

src/components/Collapsable/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ const Collapsable: React.FC<CollapsableProps> = ({ children, title, animated = t
4444
}}
4545
data-testid="collapsable-header"
4646
>
47+
<Icon name="arrowDown" rotate={open ? 0 : -90} />
4748
<Title>{title}</Title>
48-
<Icon name="arrowDown" rotate={open ? 180 : 0} />
4949
</CollapsableHeader>
5050

5151
{(animated || open) && (
@@ -94,6 +94,7 @@ const Content = styled.div<{ open: boolean; visible: boolean }>`
9494

9595
const Title = styled.div`
9696
margin-right: 1rem;
97+
margin-left: 0.3rem;
9798
`;
9899

99100
export default Collapsable;

src/components/Icon/index.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,14 @@ interface IconProps {
126126
padRight?: boolean;
127127
spin?: boolean;
128128
title?: string;
129+
visible?: boolean;
129130
onClick?: () => void;
130131
}
131132

132-
const Icon: React.FC<IconProps> = ({ name, size = 'sm', rotate, ...rest }) => {
133+
const Icon: React.FC<IconProps> = ({ name, size = 'sm', visible = true, rotate, ...rest }) => {
133134
const IconComponent = icons[name];
134135
return (
135-
<Wrapper className={`icon icon-${name}`} {...rest} {...{ size, rotate }}>
136+
<Wrapper className={`icon icon-${name}`} {...rest} {...{ size, visible, rotate }}>
136137
<IconComponent />
137138
</Wrapper>
138139
);
@@ -148,9 +149,10 @@ const Wrapper = styled.i<{
148149
padLeft?: boolean;
149150
padRight?: boolean;
150151
title?: string;
152+
visible?: boolean;
151153
}>`
152154
vertical-align: text-top;
153-
display: inline-flex;
155+
display: ${(p) => (p.visible ? 'inline-flex' : 'none')};
154156
align-items: center;
155157
margin: 0;
156158
padding: 0;

src/components/Plugins/PluginGroup.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ const PluginContainer: React.FC<{ plugin: Plugin; children: ReactNode }> = ({ pl
6363
const props = plugin.config.containerProps || {};
6464
if (isCollapsableContainer(plugin.config.container)) {
6565
return (
66-
<Collapsable {...props} title={<PluginHeaderSection name={plugin.config.name} />}>
66+
<Collapsable
67+
{...props}
68+
title={<PluginHeaderSection name={plugin.config.name} showIcon={props.showIcon === 'false' ? false : true} />}
69+
>
6770
{children}
6871
</Collapsable>
6972
);
@@ -85,9 +88,9 @@ const PluginContainer: React.FC<{ plugin: Plugin; children: ReactNode }> = ({ pl
8588
return <>{children}</>;
8689
};
8790

88-
const PluginHeaderSection: React.FC<{ name: string }> = ({ name }) => (
91+
const PluginHeaderSection: React.FC<{ name: string; showIcon?: boolean }> = ({ name, showIcon = true }) => (
8992
<PluginHeader>
90-
<Icon name="plugin" />
93+
<Icon name="plugin" visible={showIcon} />
9194
{name}
9295
</PluginHeader>
9396
);

0 commit comments

Comments
 (0)