refactor consts
This commit is contained in:
parent
c054538ae2
commit
018e8a82a3
3 changed files with 9 additions and 7 deletions
|
|
@ -1026,8 +1026,7 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler
|
|||
|
||||
// The rows get padded a little due to header font being larger than row font
|
||||
obj.Height = float64(dims.Height * (len(obj.SQLTable.Columns) + 1))
|
||||
// Leave room for padding (10 name 20 type 20 = 50)
|
||||
obj.Width = float64(maxNameWidth + maxTypeWidth + constraintWidth + 50)
|
||||
obj.Width = float64(d2target.NamePadding + maxNameWidth + d2target.TypePadding + maxTypeWidth + d2target.TypePadding + constraintWidth)
|
||||
|
||||
case d2target.ShapeText, d2target.ShapeCode:
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ import (
|
|||
"oss.terrastruct.com/util-go/go2"
|
||||
)
|
||||
|
||||
const namePadding = 10
|
||||
|
||||
func tableHeader(box *geo.Box, text string, textWidth, textHeight, fontSize float64) string {
|
||||
str := fmt.Sprintf(`<rect class="class_header" x="%f" y="%f" width="%f" height="%f" fill="%s" />`,
|
||||
box.TopLeft.X, box.TopLeft.Y, box.Width, box.Height, "#0a0f25")
|
||||
|
|
@ -45,13 +43,13 @@ func tableRow(box *geo.Box, nameText, typeText, constraintText string, fontSize,
|
|||
// e.g. | diagram int FK |
|
||||
nameTL := label.InsideMiddleLeft.GetPointOnBox(
|
||||
box,
|
||||
namePadding,
|
||||
d2target.NamePadding,
|
||||
box.Width,
|
||||
fontSize,
|
||||
)
|
||||
constraintTR := label.InsideMiddleRight.GetPointOnBox(
|
||||
box,
|
||||
typePadding,
|
||||
d2target.TypePadding,
|
||||
0,
|
||||
fontSize,
|
||||
)
|
||||
|
|
@ -71,7 +69,7 @@ func tableRow(box *geo.Box, nameText, typeText, constraintText string, fontSize,
|
|||
|
||||
// TODO light font
|
||||
fmt.Sprintf(`<text class="text" x="%f" y="%f" style="%s">%s</text>`,
|
||||
nameTL.X+longestNameWidth+2*namePadding,
|
||||
nameTL.X+longestNameWidth+2*d2target.NamePadding,
|
||||
nameTL.Y+fontSize*3/4,
|
||||
fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", fontSize, neutralColor),
|
||||
escapeText(typeText),
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@ import (
|
|||
"oss.terrastruct.com/d2/d2renderers/d2fonts"
|
||||
)
|
||||
|
||||
const (
|
||||
NamePadding = 10
|
||||
TypePadding = 20
|
||||
)
|
||||
|
||||
type SQLTable struct {
|
||||
Columns []SQLColumn `json:"columns"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue