Badge.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import * as React from "react";
  2. import { Icon, useTheme, Text, Button } from "@ui-kitten/components";
  3. export default function Badge(props) {
  4. const theme = useTheme();
  5. const useColor = React.useMemo(() => {
  6. if (props.status) {
  7. return theme["text-" + props.status + "-color"];
  8. } else {
  9. return theme["text-danger-color"];
  10. }
  11. }, [props.status]);
  12. if (props.appearance == "fill") {
  13. return (
  14. <Button
  15. appearance='badge'
  16. status={props.status || "primary"}
  17. style={{
  18. marginRight: props.right || 0,
  19. marginBottom: props.bottom || 0,
  20. flexShrink: 0,
  21. }}
  22. >
  23. {props.children}
  24. </Button>
  25. );
  26. } else {
  27. return (
  28. <Text
  29. category='h1'
  30. status={props.status || "danger"}
  31. style={[
  32. {
  33. borderWidth: props.appearance == "ghost" ? 0 : 1,
  34. borderRadius: 20,
  35. paddingHorizontal: props.appearance == "ghost" ? 0 : 3,
  36. borderColor: useColor,
  37. },
  38. props.style,
  39. ]}
  40. >
  41. {props.children}
  42. </Text>
  43. );
  44. }
  45. }