// Copyright Epic Games, Inc. All Rights Reserved.
using System.Text.Json.Serialization;
using EpicGames.Slack.Elements;
namespace EpicGames.Slack.Blocks
{
///
/// A header is a plain-text block that displays in a larger, bold font. Use it to delineate between different groups of content in your app's surfaces.
///
public class HeaderBlock : Block
{
///
/// The text for the block, in the form of a plain_text text object. Maximum length for the text in this field is 150 characters.
///
[JsonPropertyName("text"), JsonPropertyOrder(1)]
public PlainTextObject Text { get; }
///
/// Constructor
///
/// Any text to initiale the Section with
public HeaderBlock(PlainTextObject text) : base("header")
{
Text = text;
}
///
/// Constructor
///
/// Text to display in the header
public HeaderBlock(string text) : this(new PlainTextObject(text))
{
}
}
///
/// Extension methods for
///
public static class HeaderBlockExtensions
{
///
/// Add an to the list of blocks
///
/// List of blocks
/// Text for the header
public static void AddHeader(this ISlackBlockContainer container, PlainTextObject text)
{
HeaderBlock block = new HeaderBlock(text);
container.Blocks.Add(block);
}
///
/// Add an to the list of blocks
///
/// List of blocks
/// Text for the header
/// Whether to enable emoji
public static void AddHeader(this ISlackBlockContainer container, string text, bool? emoji) => AddHeader(container, new PlainTextObject(text, emoji));
}
}