All Projects → oyyd → React Yue

oyyd / React Yue

Render the views of Yue with React.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Yue

Pywebview
Build GUI for your Python program with JavaScript, HTML, and CSS
Stars: ✭ 2,649 (+2071.31%)
Mutual labels:  gui, webkit
Fenix
A simple and visual static web server with collaboration features.
Stars: ✭ 1,559 (+1177.87%)
Mutual labels:  gui
Shoes4
Shoes 4 : the next version of Shoes
Stars: ✭ 1,509 (+1136.89%)
Mutual labels:  gui
Easygui
Easy GUI for microcontrollers
Stars: ✭ 116 (-4.92%)
Mutual labels:  gui
Boltbrowser
boltBrowser is a GUI web-based explorer and editor for boltDB
Stars: ✭ 116 (-4.92%)
Mutual labels:  gui
Liveprof Ui
An aggregator and web interface for Live Profiler
Stars: ✭ 118 (-3.28%)
Mutual labels:  gui
Nmonvisualizer
A Java GUI tool for analyzing NMON system files
Stars: ✭ 114 (-6.56%)
Mutual labels:  gui
Core
OPNsense GUI, API and systems backend
Stars: ✭ 1,827 (+1397.54%)
Mutual labels:  gui
Binding.scala
Reactive data-binding for Scala
Stars: ✭ 1,539 (+1161.48%)
Mutual labels:  gui
Cpupower Gui
cpupower-gui is a graphical program that is used to change the scaling frequency limits of the cpu, similar to cpupower.
Stars: ✭ 117 (-4.1%)
Mutual labels:  gui
Ocamlverse.github.io
Documentation of everything relevant in the OCaml world
Stars: ✭ 117 (-4.1%)
Mutual labels:  gui
Mylittledom
High-level DOM-like terminal interface library
Stars: ✭ 116 (-4.92%)
Mutual labels:  gui
Cemui
A small launcher for the Cemu WiiU emulator made with Electron. Currently on hiatus, development is currently being focused on Pretendo https://github.com/PretendoNetwork/Pretendo
Stars: ✭ 118 (-3.28%)
Mutual labels:  gui
Gong Wpf Dragdrop
The GongSolutions.WPF.DragDrop library is a drag'n'drop framework for WPF
Stars: ✭ 1,669 (+1268.03%)
Mutual labels:  gui
Hello imgui
Hello, Dear ImGui: cross-platform Gui apps for Windows / Mac / Linux / iOS / Android / Emscripten with the simplicity of a "Hello World" app
Stars: ✭ 120 (-1.64%)
Mutual labels:  gui
Implot
Immediate Mode Plotting
Stars: ✭ 2,014 (+1550.82%)
Mutual labels:  gui
Radish
Desktop client for Redis (Windows, MacOS, Linux)
Stars: ✭ 117 (-4.1%)
Mutual labels:  gui
Sparkledriver
A clojure wrapper for jBrowserDriver, which is a Selenium-compatible wrapper around JFX embedded WebKit.
Stars: ✭ 117 (-4.1%)
Mutual labels:  webkit
Jclasslib
jclasslib bytecode editor is a tool that visualizes all aspects of compiled Java class files and the contained bytecode.
Stars: ✭ 1,789 (+1366.39%)
Mutual labels:  gui
Simple
The Simple Intelligent and Modular Programming Language and Environment
Stars: ✭ 120 (-1.64%)
Mutual labels:  gui

react-yue

npm-version build-badge

This is a lib to help you render the View of Yue in the react way.

Moreover, it's possible to utilize react-yue to a hot reload developing experience.

You may want to check do-space-client and react-yue-app as examples of using this lib.

mac

Get Started

Use node v8 or v9 as they are supported by the builds of gui.

npm i react-yue react gui

Render your view into a container:

import React from 'react'
import gui from 'gui'
import { render } from 'react-yue'

// Create your react component:
function App() {
  return (
    <container
      style={{
        flexDirection: 'row',
        flex: 1,
        justifyContent: 'center',
      }}
    >
      <label
        text="hello"
      />
    </container>
  )
}

// Create a window and a root container:
const win = gui.Window.create({})
win.setContentSize({ width: 400, height: 250 })

const contentView = gui.Container.create()
contentView.setStyle({ flexDirection: 'row' })
win.setContentView(contentView)
win.center()
win.activate()

