Skip to content

Commit 8c88ecf

Browse files
committed
🐛 fix(RN): Model Tag component
1 parent 86d3988 commit 8c88ecf

File tree

1 file changed

+41
-29
lines changed
  • packages/react-native/src/features/ModelTag

1 file changed

+41
-29
lines changed

packages/react-native/src/features/ModelTag/index.tsx

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,55 @@ import { Text, View, type ViewStyle } from 'react-native';
44
import RNModelIcon from '../ModelIcon';
55

66
export interface RNModelTagProps {
7-
model: string;
8-
style?: ViewStyle;
9-
textStyle?: ViewStyle;
10-
type?: 'color' | 'mono';
7+
model: string;
8+
size?: number;
9+
style?: ViewStyle;
10+
textStyle?: ViewStyle;
11+
type?: 'color' | 'mono';
1112
}
1213

13-
const RNModelTag = memo<RNModelTagProps>(({ type = 'mono', model, style, textStyle, ...rest }) => (
14-
<View
14+
const RNModelTag = memo<RNModelTagProps>(
15+
({ type = 'mono', model, size = 12, style, textStyle, ...rest }) => {
16+
// Calculate text size and padding based on icon size
17+
const textSize = Math.max(size * 0.9, 10); // Text slightly smaller than icon, minimum 10
18+
const paddingHorizontal = Math.max(size * 0.67, 8); // Proportional padding, minimum 8
19+
const paddingVertical = Math.max(size * 0.33, 4); // Proportional padding, minimum 4
20+
const borderRadius = Math.max(size, 12); // Proportional border radius, minimum 12
21+
const marginLeft = Math.max(size * 0.33, 4); // Proportional margin, minimum 4
22+
23+
return (
24+
<View
1525
style={[
16-
{
17-
alignItems: 'center',
18-
backgroundColor: '#f5f5f5',
19-
borderRadius: 12,
20-
flexDirection: 'row',
21-
paddingHorizontal: 8,
22-
paddingVertical: 4,
23-
},
24-
style,
26+
{
27+
alignItems: 'center',
28+
backgroundColor: '#f5f5f5',
29+
borderRadius,
30+
flexDirection: 'row',
31+
paddingHorizontal,
32+
paddingVertical,
33+
},
34+
style,
2535
]}
2636
{...rest}
27-
>
28-
<RNModelIcon model={model} size={12} type={type} />
37+
>
38+
<RNModelIcon model={model} size={size} type={type} />
2939
<Text
30-
style={[
31-
{
32-
color: '#666',
33-
fontSize: 12,
34-
marginLeft: 4,
35-
},
36-
textStyle,
37-
]}
40+
style={[
41+
{
42+
color: '#666',
43+
fontSize: textSize,
44+
marginLeft,
45+
},
46+
textStyle,
47+
]}
3848
>
39-
{model}
49+
{model}
4050
</Text>
41-
</View>
42-
));
51+
</View>
52+
);
53+
},
54+
);
4355

4456
RNModelTag.displayName = 'RNModelTag';
4557

46-
export default RNModelTag;
58+
export default RNModelTag;

0 commit comments

Comments
 (0)