Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing WebAssembly, Specs, ReactApeTree and Platform module #129

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

raphamorim
Copy link
Owner

@raphamorim raphamorim commented Jul 12, 2022

Summary

This PR introduces:

  • Specs
  • WebAssembly rendering
  • ReactApeTree
  • Platform

Below the explanation/overview for each of the features

Specs

This pull request introduces specs. Specs are formal agreement and documentation regarding React Ape Elements behavior, example below:

Screen Shot 2022-07-13 at 21 14 48

Render with WASM/Canvas (fallback to JS/Canvas)

More information soon.

ReactApeTree Overview

Since React Ape render using canvas, it can't properly read parent styles correctly. The idea behind this PR is to reduce issues regarding hierarchy, those problems makes the App looks super weird unless you rule/specify intentionally in every View which style it should carry (it's how Ape works nowaday unfortanelly).

This PR introduces a tree that contains the layout and style property for each node, so can easily propagate it between children

Related #67

Known issues:

  • Text style hierarchy doesn't work (it should render in orange)
  • View positions aren't correctly geometrically
  • View backgroundColor isn't correct, 2nd View should have same bgc as 1st and also 4th should have same as 3rd

Demo

return (
  <View style={{width: 80, height: 80, backgroundColor: 'grey', color: 'orange'}}>
    <View>
      <View style={{width: 80, height: 80, backgroundColor: 'powderblue'}}>
        <View
          style={{
            width: 30,
            height: 30
          }}>
          <Text>should be in orange</Text>
        </View>
      </View>
    </View>
  </View>
);

Before

Skärmavbild 2022-06-22 kl  06 46 07

After

Usage of _reactApeTree when process.env.NODE_ENV !== 'production'

Screen Shot 2022-07-11 at 19 52 03

Platform

When building a cross-platform app, you'll want to re-use as much code as possible. You'll probably have different scenarios where different code might be necessary.
For instance, you may want to implement separated visual components for LG-webOS and Samsung-Tizen.

This PR also introduces the Platform module to easily organize your code and separate it by platform:

import { Platform } from 'react-ape';

console.log(Platform('webos')) // true
console.log(Platform('tizen')) // false
console.log(Platform('orsay')) // false

@raphamorim raphamorim changed the title Introducting WebAssembly rendering and ReactApeTree Introducing WebAssembly rendering and ReactApeTree Jul 12, 2022
@raphamorim raphamorim changed the title Introducing WebAssembly rendering and ReactApeTree Introducing WebAssembly rendering, ReactApeTree and Platform module Jul 12, 2022
@raphamorim raphamorim changed the title Introducing WebAssembly rendering, ReactApeTree and Platform module Introducing WebAssembly rendering, Specs, ReactApeTree and Platform module Jul 13, 2022
@raphamorim raphamorim changed the title Introducing WebAssembly rendering, Specs, ReactApeTree and Platform module Introducing Specs, ReactApeTree and Platform module Jul 13, 2022
@raphamorim raphamorim changed the title Introducing Specs, ReactApeTree and Platform module Introducing WebAssembly, Specs, ReactApeTree and Platform module Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant