Class: Courier::Models::ElementalActionNode

Inherits:
ElementalBaseNode show all
Defined in:
lib/courier/models/elemental_action_node.rb,
sig/courier/models/elemental_action_node.rbs

Defined Under Namespace

Modules: Style

Instance Attribute Summary collapse

Attributes inherited from ElementalBaseNode

#channels, #if_, #loop_, #ref

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], coerce, #deconstruct_keys, #deep_to_h, dump, fields, hash, #hash, inherited, inspect, #inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, inspect, #inspect, meta_info, new_coerce_state, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initialize(content:, href:, action_id: nil, align: nil, background_color: nil, border_radius: nil, border_size: nil, disable_tracking: nil, font_size: nil, locales: nil, padding: nil, style: nil) ⇒ Object

Some parameter documentations has been truncated, see Courier::Models::ElementalActionNode for more details.

Allows the user to execute an action. Can be a button or a link.

Parameters:

  • content (String) —

    The text content of the action shown to the user.

  • href (String) —

    The target URL of the action.

  • action_id (String, nil) (defaults to: nil) —

    A unique id used to identify the action when it is executed.

  • align (Symbol, Courier::Models::Alignment, nil) (defaults to: nil) —

    The alignment of the action button. Defaults to "center".

  • background_color (String, nil) (defaults to: nil) —

    The background color of the action button.

  • border_radius (String, nil) (defaults to: nil) —

    CSS border-radius applied to the action button. For example, 4px

  • border_size (String, nil) (defaults to: nil) —

    CSS border width applied to the action button. For example, 1px

  • disable_tracking (Boolean, nil) (defaults to: nil) —

    When true, the action's href is not rewritten for click-through tracking, even w

  • font_size (String, nil) (defaults to: nil) —

    CSS font-size applied to the action button label. For example, 14px

  • locales (Hash{Symbol=>Courier::Models::LocaleItem}, nil) (defaults to: nil) —

    Region specific content. See [locales docs](https://www.courier.com/docs/platfor

  • padding (String, nil) (defaults to: nil) —

    CSS padding applied to the action button. For example, 8px 16px

  • style (Symbol, Courier::Models::ElementalActionNode::Style, nil) (defaults to: nil) —

    How prominent the action should be. button is the default, secondary and `te



# File 'lib/courier/models/elemental_action_node.rb', line 94

Instance Attribute Details

#action_id ⇒ String?

A unique id used to identify the action when it is executed.

Parameters:

  • _ (String, nil)

Returns:

  • (String, nil)


22
# File 'lib/courier/models/elemental_action_node.rb', line 22

optional :action_id, String, nil?: true

#align ⇒ Symbol, ...

The alignment of the action button. Defaults to "center".

Parameters:

  • _ (Courier::Models::alignment, nil)

Returns:



28
# File 'lib/courier/models/elemental_action_node.rb', line 28

optional :align, enum: -> { Courier::Alignment }, nil?: true

#background_color ⇒ String?

The background color of the action button.

Parameters:

  • _ (String, nil)

Returns:

  • (String, nil)


34
# File 'lib/courier/models/elemental_action_node.rb', line 34

optional :background_color, String, nil?: true

#border_radius ⇒ String?

CSS border-radius applied to the action button. For example, 4px

Parameters:

  • _ (String, nil)

Returns:

  • (String, nil)


40
# File 'lib/courier/models/elemental_action_node.rb', line 40

optional :border_radius, String, nil?: true

#border_size ⇒ String?

CSS border width applied to the action button. For example, 1px

Parameters:

  • _ (String, nil)

Returns:

  • (String, nil)


46
# File 'lib/courier/models/elemental_action_node.rb', line 46

optional :border_size, String, nil?: true

#content ⇒ String

The text content of the action shown to the user.

Parameters:

  • _ (String)

Returns:

  • (String)


10
# File 'lib/courier/models/elemental_action_node.rb', line 10

required :content, String

#disable_tracking ⇒ Boolean?

When true, the action's href is not rewritten for click-through tracking, even when click-through tracking is enabled for the workspace.

Parameters:

  • _ (Boolean, nil)

Returns:

  • (Boolean, nil)


53
# File 'lib/courier/models/elemental_action_node.rb', line 53

optional :disable_tracking, Courier::Internal::Type::Boolean, nil?: true

#font_size ⇒ String?

CSS font-size applied to the action button label. For example, 14px

Parameters:

  • _ (String, nil)

Returns:

  • (String, nil)


59
# File 'lib/courier/models/elemental_action_node.rb', line 59

optional :font_size, String, nil?: true

#href ⇒ String

The target URL of the action.

Parameters:

  • _ (String)

Returns:

  • (String)


16
# File 'lib/courier/models/elemental_action_node.rb', line 16

required :href, String

#locales ⇒ Hash{Symbol=>Courier::Models::LocaleItem}?

Region specific content. See locales docs for more details.

Parameters:

  • _ (Courier::Models::locales, nil)

Returns:



67
# File 'lib/courier/models/elemental_action_node.rb', line 67

optional :locales, -> { Courier::Internal::Type::HashOf[Courier::LocaleItem] }, nil?: true

#padding ⇒ String?

CSS padding applied to the action button. For example, 8px 16px

Parameters:

  • _ (String, nil)

Returns:

  • (String, nil)


73
# File 'lib/courier/models/elemental_action_node.rb', line 73

optional :padding, String, nil?: true

#style ⇒ Symbol, ...

How prominent the action should be. button is the default, secondary and tertiary are the other two button styles, and link renders as inline text rather than a button.

Each channel draws these as closely as its medium allows. Email fills button, outlines secondary, and underlines tertiary. The in-app Inbox fills button, outlines secondary, and draws tertiary as a solid button. Slack renders all three as Block Kit buttons, with secondary in Slack's primary style and tertiary in its danger style.

background_color is the fill for button, and the border and label color for secondary. For tertiary it colors the underline and label in email and the fill in the Inbox. It does not apply to link. An Inbox theme that sets its own action colors takes precedence over the template.



92
# File 'lib/courier/models/elemental_action_node.rb', line 92

optional :style, enum: -> { Courier::ElementalActionNode::Style }, nil?: true

Instance Method Details

#to_hash ⇒ {

Returns:

  • ({)


85
# File 'sig/courier/models/elemental_action_node.rbs', line 85

def to_hash: -> {