Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added template nesting. Improved example.
- Loading branch information
Showing
21 changed files
with
338 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.Count { | ||
background: lightsalmon; | ||
border: 10px solid salmon; | ||
} | ||
|
||
.Cocos { | ||
background: lightyellow; | ||
border: 10px solid yellow; | ||
} | ||
|
||
.Coco { | ||
display: inline-block; | ||
background: lightgray; | ||
cursor: pointer; | ||
border: 10px solid gray; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import "github.com/mrmiguu/coco" | ||
|
||
type Count struct { | ||
Up | ||
Cocos []string | ||
Down | ||
} | ||
|
||
func NewCount() Count { | ||
return Count{ | ||
Cocos: []string{"🥥"}, | ||
} | ||
} | ||
|
||
func (c Count) OnUpClick() { | ||
println("clicked Up") | ||
c.Cocos = append(c.Cocos, "🥥") | ||
coco.Set(c) | ||
} | ||
|
||
func (c Count) OnCocoClick() { | ||
println("clicked Coco") | ||
} | ||
|
||
func (c Count) OnDownClick() { | ||
println("clicked Down") | ||
c.Cocos = c.Cocos[1:] | ||
coco.Set(c) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div class="Count"> | ||
{{template "Up"}} | ||
|
||
<div class="Cocos"> | ||
{{range $_, $coco := .Cocos}} | ||
<div class="Coco">{{$coco}}</div> | ||
{{end}} | ||
</div> | ||
|
||
{{template "Down"}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.Down { | ||
display: inline-block; | ||
background: lightblue; | ||
cursor: pointer; | ||
border: 10px solid blue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package main | ||
|
||
type Down struct { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="Down"> | ||
🔽 | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.Up { | ||
display: inline-block; | ||
background: lightgreen; | ||
cursor: pointer; | ||
border: 10px solid green; | ||
} |
Oops, something went wrong.