From 7fa560b05cfd64df99b2cf9dac31b721b6197a1d Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Tue, 30 Aug 2022 17:14:53 -0400 Subject: [PATCH] feat: Align takes multiple arguments for setting horizontal + vertical alignment --- set.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/set.go b/set.go index e96399f5..a58d3b3f 100644 --- a/set.go +++ b/set.go @@ -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 }