Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IsSublte and HorizontalAlignment to Element #264

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions adaptivecard/adaptivecard.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ const (
SpacingPadding string = "padding"
)

// Supported Horizontal alignment values for (supported) container types.
// Supported Horizontal alignment values for (supported) container and text
// types.
const (
HorizontalAlignmentLeft string = "left"
HorizontalAlignmentCenter string = "center"
Expand Down Expand Up @@ -502,6 +503,9 @@ type Element struct {
// preceding element.
Spacing string `json:"spacing,omitempty"`

// HorizontalAlignment controls the horizontal text alignment.
HorizontalAlignment string `json:"horizontalAlignment,omitempty"`

// The style of the element for accessibility purposes. Valid values
// differ based on the element type. For example, a TextBlock element
// supports the "heading" style, whereas the Column element supports the
Expand Down Expand Up @@ -584,6 +588,10 @@ type Element struct {
// TextBlock elements.
Wrap bool `json:"wrap,omitempty"`

// IsSubtle specifies whether this element should appear slightly toned
// down.
IsSubtle bool `json:"isSubtle,omitempty"`

// Separator, when true, indicates that a separating line shown should be
// drawn at the top of the element.
Separator bool `json:"separator,omitempty"`
Expand Down Expand Up @@ -1281,6 +1289,7 @@ func (e Element) Validate() error {
supportedWeightValues := supportedWeightValues()
supportedColorValues := supportedColorValues()
supportedSpacingValues := supportedSpacingValues()
supportedHorizontalAlignmentValues := supportedHorizontalAlignmentValues()

// Valid Style field values differ based on type. For example, a Container
// element supports Container styles whereas a TextBlock supports a
Expand All @@ -1297,6 +1306,7 @@ func (e Element) Validate() error {
v.InListIfFieldValNotEmpty(e.Weight, "Weight", "element", supportedWeightValues, ErrInvalidFieldValue)
v.InListIfFieldValNotEmpty(e.Color, "Color", "element", supportedColorValues, ErrInvalidFieldValue)
v.InListIfFieldValNotEmpty(e.Spacing, "Spacing", "element", supportedSpacingValues, ErrInvalidFieldValue)
v.InListIfFieldValNotEmpty(e.HorizontalAlignment, "HorizontalAlignment", "element", supportedHorizontalAlignmentValues, ErrInvalidFieldValue)
v.InListIfFieldValNotEmpty(e.Style, "Style", "element", supportedStyleValues, ErrInvalidFieldValue)

/******************************************************************
Expand Down Expand Up @@ -1443,7 +1453,7 @@ func (tcd TableColumnDefinition) Validate() error {
tcd.HorizontalCellContentAlignment,
"HorizontalCellContentAlignment",
TypeTableColumnDefinition,
supportedHorizontalContentAlignmentValues(),
supportedHorizontalAlignmentValues(),
ErrInvalidFieldValue,
)

Expand Down Expand Up @@ -1534,7 +1544,7 @@ func (tr TableRow) Validate() error {
tr.HorizontalCellContentAlignment,
"HorizontalCellContentAlignment",
TypeTableRow,
supportedHorizontalContentAlignmentValues(),
supportedHorizontalAlignmentValues(),
ErrInvalidFieldValue,
)

Expand Down
5 changes: 3 additions & 2 deletions adaptivecard/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ func supportedSpacingValues() []string {
}

// supportedHorizontalAlignmentValues returns a list of valid horizontal
// content alignment values for supported container types. This list is
// alignment values for supported container and text types. This list is
// intended to be used for validation and display purposes.
func supportedHorizontalContentAlignmentValues() []string {
func supportedHorizontalAlignmentValues() []string {
// https://adaptivecards.io/explorer/Table.html
// https://adaptivecards.io/explorer/TextBlock.html
// https://adaptivecards.io/schemas/adaptive-card.json
return []string{
HorizontalAlignmentLeft,
Expand Down
Loading