Giter Club home page Giter Club logo

react-native-jigsaw's Introduction

react-native-jigsaw

Draftbit's specialized component library. Loosely based on React Native Paper, this allows you to incorporate your components into the Draftbit platform. You're also welcome to use this library however you'd like in a typical Expo/React Native project

This is a monorepo containing the packages comprising @draftbit/ui, Draftbit's component library used inside our Builder.

See the ui package readme for details.

Quickstart:

git clone https://github.com/draftbit/react-native-jigsaw && cd react-native-jigsaw
yarn && yarn bootstrap && yarn build
yarn example start -c --web

Any changes in the packages/ typescript files should be automatically picked up by the Metro bundler and reflected in the example application.

Please read the contributing guide before making a pull-request and to understand the full development flow

Uploading Example to Snack:

yarn example:snack

Overview

This is a lerna/monorepo setup that is split up into types, native, core and ui packages.

  • packages/ui: pulls in everything from core and native and re-exports it. This is what any user will install to use this Library
  • packages/core: Non-native, javascript components go here. These are components that work perfectly across web, ios and android without any adjustments
  • packages/native: Native components that rely on expo/react-native modules likes expo-av and @expo/vector-icons. This houses our AudioPlayer and Icon components because the current version requires modifications to work well on Web
  • packages/types: Shared typescript types and SEED_DATA types which is how we build the translation layer for Draftbit

** Chances are, you'll spend most of your time in packages/core **

SEED_DATA

You'll notice that most components will have SEED_DATA at the bottom of their files. This is how we incorporate components and props into Draftbit's property panel.

The object at the bottom maps one to one to what the UI will look like in the panel. Here's an example of the "View" component:

Draftbit Properties Panel

Here's an example of what the SEED_DATA prop would look like:

  source: createImageProp(),
  pointerEvents: {
    group: GROUPS.advanced,
    name: "pointerEvents",
    label: "pointerEvents",
    description: "Pointer events"
    options: ["auto", "none", "box-none", "box-only"],
    editable: true,
    required: false,
    formType: FORM_TYPES.flatArray,
    propType: PROP_TYPES.STRING,
    defaultValue: "auto",
  },

Objects vs. Functions for SEED_DATA

Our legacy implementation included an object, like you see pointerEvents above. Moving forward, everything should be a function, like createImageProp(). The reason is that its easier to maintain and update across the board when features change inside the builder.

If you're having doubts, use a function. If that function doesn't exist, create it! All the functions live inside packages/types/src/component-types

Linking

If you want to dynamically link these packages into a project using yarn link, make sure to run yarn watch <packagename> from the root folder so that lerna can properly cross link everything, then yarn link from the particular package directory (not the root!) you are interested in.

So if using @draftbit/core in a create-react-app, this would look like:

# In react-native-jigsaw/
$ yarn install
$ yarn watch core

# In ./packages/core/
$ yarn link

# In create-react-app project root
$ <shutdown any running create-react-app dev mode>
$ yarn add @draftbit/core # only if this is the first time using it
$ yarn install
$ yarn link @draftbit/core
$ yarn start

You should be able to make changes inside core/, have nodemon pick them up and rebuild, then have create-react-app pick that up and rebuild.

Publishing

Pre-Release:

  • Every pull request will cause a prerelease version to be published on npm. You can use these versions to test you changes without having to worry about linking packages.

Release Process:

  • We release master, meaning a pull-request containing substantive changes should not alter any version information.

  • When master is ready for release, create a new branch and run a yarn version:XXXX command from the root, as appropriate. Lerna will update all the package.json files with the next version, and create and tag a commit.

    • NOTE: We follow a modified semver: EXPO_VERSION.MAJOR.MINOR.
  • Push the branch and tag to github, and open a pull-request for the new version.

  • When the pull-request is approved and merged to master, a github action & lerna will automatically publish all packages to npm with the new version.

  • Once that is done, create a tag for the version, ie git tag v46.2.4 and git push --tags

  • If auto-publication fails, say because npm is down, contributors can also run yarn lerna publish from-package from an up-to-date master branch. Lerna will automatically inspect the registry and the versions on master and publish only the appropriate packages.

Upgrade Expo SDK Modules

Run node scripts/upgrade-expo-sdk-packages.js expo-sdk-version. Where expo-sdk-version comes from Expo. Expo hosts a file called bundledNativeModules.json. You must use the correct version via the url: https://github.com/expo/expo/blob/sdk-46/packages/expo/bundledNativeModules.json

Plug

Sound cool? We're hiring!.

License

MIT

Contributing

  • Any color should be passed down via theme prop:
// NOT dotColor="#5a45ff" b/c that isn't theme powered
// Learn more here https://callstack.github.io/react-native-paper/theming.html
<Carousel dotColor={theme.colors.strong}>

react-native-jigsaw's People

Contributors

dhruska avatar sebastiankurp avatar peterpme avatar davesnx avatar youssefhenna avatar smlarkin avatar gunjankothari avatar bluerssen avatar pnickolas1 avatar adnelson avatar zan-rosenthal avatar dependabot[bot] avatar ballenwillis avatar ismafunes avatar babzcraig avatar tush13ar avatar czystyl avatar sammakesthings avatar dsebek avatar sergeyromanovsky avatar tatchi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.