Use jsx to make scriptable's layout.

Overview

scriptable-jsx

This project helps you to write Scriptable widgets with JSX syntax. And add some useful tools by the way.

you can check demos in demo folder

简体中文

Install

npm i scriptable-jsx

Requirements

  1. webpack (or other bundler)
  2. babel
  3. @babel/plugin-transform-react-jsx

Usage

  1. We can create a jsx file like this:
import { render } from "scriptable-jsx";

const widget = new ListWidget();

render(
  <stack>
    <text>Hello World</text>
  </stack>,
  widget
);

widget.presentMedium();
  1. Set babel:
{
  ...,
  "plugins": [
    [
      "@babel/plugin-transform-react-jsx",
      {
        "runtime": "automatic",
        // use scriptable-jsx to parse jsx
        "importSource": "scriptable-jsx"
      }
    ]
  ]
}

Supported Tags

We have supported these native tags now:

  • stack
  • image
  • spacer
  • text
  • date

Remember, just like react, all the native tags are lowercase. The custom tags should start with uppercase.

All the props are the same as native basically. For example:

<date date={new Date()} applyTimeStyle></date>
<stack
  size={new Size(100, 50)}
  backgroundColor={new Color("#ff0000")}
>
  <text>Test</text>
</stack>

External Features

FlexibleSize

import { FlexibleSize } from "scriptable-jsx";

<stack size={new FlexibleSize(50, 50)}></stack>;

The native Size means the pt unit. It's accurate but not flexible. Users need to adapt to different models. But, FlexibleSize helps you to write the relative value to the widget size. The number you supply means the percent of the full size of width/height of the widget.

We have registered common sizes (check this in device-data.ts). You can add custom sizes too.

Warning: Size for macOS is not provided currently. Actually, the runtime size should be provided by the Scriptable app.

TODO

  • add unit tests
  • remove any type
You might also like...

Like JSX, but native and fast

Like JSX, but native and fast

esx High throughput React Server Side Rendering For a simplified example of esx in action, check out esx-demo. esx is designed to be a high speed SSR

Jan 2, 2023

✏️ Super lightweight JSX syntax highlighter, around 1KB after minified and gzipped

✏️ Super lightweight JSX syntax highlighter, around 1KB after minified and gzipped

Sugar High Introduction Super lightweight JSX syntax highlighter, around 1KB after minified and gzipped Usage npm install --save sugar-high import { h

Dec 8, 2022

Create a html response with JSX.

Htm Create a text/html response with JSX, powered by Preact and UnoCSS. Usage To use Htm, create a server.tsx file like this: /** @jsx h */ import {

Dec 9, 2022

Converts JSX to HTML strings at compile time.

unplugin-jsx-string Converts JSX to HTML strings at compile time. Installation npm i unplugin-jsx-string Vite // vite.config.ts import JsxString from

Sep 3, 2022

Add the `className` to all JSX elements in your project

Babel Plugin Transform JSX Classes This babel plugin adds the className in each JSX element. Before After function FancyComponent () { return (

Jul 15, 2022

Unofficial Library for using Discord.JS with JSX Syntax.

@chooks22/discord.jsx WARNING! This project is in very early stage of development. And while I do have plans to finish it to completion, consider this

Nov 14, 2022

🖼️ Tiny JSX helper function for high-DPI (Retina Display) images.

🖼️ Tiny JSX helper function for high-DPI (Retina Display) images.

img-srcx Tiny JSX helper function for high-DPI (Retina Display) images. 394 bytes minified and gzipped for ESM (830 bytes for ES5). Installation npm i

Oct 6, 2022

A JSX transformer with extra hints around interpolations and outer templates.

@ungap/babel-plugin-transform-hinted-jsx This plugin is a follow up of this post and it can be used together with @babel/plugin-transform-react-jsx. A

Nov 12, 2022

A library for boolean aliases to help you make your code more confusing and make your coworkers hate you.

yup-nope A library for boolean aliases to help you make your code more confusing and make your coworkers hate you. Installation Using npm: npm install

Dec 10, 2022
Owner
毛球
毛球
Script para crear un layout tipo masonry.

light-masonry Script para crear un layout tipo masonry. Solo es necesario tener el contenedor junto a sus hijos que se acomodaran en este tipo de layo

Lenin Felix 2 Feb 4, 2022
A simple library to draw option menu or other popup inputs and layout on Node.js console.

console-gui-tools A simple library to draw option menu or other popup inputs and layout on Node.js console. console-gui-tools A simple Node.js library

Elia Lazzari 12 Dec 24, 2022
Lightweight and independent Pinterest-like cascading grid layout library

Bricklayer is a Lightweight and Independent Pinterest-like Cascading Grid Layout Library ?? Simpler than any other cascading grid layout tools. ❄️ Lig

Adem ilter 2.5k Dec 22, 2022
Chrome & Firefox extension to return old Twitter layout from 2015.

OldTwitter (2022) Chrome extension to return old Twitter layout from 2015. This extension doesn't add any CSS on top of original Twitter. It's fully o

dimden 35 Jan 4, 2023
2D HTML5 rendering and layout engine for game development

Stage.js is a 2D HTML5 JavaScript library for cross-platform game development, it is lightweight, fast and open-source. Check out examples and demos!

Ali Shakiba 2.2k Jan 3, 2023
Minimalist dependancy free Masonry layout library

MiniMasonry.js Minimalist dependency free Masonry layout library MiniMasonry is a lightweight dependency free Masonry layout. It will compute elements

Spope 343 Dec 4, 2022
Print seat layout for movie, flight (jQuery plugin)

seatLayout.js (movie-seat-layout) Print seat layout for movie, flight and seat selection (jQuery plugin) Demo : https://sachinkurkute.github.io/movie-

Sachin Kurkute 20 Dec 8, 2022
Web Components engine based on JSX & TypeScript

WebCell Web Components engine based on JSX & TypeScript Usage Demo & GitHub template: https://web-cell.dev/scaffold/ Project bootstrap Command npm ini

null 162 Nov 17, 2022
High performance JSX web views for S.js applications

Surplus const name = S.data("world"), view = <h1>Hello {name()}!</h1>; document.body.appendChild(view); Surplus is a compiler and runtime to all

Adam Haile 587 Dec 30, 2022