Skip to content

Commit

Permalink
feat: Align takes multiple arguments for setting horizontal + vertica…
Browse files Browse the repository at this point in the history
…l alignment
  • Loading branch information
maaslalani committed Aug 30, 2022
1 parent fd86389 commit 7fa560b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions set.go
Expand Up @@ -104,9 +104,17 @@ func (s Style) Height(i int) Style {
return s
}

// Align sets a horizontal text alignment rule.
func (s Style) Align(p Position) Style {
s.set(alignHorizontalKey, p)
// Align is a shorthand method for setting horizontal and vertical alignment.
//
// With one argument, the position value is applied to the horizontal alignment.
//
// With two arguments, the value is applied to the vertical and horizontal
// alignments, in that order.
func (s Style) Align(p ...Position) Style {
s.set(alignHorizontalKey, p[0])
if len(p) > 1 {
s.set(alignVerticalKey, p[1])
}
return s
}

Expand Down

0 comments on commit 7fa560b

Please sign in to comment.