3.0.0-beta.6 • Published 5 months ago

react-native-body-highlighter v3.0.0-beta.6

Weekly downloads
6
License
MIT
Repository
-
Last release
5 months ago

react-native-body-highlighter

npm Downloads CircleCI

SVG human body parts highlighter for react-native (Expo compatible).

Installation

npm

$ npm install react-native-body-highlighter

yarn

$ yarn add react-native-body-highlighter

Usage

Basic example

import { useState } from "react";
import Body from "react-native-body-highlighter";

export default function App() {
  return (
    <View style={styles.container}>
      <Body
        data={[
          { slug: "chest", intensity: 1 },
          { slug: "abs", intensity: 2 },
        ]}
        gender="female"
        side="front"
        scale={1.7}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});
import { StyleSheet, Switch, Text, View } from "react-native";
import { useState } from "react";
import Body from "react-native-body-highlighter";

export default function App() {
  const [bodyPartSelected, setBodyPartSelected] = useState({
    slug: "biceps",
    intensity: 2,
  });
  const [isBackSideEnabled, setIsBackSideEnabled] = useState(false);
  const [isMale, setIsMale] = useState(true);
  const toggleSwitch = () =>
    setIsBackSideEnabled((previousState) => !previousState);

  const toggleGenderSwitch = () => setIsMale((previousState) => !previousState);

  return (
    <View style={styles.container}>
      <Body
        data={[
          { slug: "chest", intensity: 1 },
          { slug: "abs", intensity: 2 },
          { slug: "upper-back", intensity: 1 },
          { slug: "lower-back", intensity: 2 },
          bodyPartSelected,
        ]}
        onBodyPartPress={(e) =>
          setBodyPartSelected({ slug: e.slug, intensity: 2 })
        }
        gender={isMale ? "male" : "female"}
        side={isBackSideEnabled ? "back" : "front"}
        scale={1.7}
      />
      <View style={styles.switchContainer}>
        <View style={styles.switch}>
          <Text>Side ({isBackSideEnabled ? "Back" : "Front"})</Text>
          <Switch onValueChange={toggleSwitch} value={isBackSideEnabled} />
        </View>
        <View style={styles.switch}>
          <Text>Gender ({isMale ? "Male" : "Female"})</Text>
          <Switch onValueChange={toggleGenderSwitch} value={isMale} />
        </View>
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
  switchContainer: {
    flexDirection: "row",
    gap: 30,
  },
  switch: {
    flex: 1,
    alignItems: "center",
    justifyContent: "center",
  },
});

v3.X.X Props

PropRequiredPurpose
dataYesBodyPartObject[] - Array of BodyPartObject to highlight
onBodyPartPressNoFunc - (bodyPart: BodyPartObject) => {} Callback called when a user tap a body part
colorsNoString[] - Defaults to ['#0984e3', '#74b9ff']
sideNostring - Can be "back" or "front", Defaults to front
genderNostring - Can be "male" or "female", Defaults to male - :warning: Please consider female as a beta work in progress
scaleNoFloat - Defaults to 1

v2.X.X Props

PropRequiredPurpose
dataYes(Array) Array of BodyPartObject to highlight
onMusclePressNo(Func) (bodyPart: BodyPartObject) => {} Callback called when a user tap a body part, disabled if zoomOnPress is set to true
colorsNo(Array) Defaults to ['#0984e3', '#74b9ff']
frontOnlyNo(Boolean) Display only the front, Defaults to false
backOnlyNo(Boolean) Display only the back, Defaults to false
zoomOnPressNo(Boolean) Defaults to false
scaleNo(Float) Defaults to 1

BodyPart object model

  • BodyPartObject : { slug: BodyPartName, intensity: IntensityNumber }

  • BodyPartName : Body part name to highlight (See the list of available body parts below)

  • IntensityNumber : Color intensity (if the colors property is set: from 1 to colors.length + 1. If not, intensity can be 1 or 2)

List of body parts

BodyPartsv2v3Side
trapezius:white_check_mark::white_check_mark:Both
triceps:white_check_mark::white_check_mark:Both
forearm:white_check_mark::white_check_mark:Both
obliques:white_check_mark::white_check_mark:Both
adductors:white_check_mark::white_check_mark:Both
calves:white_check_mark::white_check_mark:Both
head:white_check_mark::white_check_mark:Both
neck:white_check_mark::white_check_mark:Both
chest:white_check_mark::white_check_mark:Front
biceps:white_check_mark::white_check_mark:Front
abs  :white_check_mark::white_check_mark:Front
upper-back:white_check_mark::white_check_mark:Back
lower-back:white_check_mark::white_check_mark:Back
hamstring:white_check_mark::white_check_mark:Back
gluteal:white_check_mark::white_check_mark:Back
deltoids  :x::white_check_mark:Both
hands:x::white_check_mark:Both
feet:x::white_check_mark:Both
ankles:x::white_check_mark:Both
tibialis:x::white_check_mark:Both
adductor:white_check_mark::x:Both
front-deltoids :white_check_mark::x:Front
abductors:white_check_mark::x:Front
back-deltoids  :white_check_mark::x:Back
3.0.0-beta.5

5 months ago

3.0.0-beta.6

5 months ago

3.0.0-beta.4

6 months ago

3.0.0-beta.1

8 months ago

3.0.0-beta.3

8 months ago

3.0.0-beta.2

8 months ago

2.1.2

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.0

2 years ago

2.0.2

4 years ago

2.0.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago