fly-close

Migrating fly-close


Source component

Buttons with a fly-close class, typically with a close icon inside.

Target component

A Pluma component's default close behavior, or a PlumaCloseButton where appropriate.

Mapping

Modals

fly-close is commonly used in FlyModal components, usually as a close button next to the modal's title.

Refer to the FlyModal migration docs for details on this type of migration.

When converting FlyModal to PlumaModal, the ideal scenario is to use PlumaModal's default behavior, which is to pass in a @title string argument, and an @onClose callback argument. With this, a PlumaModal will render the correct header, and a close "X" button in the correct position.

For example:

Source:

{{#if this.isModalOpen}}
  <FlyModal @onClose={{this.closeModal}} as |onClose|>
    <header class="fly-panel-header">
      <h3 class="fly-panel-title">
        Modal title
      </h3>

      <button type="button" class="fly-close" {{on "click" onClose}}>
        <FlyIcon @icon="close" />
      </button>
    </header>

    <div class="fly-panel-body">
      <PlumaParagraph>Modal content</PlumaParagraph>
    </div>
  </FlyModal>
{{/if}}

Target:

<PlumaModal @title="Modal title" @isOpen={{this.isModalOpen}} @onClose={{this.closeModal}}>
  <PlumaModalBody>
    <PlumaParagraph>Modal content</PlumaParagraph>
  </PlumaModalBody>
</PlumaModal>

It's also possible to build custom header sections in PlumaModal, which is described in the FlyModal migration docs.

Tags

A fly-tag might be used with a close button, to indicate that it's dismissable or deletable. PlumaTag supports this by default with an @onDelete argument, as described in the FlyTag migration docs.

Source:

<span class="fly-tag">
  {{tag.name}}

  <button
    data-test-remove-tag={{tag.id}}
    aria-hidden="true"
    class="fly-close ml-0.5"
    disabled={{@readOnly}}
    type="button"
    {{on "click" (perform this.removeTagTask tag)}}
  >
    <FlyIcon @icon="close" @size="sm" class="block" />
    <span class="sr-only">Remove tag</span>
  </button>
</span>

Target:

<PlumaTag @onDelete={{fn this.removeTagTask.perform tag}} @isDisabled={{@readOnly}}>
  {{tag.name}}
</PlumaTag>

Custom

When no appropriate Pluma component exists (with "close" or "delete" functionality), a PlumaCloseButton can be used.

Source:

<button
  class="fly-close"
  type="button"
  {{on "click" this.removeItem}}
>
  <FlyIcon @icon="close" />
  <span class="sr-only">Remove</span>
</button>

Target:

<PlumaCloseButton @onClick={{this.removeItem}} aria-label="Remove" />