Skip to content

Commit

Permalink
demo window example
Browse files Browse the repository at this point in the history
  • Loading branch information
maxence-charriere committed Dec 12, 2018
1 parent 4caf56a commit 5948e68
Show file tree
Hide file tree
Showing 10 changed files with 308 additions and 24 deletions.
4 changes: 2 additions & 2 deletions examples/demo/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Hello struct {
Name string
}

// Render returns a string that describes the component markup.
// Render returns a html string that describes the component.
func (h *Hello) Render() string {
return `
<div class="Layout Hello">
Expand All @@ -19,7 +19,7 @@ func (h *Hello) Render() string {
world
{{end}}!
</h1>
<input class="Hello-Input" value="{{.Name}}" placeholder="Say something..." onchange="Name" autofocus>
<input class="Hello-Input" value="{{.Name}}" placeholder="Say something..." onchange="{{to "Name"}}" autofocus>
</div>
</div>
`
Expand Down
16 changes: 14 additions & 2 deletions examples/demo/main_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ func main() {
app.Import(
&NavPane{},
&Hello{},
&Window{},
)

entryCompo := "window"

switch app.Kind {
case "web":
app.Run(&web.Driver{
URL: "/Hello",
URL: entryCompo,
})

default:
app.Run(&mac.Driver{
URL: "/Hello",
Settings: mac.Settings{
SupportedFiles: []mac.FileType{
{
Expand All @@ -36,6 +38,16 @@ func main() {
URLScheme: "goapp-demo",
},

OnRun: func() {
newWindow("main", entryCompo)
},

OnReopen: func(hasVisibleWindow bool) {
if !hasVisibleWindow {
newWindow("main", entryCompo)
}
},

OnFilesOpen: func(filenames []string) {
app.Log("opened from:", filenames)
},
Expand Down
1 change: 1 addition & 0 deletions examples/demo/main_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ func main() {
app.Import(
&NavPane{},
&Hello{},
&Window{},
)

app.Run(&web.Driver{
Expand Down
1 change: 1 addition & 0 deletions examples/demo/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func main() {
app.Import(
&NavPane{},
&Hello{},
&Window{},
)

switch app.Kind {
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/navpane.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ func (n *NavPane) Render() string {
return `
<div class="NavPane">
<h1>Demo</h1>
<ul class="NavPane-List">
<ul>
{{$current := .Current}}
{{range .Examples}}
<li class="NavPane-Elem {{if eq . $current}}Selected{{end}}">
<li class="{{if eq . $current}}Selected{{end}}">
<a href="{{.}}">{{.}}</a>
</li>
{{end}}
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/resources/css/hello.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.Hello {
background-image: url('../space.jpg');
background-size: cover;
background-position: top;
background-size:cover;
background-position: right;
}

.Hello-Content {
Expand Down
43 changes: 43 additions & 0 deletions examples/demo/resources/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ h1 {
letter-spacing: 1px;
font-weight: 200;
text-transform: lowercase;
margin: 0;
padding: 38px 24px 0;
}

h2 {
font-weight: 200;
text-transform: lowercase;
margin: 0;
padding: 0 24px;
}

p {
padding: 6px 24px 0;
margin: 0;
outline: 0;
}

.Layout {
Expand All @@ -29,4 +44,32 @@ h1 {

.Selected a {
color: deepskyblue;
}

ul {
margin: 0;
padding: 12px 0 0;
}

ul li {
margin: 0;
padding: 6px 24px 3px;
}

table {
width: calc(100% - 48px);
border-collapse: collapse;
margin: 12px 24px;
table-layout: fixed;
}

td {
border-bottom: 0.5px solid rgba(255, 255, 255, 0.3);
padding: 12px;
text-align: center;
border-collapse: collapse;
}

tr:last-child td {
border-bottom: 0;
}
16 changes: 0 additions & 16 deletions examples/demo/resources/css/navpane.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,6 @@
background-color: rgba(0, 0, 0, 0.50);
}

.NavPane h1 {
margin: 0;
padding: 38px 24px 6px;
}

.NavPane-List {
margin: 3px 0 0;
padding: 0;
list-style: circle;
}

.NavPane-Elem {
margin: 0;
padding: 6px 24px 3px;
}

.NavPane-Elem a {
display: block;
width: 100%;
Expand Down
24 changes: 24 additions & 0 deletions examples/demo/resources/css/window.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.Window-Tracking {
background-color: rgba(0, 0, 0, 0.25);
width: 400px;
}

.Window-Actions {
background-color: rgba(0, 0, 0, 0.5);
flex-grow: 1;
}

.Window-Action-List {
margin: 6px 0 0;
}

.Window-Action {
margin: 0;
padding: 12px 0;
cursor: pointer;
-webkit-user-select: none;
}

.Window-Action:hover {
background-color: deepskyblue;
}

0 comments on commit 5948e68

Please sign in to comment.