Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit dca294c

Browse files
authored
fix: background of +/- icon buttons should be transparent (#43)
1 parent 92f0ed3 commit dca294c

File tree

3 files changed

+53
-28
lines changed

3 files changed

+53
-28
lines changed

src/components/ArrayInput.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { IFormtronControl } from '..';
88

99
import { FieldSet } from './FieldSet';
1010
import { useDiagnostics } from './hooks';
11+
import { IconButton } from './IconButton';
1112
import { Label } from './Label';
1213
import { Messages } from './Messages';
1314
import { EasyArray } from './utils/EasyArray';
@@ -38,7 +39,8 @@ export const ArrayInput: React.FunctionComponent<IFormtronControl> = ({
3839
color="rgb(118, 130, 143)"
3940
disabled={disabled}
4041
display="inline-block"
41-
border="transparent"
42+
borderColor="transparent"
43+
backgroundColor="transparent"
4244
onClick={() => onChange(easyArray.append())}
4345
>
4446
<Icon mr={2} icon={faPlus} /> Add Item
@@ -64,24 +66,19 @@ export const ArrayInput: React.FunctionComponent<IFormtronControl> = ({
6466
<Label disabled={disabled}>Add</Label>
6567

6668
<Flex flex={1} width="100%" justifyContent="center" alignItems="center">
67-
<Button
68-
border="transparent"
69-
height="100%"
69+
<IconButton
70+
icon={faPlus}
7071
onClick={() => onChange(easyArray.insert(index + 1))}
7172
disabled={disabled}
72-
>
73-
<Icon icon={faPlus} fontSize="15px" color="rgb(118, 130, 143)" />
74-
</Button>
73+
/>
7574
</Flex>
7675
</Flex>
7776

7877
<Flex flexDirection="column" alignItems="center" ml="10px">
7978
<Label disabled={disabled}>Remove</Label>
8079

8180
<Flex flex={1} width="100%" justifyContent="center" alignItems="center" disabled={disabled}>
82-
<Button border="transparent" height="100%" onClick={() => onChange(easyArray.remove(index))}>
83-
<Icon icon={faTrash} fontSize="15px" color="rgb(118, 130, 143)" />
84-
</Button>
81+
<IconButton icon={faTrash} onClick={() => onChange(easyArray.remove(index))} disabled={disabled} />
8582
</Flex>
8683
</Flex>
8784
</Flex>

src/components/IconButton.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import * as React from 'react';
2+
3+
import { Button, IButton, Icon } from '@stoplight/ui-kit';
4+
5+
import { IconDefinition } from '@fortawesome/free-solid-svg-icons';
6+
7+
interface IIconButton extends IButton {
8+
disabled?: boolean;
9+
onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
10+
icon: IconDefinition;
11+
}
12+
13+
export const IconButton: React.FunctionComponent<IIconButton> = ({ disabled = false, onClick, icon }) => {
14+
return (
15+
<Button
16+
borderColor="transparent"
17+
backgroundColor="transparent"
18+
height="100%"
19+
fontSize="15px"
20+
px={0}
21+
onClick={onClick}
22+
disabled={disabled}
23+
color="rgb(118, 130, 143)"
24+
css={{
25+
':hover': {
26+
backgroundColor: 'transparent',
27+
color: '#1E2537',
28+
},
29+
':active': {
30+
backgroundColor: 'transparent',
31+
fontSize: '17px',
32+
},
33+
}}
34+
>
35+
<Icon icon={icon} />
36+
</Button>
37+
);
38+
};

src/components/ObjectInput.tsx

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { IFormtronControl } from '..';
88

99
import { FieldSet } from './FieldSet';
1010
import { useDiagnostics } from './hooks';
11+
import { IconButton } from './IconButton';
1112
import { Label } from './Label';
1213
import { Messages } from './Messages';
1314
import { Variant } from './types';
@@ -39,12 +40,11 @@ export const ObjectInput: React.FunctionComponent<IFormtronControl> = ({
3940
<Button
4041
fontWeight={800}
4142
fontSize="11px"
42-
my={3}
43-
mx={2}
4443
color="rgb(118, 130, 143)"
4544
disabled={disabled}
4645
display="inline-block"
47-
border="transparent"
46+
borderColor="transparent"
47+
backgroundColor="transparent"
4848
onClick={() => onChange(easyObject.append())}
4949
>
5050
<Icon mr={2} icon={faPlus} /> Add Item
@@ -94,29 +94,19 @@ export const ObjectInput: React.FunctionComponent<IFormtronControl> = ({
9494
<Label disabled={disabled}>Add</Label>
9595

9696
<Flex flex={1} width="100%" justifyContent="center" alignItems="center">
97-
<Button
98-
border="transparent"
99-
height="100%"
100-
disabled={disabled}
97+
<IconButton
98+
icon={faPlus}
10199
onClick={() => onChange(easyObject.insert(index + 1))}
102-
>
103-
<Icon icon={faPlus} fontSize="15px" color="rgb(118, 130, 143)" />
104-
</Button>
100+
disabled={disabled}
101+
/>
105102
</Flex>
106103
</Flex>
107104

108105
<Flex flexDirection="column" alignItems="center" ml="10px">
109106
<Label disabled={disabled}>Remove</Label>
110107

111108
<Flex flex={1} width="100%" justifyContent="center" alignItems="center">
112-
<Button
113-
border="transparent"
114-
height="100%"
115-
disabled={disabled}
116-
onClick={() => onChange(easyObject.remove(index))}
117-
>
118-
<Icon icon={faTrash} fontSize="15px" color="rgb(118, 130, 143)" />
119-
</Button>
109+
<IconButton icon={faTrash} onClick={() => onChange(easyObject.remove(index))} disabled={disabled} />
120110
</Flex>
121111
</Flex>
122112
</Flex>

0 commit comments

Comments
 (0)