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

Introduce italic description for Button Builder API #1450

Merged
merged 1 commit into from
May 27, 2024
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
12 changes: 12 additions & 0 deletions pkg/api/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ type ButtonDescriptionStyle string
const (
// ButtonDescriptionStyleBold defines the bold style for the button description.
ButtonDescriptionStyleBold ButtonDescriptionStyle = "bold"

// ButtonDescriptionStyleItalic defines the bold style for the button description.
ButtonDescriptionStyleItalic ButtonDescriptionStyle = "italic"
// ButtonDescriptionStyleText defines the plaintext style for the button description.
ButtonDescriptionStyleText ButtonDescriptionStyle = "text"
// ButtonDescriptionStyleCode defines the code style for the button description.
Expand Down Expand Up @@ -351,6 +354,15 @@ func (b *ButtonBuilder) ForCommandWithDescCmd(name, cmd string, style ...ButtonS
return b.commandWithCmdDesc(name, cmd, cmd, bt)
}

// ForCommandWithItalicDesc returns button command where description and command are different and the description is italic.
func (b *ButtonBuilder) ForCommandWithItalicDesc(name, desc, cmd string, style ...ButtonStyle) Button {
bt := ButtonStyleDefault
if len(style) > 0 {
bt = style[0]
}
return b.commandWithDesc(name, cmd, desc, bt, ButtonDescriptionStyleItalic)
}

// ForCommandWithBoldDesc returns button command where description and command are different.
func (b *ButtonBuilder) ForCommandWithBoldDesc(name, desc, cmd string, style ...ButtonStyle) Button {
bt := ButtonStyleDefault
Expand Down
2 changes: 2 additions & 0 deletions pkg/bot/slack_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ func (b *SlackRenderer) renderButtonsWithDescription(in api.Buttons) []slack.Blo
switch btn.DescriptionStyle {
case api.ButtonDescriptionStyleBold:
desc = fmt.Sprintf("*%s*", desc)
case api.ButtonDescriptionStyleItalic:
desc = fmt.Sprintf("_%s_", desc)
case api.ButtonDescriptionStyleText:
// no op, it should be just a simple string
case api.ButtonDescriptionStyleCode:
Expand Down
Loading