-
Notifications
You must be signed in to change notification settings - Fork 19
/
model.go
66 lines (59 loc) · 1.28 KB
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package design
import (
"fmt"
. "goa.design/model/dsl"
"goa.design/model/mdl"
)
var shapes = []ShapeKind{
ShapeBox,
ShapeCircle,
ShapeCylinder,
ShapeEllipse,
ShapeHexagon,
ShapeRoundedBox,
ShapeComponent,
ShapeFolder,
ShapeMobileDeviceLandscape,
ShapeMobileDevicePortrait,
//ShapePerson,
ShapePipe,
ShapeRobot,
ShapeWebBrowser,
}
var _ = Design("Getting Started", "This is a model of my software system.", func() {
for i, sh := range shapes {
func(i int) {
SoftwareSystem(fmt.Sprintf("System %d", i+1), fmt.Sprintf("Shape: %s.", shapeName(sh)), func() {
Tag(fmt.Sprintf("system%d", i+1))
})
}(i)
}
Person("User", "A person using shapes.", func() {
for i := range shapes {
Uses(fmt.Sprintf("System %d", i+1), "Uses")
}
Tag("person")
})
Views(func() {
SystemContextView("System 1", "SystemContext", "An example of a System Context diagram.", func() {
AddAll()
AutoLayout(RankLeftRight)
})
Styles(func() {
ElementStyle("person", func() {
Shape(ShapePerson)
Background("#f0f7ff")
})
for i, shape := range shapes {
ElementStyle(fmt.Sprintf("system%d", i+1), func() {
Shape(shape)
Background("#f0f7ff")
})
}
})
})
})
func shapeName(sh ShapeKind) string {
b, _ := mdl.ShapeKind(sh).MarshalJSON()
return string(b)
}