Modal is a dynamically rendered element that floats above the rest of a page's content. It can be especially useful for interstitials that require additional user feedback.
import { DaffModalHeaderComponent } from '@daffodil/design/modal'
@Component()
class DaffModalHeaderComponent {
faXmark: IconDefinition = faXmark
@Input() dismissible: boolean = true
}
boolean
Default | true |
---|---|
Description | Whether or not a modal is dismissible. |
import { DaffModalContentComponent } from '@daffodil/design/modal'
@Component()
class DaffModalContentComponent {
@HostBinding() class: boolean = true
}
import { DaffModalActionsComponent } from '@daffodil/design/modal'
@Component()
class DaffModalActionsComponent {
@HostBinding() class: boolean = true
}
import { DaffModalComponent } from '@daffodil/design/modal'
@Component()
class DaffModalComponent implements AfterContentInit, AfterViewInit, DaffOpenable {
@HostBinding() modalClass: boolean = true
@HostBinding() role: string = 'dialog'
@HostBinding() ariaModal: boolean = true
@HostBinding() ariaLabelledBy: string
animationCompleted: EventEmitter<any> = new EventEmitter<any>()
closedAnimationCompleted: EventEmitter<any> = new EventEmitter<
any
>()
@HostBinding()
get fadeState(): string
get open(): boolean
ngAfterContentInit(): void
ngAfterViewInit(): void
attachContent(portal: ComponentPortal<any>): any
@HostListener() animationDone(e: AnimationEvent_2): void
reveal(): void
hide(): void
toggle(): void
}
boolean
Default | true |
---|---|
Description | Sets a class of .daff-modal to the host element. |
string
Default | 'dialog' |
---|---|
Description | Sets the role to dialog. |
boolean
Default | true |
---|---|
Description | Sets aria-modal to true. |
string
Default | – |
---|---|
Description | The aria-labelledby for the modal. This is set by the id of
|
EventEmitter<any>
Default | new EventEmitter<any>() |
---|---|
Description | Event fired when the close animation is completed. |
EventEmitter<any>
Default | new EventEmitter<
any
>() |
---|---|
Description | Event fired when the close animation is completed. |
string
Default | – |
---|---|
Description | Animation hook that controls the entrance and exit animations of the modal. |
boolean
Default | – |
---|---|
Description |
void
void
any
Helper method to attach portable content to modal.
Parameter | portal: ComponentPortal |
---|---|
Description |
void
Animation event that can used to hook into when animations are fully completed. We use this in the DaffModalService to determine when to actually remove the dynamically rendered element from the DOM so that the animation does not clip as the element is removed.
Parameter | e: AnimationEvent_2 |
---|---|
Description |
void
Reveals the modal
void
Hides the modal
void
Toggles the visibility of the modal
import { DaffModalTitleDirective } from '@daffodil/design/modal'
Title of a modal.
@Directive()
class DaffModalTitleDirective {
@HostBinding()
get uniqueId(): string
}
string
Default | – |
---|---|
Description | The html |
import { DaffModalCloseDirective } from '@daffodil/design/modal'
The DaffModalCloseDirective is a helper directive that passes a click
event to the button it's used with to close a modal. It needs to be
implemented with the <button>
HTML element to work. This helps to
reduce code duplication.
@Directive()
class DaffModalCloseDirective {
@HostBinding() typeAttribute: string = 'button'
@HostListener() _onCloseModal(event: MouseEvent): void
}
string
Default | 'button' |
---|---|
Description | Sets the button type attribute to button. |
void
Event fired when the button the directive is attached to is clicked. This is used to close a modal.
Parameter | event: MouseEvent |
---|---|
Description |
import { DaffModalService } from '@daffodil/design/modal'
@Injectable()
class DaffModalService {
open(
component: Type<any>
configuration?: Partial<DaffModalConfiguration>
): DaffModalComponent
close(component: DaffModalComponent): void
}
Parameter | component: Type |
---|---|
Description |
Parameter | configuration: Partial |
---|---|
Description |
void
Parameter | component: DaffModalComponent |
---|---|
Description |
import { DaffModalModule } from '@daffodil/design/modal'
@NgModule()
class DaffModalModule {}
import { DaffModal } from '@daffodil/design/modal'
interface DaffModal {
modal: ComponentRef<DaffModalComponent>
overlay: OverlayRef
}
modal ComponentRef<DaffModalComponent> |
---|
The reference to the modal in question |
overlay OverlayRef |
---|
The overlay associated with a given modal. |