nodegui / nodegui-plugin-title-bar

Plugin for NodeGUI to hide macOS title bar and leave only traffic lights.
13 stars 4 forks source link

react-nodegui use? #21

Open etoscn opened 4 years ago

etoscn commented 4 years ago

for react-nodegui? help

DimitarNestorov commented 4 years ago

I forked the react-nodegui example and I added the plugin here: https://github.com/dimitarnestorov/react-nodegui-starter Here are all the changes: https://github.com/dimitarnestorov/react-nodegui-starter/commit/12f8c71f9a3215628464ba91a324f4e2ec479f77 image

wkirby commented 3 years ago

@dimitarnestorov you seem to have deleted the repository with the example; any chance you can throw it in a gist or add it as a comment here?

wkirby commented 3 years ago

A little futzing, and I found a working solution:

import { hot, Window, Text } from "@nodegui/react-nodegui";
import React from "react";
import { setTitleBarStyle } from "@nodegui/plugin-title-bar";

class App extends React.Component {
  constructor(props) {
    super(props);
    this.window = React.createRef();
  }

  componentDidMount() {
    try {
      setTitleBarStyle(this.window.current.native, 'hiddenInset');
    } catch(err) {
      console.error(err);
    }
  }

  render() {
    return (
      <Window windowTitle="Hello 👋🏽" ref={this.window}>
         <Text>Hello</Text>
      </Window>
    );
  }
}

export default hot(App);