Skip to content

Commit a3f727e

Browse files
authored
Introduce italic description for Button Builder API (#1450)
Add new style API for ButtonBuilder
1 parent 9d1c897 commit a3f727e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/api/message.go

+12
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ type ButtonDescriptionStyle string
316316
const (
317317
// ButtonDescriptionStyleBold defines the bold style for the button description.
318318
ButtonDescriptionStyleBold ButtonDescriptionStyle = "bold"
319+
320+
// ButtonDescriptionStyleItalic defines the bold style for the button description.
321+
ButtonDescriptionStyleItalic ButtonDescriptionStyle = "italic"
319322
// ButtonDescriptionStyleText defines the plaintext style for the button description.
320323
ButtonDescriptionStyleText ButtonDescriptionStyle = "text"
321324
// ButtonDescriptionStyleCode defines the code style for the button description.
@@ -351,6 +354,15 @@ func (b *ButtonBuilder) ForCommandWithDescCmd(name, cmd string, style ...ButtonS
351354
return b.commandWithCmdDesc(name, cmd, cmd, bt)
352355
}
353356

357+
// ForCommandWithItalicDesc returns button command where description and command are different and the description is italic.
358+
func (b *ButtonBuilder) ForCommandWithItalicDesc(name, desc, cmd string, style ...ButtonStyle) Button {
359+
bt := ButtonStyleDefault
360+
if len(style) > 0 {
361+
bt = style[0]
362+
}
363+
return b.commandWithDesc(name, cmd, desc, bt, ButtonDescriptionStyleItalic)
364+
}
365+
354366
// ForCommandWithBoldDesc returns button command where description and command are different.
355367
func (b *ButtonBuilder) ForCommandWithBoldDesc(name, desc, cmd string, style ...ButtonStyle) Button {
356368
bt := ButtonStyleDefault

pkg/bot/slack_renderer.go

+2
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ func (b *SlackRenderer) renderButtonsWithDescription(in api.Buttons) []slack.Blo
307307
switch btn.DescriptionStyle {
308308
case api.ButtonDescriptionStyleBold:
309309
desc = fmt.Sprintf("*%s*", desc)
310+
case api.ButtonDescriptionStyleItalic:
311+
desc = fmt.Sprintf("_%s_", desc)
310312
case api.ButtonDescriptionStyleText:
311313
// no op, it should be just a simple string
312314
case api.ButtonDescriptionStyleCode:

0 commit comments

Comments
 (0)