From f6c11d52f03463b6a693da3147216505e20cfcd2 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 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/set.go b/set.go index e96399f5..02884543 100644 --- a/set.go +++ b/set.go @@ -104,9 +104,19 @@ 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 { + if len(p) > 0 { + s.set(alignHorizontalKey, p[0]) + } + if len(p) > 1 { + s.set(alignVerticalKey, p[1]) + } return s }