Skip to content

Repository files navigation

app

app

Build StatusGo Report CardCoverage StatusGoDoc

Build multiplatform apps with Go, HTML and CSS.

Table of Contents

  1. Requirements
  2. Install
  3. Getting started
  4. Documentation

Requirements:

  • MacOS: 10.12 (Sierra) and the latest version of Xcode (mandatory for Apple frameworks).

Install

  1. Install Golang:

  2. Get a driver:

    • MacOS: go get -u github.com/murlokswarm/mac
    • Windows: In progress
    • Linux: (Please contribute)
    • IOS: (Please contribute)
    • Android: (Please contribute)

Getting started

hello

Import a driver

import (
_ "github.com/murlokswarm/mac"
)

Create a component

typeHellostruct {
Greetingstring
}
func (h*Hello) Render() string {
return`<div class="WindowLayout">  <div class="HelloBox"> <h1> Hello, <span>{{if .Greeting}}{{html .Greeting}}{{else}}World{{end}}</span> </h1> <input type="text" placeholder="What is your name?" onchange="OnInputChange" /> </div></div> `
}
func (h*Hello) OnInputChange(arg app.ChangeArg) {
h.Greeting=arg.Valueapp.Render(h)
}
funcinit() {
app.RegisterComponent(&Hello{})
}

Write the main

funcmain() {
app.OnLaunch=func() {
win:=app.NewWindow(app.Window{
Title: "Hello World",
Width: 1280,
Height: 720,
TitlebarHidden: true,
})
hello:=&Hello{}
win.Mount(hello)
}
app.Run()
}

Style your component

Create a CSS file in [PACKAGE PATH]/resources/css/ and write your styles.

resources/css/hello.css:

body {
background-image:url("../bg1.jpg");
background-size: cover;
background-position: center;
color: white;
overflow: hidden;
}
.WindowLayout {
position: fixed;
width:100%;
height:100%;
display: flex;
justify-content: center;
align-items: center;
}
.HelloBox {
padding:20pt;
}
h1 {
font-weight:300;
}
input {
width:100%;
padding:5pt;
border:0;
border-left:2px solid silver;
outline: none;
font-size:14px;
background: transparent;
color: white;
}
input:focus {
border-left-color: deepskyblue;
}

Try it by cloning the full example.

Go to the cloned directory and type:

go build
./hello

Documentation

More examples

About

Package to create apps with GO, HTML and CSS.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages