Files
UnrealEngineUWP/Engine/Source/Programs/Shared/EpicGames.Slack/Blocks/HeaderBlock.cs
Ben Marsh 2ee9f576c1 Horde: Enable code style warnings in EpicGames.Slack, and fix current violations.
[CL 27827302 by Ben Marsh in ue5-main branch]
2023-09-13 09:00:54 -04:00

62 lines
1.9 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System.Text.Json.Serialization;
using EpicGames.Slack.Elements;
namespace EpicGames.Slack.Blocks
{
/// <summary>
/// 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.
/// </summary>
public class HeaderBlock : Block
{
/// <summary>
/// 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.
/// </summary>
[JsonPropertyName("text"), JsonPropertyOrder(1)]
public PlainTextObject Text { get; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="text">Any text to initiale the Section with</param>
public HeaderBlock(PlainTextObject text) : base("header")
{
Text = text;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="text">Text to display in the header</param>
public HeaderBlock(string text) : this(new PlainTextObject(text))
{
}
}
/// <summary>
/// Extension methods for <see cref="Block"/>
/// </summary>
public static class HeaderBlockExtensions
{
/// <summary>
/// Add an <see cref="HeaderBlock"/> to the list of blocks
/// </summary>
/// <param name="container">List of blocks</param>
/// <param name="text">Text for the header</param>
public static void AddHeader(this ISlackBlockContainer container, PlainTextObject text)
{
HeaderBlock block = new HeaderBlock(text);
container.Blocks.Add(block);
}
/// <summary>
/// Add an <see cref="HeaderBlock"/> to the list of blocks
/// </summary>
/// <param name="container">List of blocks</param>
/// <param name="text">Text for the header</param>
/// <param name="emoji">Whether to enable emoji</param>
public static void AddHeader(this ISlackBlockContainer container, string text, bool? emoji) => AddHeader(container, new PlainTextObject(text, emoji));
}
}