fix: update mobile metric cards with proper 500-range vibrant colors matching admin dashboard
This commit is contained in:
parent
e4eadc858c
commit
71a05c51bf
@ -10,42 +10,78 @@ interface MetricProps {
|
|||||||
change: string;
|
change: string;
|
||||||
trend: 'up' | 'down';
|
trend: 'up' | 'down';
|
||||||
icon: string;
|
icon: string;
|
||||||
colors: string[];
|
colorScheme: 'blue' | 'green' | 'purple' | 'orange';
|
||||||
}
|
}
|
||||||
|
|
||||||
const MetricCard: React.FC<MetricProps> = ({ title, value, change, trend, icon, colors }) => {
|
const getColorScheme = (colorScheme: 'blue' | 'green' | 'purple' | 'orange') => {
|
||||||
|
const schemes = {
|
||||||
|
blue: {
|
||||||
|
colors: ['#3b82f6', '#06b6d4'],
|
||||||
|
text: '#ffffff',
|
||||||
|
badge: '#dbeafe',
|
||||||
|
badgeText: '#1e40af',
|
||||||
|
icon: '#60a5fa',
|
||||||
|
},
|
||||||
|
green: {
|
||||||
|
colors: ['#10b981', '#14b8a6'],
|
||||||
|
text: '#ffffff',
|
||||||
|
badge: '#dcfce7',
|
||||||
|
badgeText: '#047857',
|
||||||
|
icon: '#34d399',
|
||||||
|
},
|
||||||
|
purple: {
|
||||||
|
colors: ['#a855f7', '#3b82f6'],
|
||||||
|
text: '#ffffff',
|
||||||
|
badge: '#e9d5ff',
|
||||||
|
badgeText: '#6b21a8',
|
||||||
|
icon: '#c084fc',
|
||||||
|
},
|
||||||
|
orange: {
|
||||||
|
colors: ['#f97316', '#ef4444'],
|
||||||
|
text: '#ffffff',
|
||||||
|
badge: '#fed7aa',
|
||||||
|
badgeText: '#92400e',
|
||||||
|
icon: '#fb923c',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return schemes[colorScheme];
|
||||||
|
};
|
||||||
|
|
||||||
|
const MetricCard: React.FC<MetricProps> = ({ title, value, change, trend, icon, colorScheme }) => {
|
||||||
|
const colors = getColorScheme(colorScheme);
|
||||||
const isPositive = trend === 'up';
|
const isPositive = trend === 'up';
|
||||||
const changeColor = isPositive ? '#10b981' : '#ef4444';
|
|
||||||
const trendIcon = isPositive ? 'arrow-up' : 'arrow-down';
|
const trendIcon = isPositive ? 'arrow-up' : 'arrow-down';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LinearGradient
|
<LinearGradient
|
||||||
colors={colors}
|
colors={colors.colors as any}
|
||||||
start={{ x: 0, y: 0 }}
|
start={{ x: 0, y: 0 }}
|
||||||
end={{ x: 1, y: 1 }}
|
end={{ x: 1, y: 1 }}
|
||||||
style={styles.card}
|
style={styles.card}
|
||||||
>
|
>
|
||||||
<View style={styles.cardContent}>
|
<View style={styles.cardContent}>
|
||||||
<View style={styles.iconContainer}>
|
<View style={styles.header}>
|
||||||
<Ionicons name={icon as any} size={24} color="#fff" />
|
<Text style={[styles.label, { color: colors.text }]}>{title}</Text>
|
||||||
|
<View style={[styles.iconContainer, { backgroundColor: colors.icon + '40' }]}>
|
||||||
|
<Ionicons name={icon as any} size={20} color={colors.text} />
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.info}>
|
<Text style={[styles.value, { color: colors.text }]}>{value}</Text>
|
||||||
<Text style={styles.label}>{title}</Text>
|
|
||||||
<Text style={styles.value}>{value}</Text>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<View style={styles.changeContainer}>
|
<View style={styles.changeContainer}>
|
||||||
<View style={[styles.trendBadge, { backgroundColor: changeColor }]}>
|
<View style={[styles.trendBadge, { backgroundColor: colors.badge }]}>
|
||||||
<Ionicons
|
<Ionicons
|
||||||
name={trendIcon}
|
name={trendIcon}
|
||||||
size={12}
|
size={12}
|
||||||
color="#fff"
|
color={colors.badgeText}
|
||||||
style={{ marginRight: 4 }}
|
style={{ marginRight: 4 }}
|
||||||
/>
|
/>
|
||||||
<Text style={styles.changeText}>{change}</Text>
|
<Text style={[styles.changeText, { color: colors.badgeText, fontWeight: '700' }]}>
|
||||||
|
{trend === 'up' ? '↑' : '↓'} {change}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.compareText}>vs month</Text>
|
<Text style={[styles.compareText, { color: colors.text }]}>vs month</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</LinearGradient>
|
</LinearGradient>
|
||||||
@ -60,7 +96,7 @@ export const PerformanceMetrics: React.FC = () => {
|
|||||||
change: '+12%',
|
change: '+12%',
|
||||||
trend: 'up',
|
trend: 'up',
|
||||||
icon: 'people',
|
icon: 'people',
|
||||||
colors: ['#1e40af', '#0369a1'],
|
colorScheme: 'blue',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Active Clients',
|
title: 'Active Clients',
|
||||||
@ -68,7 +104,7 @@ export const PerformanceMetrics: React.FC = () => {
|
|||||||
change: '+5%',
|
change: '+5%',
|
||||||
trend: 'up',
|
trend: 'up',
|
||||||
icon: 'person-add',
|
icon: 'person-add',
|
||||||
colors: ['#065f46', '#0d9488'],
|
colorScheme: 'green',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Revenue',
|
title: 'Revenue',
|
||||||
@ -76,7 +112,7 @@ export const PerformanceMetrics: React.FC = () => {
|
|||||||
change: '0%',
|
change: '0%',
|
||||||
trend: 'down',
|
trend: 'down',
|
||||||
icon: 'wallet',
|
icon: 'wallet',
|
||||||
colors: ['#6b21a8', '#1e40af'],
|
colorScheme: 'purple',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Growth',
|
title: 'Growth',
|
||||||
@ -84,7 +120,7 @@ export const PerformanceMetrics: React.FC = () => {
|
|||||||
change: '-2%',
|
change: '-2%',
|
||||||
trend: 'down',
|
trend: 'down',
|
||||||
icon: 'trending-up',
|
icon: 'trending-up',
|
||||||
colors: ['#9a3412', '#dc2626'],
|
colorScheme: 'orange',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -116,7 +152,7 @@ const styles = StyleSheet.create({
|
|||||||
title: {
|
title: {
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: '600',
|
fontWeight: '600',
|
||||||
color: theme.colors.gray600,
|
color: '#4b5563',
|
||||||
letterSpacing: 0.3,
|
letterSpacing: 0.3,
|
||||||
},
|
},
|
||||||
metricsGrid: {
|
metricsGrid: {
|
||||||
@ -131,61 +167,54 @@ const styles = StyleSheet.create({
|
|||||||
card: {
|
card: {
|
||||||
borderRadius: 20,
|
borderRadius: 20,
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
elevation: 5,
|
elevation: 8,
|
||||||
shadowColor: '#000',
|
shadowColor: '#000',
|
||||||
shadowOffset: { width: 0, height: 4 },
|
shadowOffset: { width: 0, height: 4 },
|
||||||
shadowOpacity: 0.15,
|
shadowOpacity: 0.2,
|
||||||
shadowRadius: 12,
|
shadowRadius: 12,
|
||||||
},
|
},
|
||||||
cardContent: {
|
cardContent: {
|
||||||
padding: 16,
|
padding: 16,
|
||||||
minHeight: 140,
|
minHeight: 160,
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
},
|
},
|
||||||
iconContainer: {
|
iconContainer: {
|
||||||
width: 40,
|
width: 36,
|
||||||
height: 40,
|
height: 36,
|
||||||
borderRadius: 12,
|
borderRadius: 10,
|
||||||
backgroundColor: 'rgba(255, 255, 255, 0.3)',
|
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
marginBottom: 12,
|
|
||||||
},
|
|
||||||
info: {
|
|
||||||
marginBottom: 12,
|
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
fontSize: 12,
|
fontSize: 11,
|
||||||
fontWeight: '600',
|
fontWeight: '700',
|
||||||
color: '#fff',
|
letterSpacing: 0.6,
|
||||||
letterSpacing: 0.5,
|
marginBottom: 12,
|
||||||
marginBottom: 6,
|
|
||||||
textTransform: 'uppercase',
|
textTransform: 'uppercase',
|
||||||
},
|
},
|
||||||
value: {
|
value: {
|
||||||
fontSize: 24,
|
fontSize: 28,
|
||||||
fontWeight: '800',
|
fontWeight: '800',
|
||||||
color: '#fff',
|
marginBottom: 12,
|
||||||
},
|
},
|
||||||
changeContainer: {
|
changeContainer: {
|
||||||
alignItems: 'flex-start',
|
alignItems: 'flex-start',
|
||||||
},
|
},
|
||||||
trendBadge: {
|
trendBadge: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
paddingHorizontal: 10,
|
paddingHorizontal: 8,
|
||||||
paddingVertical: 4,
|
paddingVertical: 4,
|
||||||
borderRadius: 8,
|
borderRadius: 6,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
marginBottom: 4,
|
marginBottom: 6,
|
||||||
},
|
},
|
||||||
changeText: {
|
changeText: {
|
||||||
fontSize: 12,
|
fontSize: 11,
|
||||||
fontWeight: '700',
|
fontWeight: '700',
|
||||||
color: '#fff',
|
|
||||||
},
|
},
|
||||||
compareText: {
|
compareText: {
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
color: '#fff',
|
|
||||||
fontWeight: '500',
|
fontWeight: '500',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user