#polyhorn #style #ui #macro #building #cross-platform #rapidly

macro polyhorn-ui-macros

Procedural macros for Polyhorn UI that turn a CSS-like specification into style structs

5 unstable releases

0.4.0 Dec 2, 2020
0.3.2 Oct 20, 2020
0.3.1 Oct 20, 2020
0.3.0 Oct 20, 2020
0.2.0 Oct 10, 2020

#14 in #rapidly

Download history 14/week @ 2024-03-11 9/week @ 2024-03-18 13/week @ 2024-03-25 36/week @ 2024-04-01 13/week @ 2024-04-08 7/week @ 2024-04-15 8/week @ 2024-04-22 7/week @ 2024-04-29 10/week @ 2024-05-06 12/week @ 2024-05-13 14/week @ 2024-05-20 14/week @ 2024-05-27 13/week @ 2024-06-03 13/week @ 2024-06-10 8/week @ 2024-06-17 16/week @ 2024-06-24

52 downloads per month
Used in 6 crates (2 directly)

MIT license

275KB
6K SLoC

Polyhorn

A library for rapidly building cross-platform apps in Rust 🦀.

Polyhorn is a Rust library for building user interfaces. For users familiar with React or React Native, this library will be very similar in purpose.

It also comes with its own command line interface that makes it easy to start a new project and to build and run existing projects.

Colloquially, both are called Polyhorn.


🚧 Warning: Polyhorn is still very much a work-in-progress, which means that there will probably be many breaking changes and missing features before its official launch (sorry for this).


Get Started

Installation

Installation of Polyhorn is easy and takes just a few seconds. If you're new to Rust, you also need to install Rust first with step 1 below. If you're already using Rust, you can skip step 1 and install Polyhorn with step 2.

  1. If you don't already have Rust installed, install Rust with rustup.

    $ curl -sSf https://sh.rustup.rs | sh
    
  2. Now, install Polyhorn with cargo, the Rust-provided package manager.

    $ cargo install polyhorn
    

Start a Project

Starting a new project from one of our built-in templates is easy. For an almost blank project, run:

$ polyhorn new hello-world

You can replace hello-world with the name of your app. Make sure it contains only alphanumerical characters and dashes.

This will generate a directory with the following structure:

hello-world/
├── .gitignore
├── assets
│   └── .gitkeep
└── src
    └── lib.rs

This is the content of src/lib.rs:

use polyhorn::prelude::*;

#[derive(Default)]
pub struct App {}

impl Component for App {
    fn render(&self, _manager: &mut Manager) -> Element {
        poly!(<Window>
            <View style=!{
                align-items: center;
                justify-content: center;
                background-color: red;
                height: 100%;
            }>
                <Text style=!{ color: white; }>
                    "Welcome to your Polyhorn app!"
                </Text>
            </View>
        </Window>)
    }
}

polyhorn::render!(<App />);

Run a Project

In your command line, navigate to your project. For example, if you followed the instructions above, you should now be in hello-world/. Then, decide on which platform you want to run. Note that all platforms share the same codebase, so you don't need to plan ahead.

Running on iOS

If you want to run your app on an iOS simulator, run this command:

$ polyhorn run ios

It will ask you to select an available simulator.


lib.rs:

This crate wraps the macros implemented in Polyhorn UI in a proc-macro = true library.

Dependencies

~7.5MB
~154K SLoC