// Create your react elements and render them:
render(<App />, contentView)

// Start your app
if (!process.versions.yode) {
  gui.MessageLoop.run()
  process.exit(0)
}

Check this ES5 example if you want to run it without any code transforming:

const React = require('react')
const gui = require('gui')
const { render } = require('react-yue')

// Create your react component:
function App() {
  return React.createElement('container', {
    style: {
      flexDirection: 'row',
      flex: 1,
      justifyContent: 'center',
    },
  }, React.createElement('label', {
    text: 'hello',
  }))
}

// Create a window and a root container:
const win = gui.Window.create({})
win.setContentSize({ width: 400, height: 250 })

const contentView = gui.Container.create()
contentView.setStyle({ flexDirection: 'row' })
win.setContentView(contentView)
win.center()
win.activate()

// Create your react elements and render them:
render(React.createElement(App), contentView)

// Start your app
if (!process.versions.yode) {
  gui.MessageLoop.run()
  process.exit(0)
}

Style / Layout

Yue use yoga layout and you can use these properties in the style property. It's also possible to provide other styles via the style prop.

  • color: hex|rgb|rgba|hsl|hsla|name of a color
  • backgroundColor: hex|rgb|rgba|hsl|hsla| name of a color
  • fontSize: number representing a pixel value
  • fontWeight: supports 100-900 and all values in https://libyue.com/docs/latest/js/api/font_weight.html
  • fontFamily: name of a font to use
  • fontStyle: normal|italic
  • textAlign: left|center|right
  • verticalAlign: top|middle|bottom
import React from 'react'

export default function MyComp() {
  return (
    <container
      style={{
        flex: 1,
        flexDirection: 'row',
        backgroundColor: 'black'
      }}
    >
      <container
        style={{
          justifyContent: 'center',
        }}
      >
        <label
          text="hello"
          style={{
            color: 'white',
            fontSize: 14
          }}
        />
      </container>
    </container>
  )
}

Components

Below are what components and their props you can use with react-yue. For more details, please check the official document.

View (base class)

props:

  • Boolean visible
  • Boolean enabled
  • Boolean focusable
  • Boolean mouseDownCanMoveWindow

events:

  • onMouseDown
    • params
      • View self
  • onMouseUp
    • params
      • View self
      • MouseEvent event
  • onMouseMove
    • params
      • View self
      • MouseEvent event
  • onMouseEnter
    • params
      • View self
      • MouseEvent event
  • onMouseLeave
    • params
      • View self
      • MouseEvent event
  • onKeyDown
    • params
      • View self
      • KeyEvent event
  • onKeyUp
    • params
      • View self
      • KeyEvent event
  • onSizeChanged
    • params
      • View self
      • KeyEvent event
  • onCaptureLost
    • params
      • View self
      • KeyEvent event

Button

props:

  • Button::Type type
  • Boolean defaultChecked
  • String title
  • Image image

events:

  • onClick(self)
    • params
      • Button self

Container

events:

  • onDraw(self, painter, painter)
    • params
      • Container self
      • Painter painter - The drawing context of the view.
      • RectF dirty - The area in the view to draw on.

Entry

props:

  • Entry::Type type
  • String text

events:

  • onTextChange(self)
    • params
      • Entry self
  • onActivate(self)
    • params
      • Entry self

Group

props:

  • String title
  • View children

Label

props:

  • String text

ProgressBar

props:

  • Number percent
  • Boolean indeterminate

Scroll

props:

  • Scroll::Policy hpolicy
  • Scroll::Policy vpolicy
  • Boolean overlayScrollbar
  • SizeF size contentSize
  • View children

TextEdit

props:

  • String text
  • Scroll::Policy hpolicy
  • Scroll::Policy vpolicy
  • Boolean overlayScrollbar

events:

  • onTextChange(self)
    • params
      • TextEdit self

Vibrant

props:

  • Vibrant::Material material
  • Vibrant::BlendingMode mode

Using with yackage

React will require its modules dynamically so that you can't correctly package your apps when using yackage to package your Node.js project into an executable.

As yackage doesn't support customized code transforming, webpack is recommended to bundle your js correctly. You can take the config of do-space-client as a reference.

Run Tests

npm run test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].