Skip to content

Commit 277489f

Browse files
committed
Revert "Fix icons getting cut off (#764)"
This reverts commit d015929.
1 parent b02259b commit 277489f

File tree

3 files changed

+5
-32
lines changed

3 files changed

+5
-32
lines changed

packages/core/src/components/Checkbox/Checkbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const Checkbox: React.FC<CheckboxProps & PressableProps & IconSlot> = ({
9292
accessibilityState={{ disabled }}
9393
accessibilityRole="button"
9494
accessibilityLiveRegion="polite"
95-
style={[styles.container, style]}
95+
style={[styles.container, style, { width: size, height: size }]}
9696
>
9797
<Icon
9898
style={styles.icon}

packages/core/src/components/IconButton.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ const IconButton: React.FC<React.PropsWithChildren<Props>> = ({
5252
styles.container,
5353
{
5454
opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
55+
width: size,
56+
height: size,
5557
alignItems: "center",
5658
justifyContent: "center",
5759
},

packages/native/src/components/Icon.tsx

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
StyleProp,
77
ImageStyle,
88
Platform,
9-
LayoutChangeEvent,
109
} from "react-native";
1110

1211
// This must use require to work in both web as a published project and in Snack
@@ -26,16 +25,6 @@ const Icon: React.FC<React.PropsWithChildren<Props>> = ({
2625
style,
2726
...rest
2827
}) => {
29-
const [calculatedIconWidth, setCalculatedIconWidth] =
30-
React.useState<number>();
31-
const [calculatedIconHeight, setCalculatedIconHeight] =
32-
React.useState<number>();
33-
34-
React.useEffect(() => {
35-
setCalculatedIconWidth(undefined);
36-
setCalculatedIconHeight(undefined);
37-
}, [name]);
38-
3928
if (!name) return null;
4029

4130
let iconSet = "MaterialIcons";
@@ -46,26 +35,8 @@ const Icon: React.FC<React.PropsWithChildren<Props>> = ({
4635
const IconSet = VectorIcons[iconSet];
4736

4837
return (
49-
<View
50-
style={[
51-
styles.container,
52-
calculatedIconWidth && calculatedIconHeight
53-
? { width: calculatedIconWidth, height: calculatedIconHeight }
54-
: {},
55-
style,
56-
]}
57-
>
58-
<IconSet
59-
{...rest}
60-
onLayout={(e: LayoutChangeEvent) => {
61-
const layout = e.nativeEvent.layout;
62-
setCalculatedIconWidth(layout.width);
63-
setCalculatedIconHeight(layout.height);
64-
}}
65-
name={name}
66-
color={color}
67-
size={size}
68-
/>
38+
<View style={[styles.container, { width: size, height: size }, style]}>
39+
<IconSet {...rest} name={name} color={color} size={size} />
6940
</View>
7041
);
7142
};

0 commit comments

Comments
 (0)