acupedia-mobile-ui/src/features/content/renderers/shared/ChipList.tsx

36 lines
1.0 KiB
TypeScript

import React from "react";
import { StyleSheet, Text, View } from "react-native";
const chipTones = [
{ bg: "#EEF7F1", border: "#D5E8DB", text: "#35664E" },
{ bg: "#EFF5FA", border: "#D7E5F0", text: "#3C617E" },
{ bg: "#FAF4EB", border: "#EEDFC9", text: "#805C31" },
];
export function ChipList({ items }: { items: string[] }) {
if (!items.length) return null;
return (
<View style={styles.root}>
{items.map((item, index) => {
const tone = chipTones[index % chipTones.length];
return (
<View key={item} style={[styles.chip, { backgroundColor: tone.bg, borderColor: tone.border }]}>
<Text style={[styles.text, { color: tone.text }]}>{item}</Text>
</View>
);
})}
</View>
);
}
const styles = StyleSheet.create({
root: { flexDirection: "row", flexWrap: "wrap", gap: 8 },
chip: {
borderWidth: 1,
borderRadius: 999,
paddingHorizontal: 11,
paddingVertical: 7,
},
text: { fontSize: 13, lineHeight: 18, fontWeight: "600" },
});