Skip to content

Commit eedc2b4

Browse files
author
ignaciosantise
committed
chore: code improvements
1 parent 86f6e97 commit eedc2b4

File tree

2 files changed

+44
-18
lines changed

2 files changed

+44
-18
lines changed

packages/ui/src/composites/wui-button/styles.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ export const getThemedTextStyle = (
3838
disabled?: boolean
3939
): StyleProp<any> => {
4040
if (disabled) {
41-
return variant === 'fill'
42-
? { color: theme['gray-glass-020'] }
43-
: { color: theme['gray-glass-020'] };
41+
return { color: theme['gray-glass-020'] };
4442
}
4543

4644
return variant === 'fill'

packages/ui/src/composites/wui-network-button/index.tsx

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,52 @@ export function NetworkButton({
4747
onPressOut={setStartValue}
4848
disabled={disabled}
4949
>
50-
{loading ? (
51-
<LoadingSpinner size="md" style={styles.loader} />
52-
) : imageSrc ? (
53-
<Image
54-
style={[
55-
styles.image,
56-
{ borderColor: Theme['gray-glass-005'] },
57-
disabled && styles.imageDisabled
58-
]}
59-
source={imageSrc}
60-
headers={imageHeaders}
61-
/>
62-
) : (
63-
<IconBox icon="networkPlaceholder" background iconColor={textColor} size="sm" />
64-
)}
50+
<LoaderComponent loading={loading} />
51+
<ImageComponent
52+
loading={loading}
53+
disabled={disabled}
54+
imageSrc={imageSrc}
55+
imageHeaders={imageHeaders}
56+
borderColor={Theme['gray-glass-005']}
57+
/>
6558
<Text style={styles.text} variant="paragraph-600" color={textColor}>
6659
{children}
6760
</Text>
6861
</AnimatedPressable>
6962
);
7063
}
64+
65+
function LoaderComponent({ loading }: { loading?: boolean }) {
66+
if (!loading) return null;
67+
68+
return <LoadingSpinner size="md" style={styles.loader} />;
69+
}
70+
71+
function ImageComponent({
72+
loading,
73+
disabled,
74+
imageSrc,
75+
imageHeaders,
76+
borderColor
77+
}: {
78+
loading?: boolean;
79+
disabled?: boolean;
80+
imageSrc?: string;
81+
imageHeaders?: Record<string, string>;
82+
borderColor: string;
83+
}) {
84+
if (loading) return null;
85+
86+
const textColor = disabled ? 'fg-300' : 'fg-100';
87+
if (!imageSrc) {
88+
return <IconBox icon="networkPlaceholder" background iconColor={textColor} size="sm" />;
89+
}
90+
91+
return (
92+
<Image
93+
style={[styles.image, { borderColor }, disabled && styles.imageDisabled]}
94+
source={imageSrc}
95+
headers={imageHeaders}
96+
/>
97+
);
98+
}

0 commit comments

Comments
 (0)