MCPcopy
hub / github.com/lelandrichardson/react-primitives

github.com/lelandrichardson/react-primitives @v0.8.1 sqlite

repository ↗ · DeepWiki ↗ · release v0.8.1 ↗
82 symbols 123 edges 46 files 5 documented · 6%
README

react-primitives

Primitive React Interfaces Across Targets

npm

Installation

npm install --save react-primitives

You will also need to install the targets you want to support:

  • web: sh npm install --save react-dom react-native-web react-art
  • native iOS and Android: sh npm install --save react-native
  • sketch: sh npm install --save react-sketchapp react-test-renderer
  • figma: sh npm install --save react-figma yoga-layout-prebuilt
  • vr: sh npm install --save react-360
  • Windows: sh npm install --save react-native-windows

Usage

import React from "react";
import { View, Text, Image, StyleSheet } from "react-primitives";

class Foo extends React.Component {
  render() {
    return <View style={styles.foo}>{this.props.children}</View>;
  }
}

const styles = StyleSheet.create({
  foo: {
    width: 100,
    height: 100,
    backgroundColor: "#ff00ff"
  }
});

What is this?

This library attempts to propose an ideal set of primitives around building React applications, regardless of Platform. In the future, this could be used as a shared interface among React and React Native components that don't use platform-specific APIs.

Importantly, this includes StyleSheet for declaring styles, as well as Animated for doing declarative Animations.

The exported APIs thus far are:

  1. Animated: Pulled from the animated project.
  2. StyleSheet: Follows React Native's StyleSheet API.
  3. View: A base component for Layout.
  4. Text: A base component for Text rendering.
  5. Image: A base component for Image rendering.
  6. Touchable: A base component for interaction.
  7. Easing: A base set of easing functions.
  8. Dimensions: Get the devices dimensions.
  9. PixelRatio: Get the devices pixel density.
  10. Platform: Get information about the platform. (iOS, Android, Web, Sketch, VR,...)

In the future, a TextInput component may also be added.

Props where props are due

This library was largely inspired from the work done by Nicolas Gallager and his great work on the react-native-web library. A few of the files in this repo are even copied directly from his project.

Core symbols most depended-on inside this repo

throttle
called by 4
src/modules/Touchable.js
throttle
called by 4
src/vr/Touchable.js
getStories
called by 2
example/StoryManager.js
setup
called by 2
example/web/perf.js
teardown
called by 2
example/web/perf.js
fmt
called by 2
example/benchmarks/benchmark.js
measure
called by 2
example/benchmarks/benchmark.js
ensurePositiveDelayProps
called by 2
src/modules/Touchable.js

Shape

Function 65
Method 9
Class 8

Languages

TypeScript90%
Java10%

Modules by API surface

src/modules/Touchable.js16 symbols
src/injection/react-sketchapp.js9 symbols
src/injection/react-figma.js9 symbols
example/benchmarks/benchmark.js8 symbols
src/vr/Touchable.js7 symbols
example/native/android/app/src/main/java/com/native/MainApplication.java6 symbols
src/modules/PixelRatio.js4 symbols
example/web/pythagoras.js4 symbols
example/stories/Animated/Animated1.js3 symbols
example/native/index.js3 symbols
example/StoryManager.js3 symbols
src/injection/react-native-web.js2 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

animated0.2.2 · 1×
babel-cli6.6.5 · 1×
babel-core6.26.3 · 1×
babel-eslint8.2.3 · 1×
babel-jest17.0.2 · 1×
babel-loader7.1.4 · 1×
babel-plugin-module-resolver3.1.1 · 1×
babel-plugin-syntax-object-rest-spread6.5.0 · 1×
babel-plugin-transform-object-rest-spread6.6.5 · 1×
babel-preset-airbnb2.4.0 · 1×
babel-preset-react-native1.9.0 · 1×
browserify13.1.0 · 1×

For agents

$ claude mcp add react-primitives \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact