//! Methods related to dialog elements.

use crate::dom::element::DomElement;

impl DomElement {
    /// Open the dialog element as a modal
    ///
    /// TODO: Consider having more type safety to reduce the likelihood of
    /// calling this on something that isn't a dialog.
    /// One possible idea would be to have a DialogElement type and put the
    /// show_modal and close methods on the DialogElement type and then have a
    /// way to cast between types.
    pub fn dialog_show_modal(&self) {
        unsafe {
            afia_component_sys::dialog_element_show_modal(
                self.component_imports_ptr(),
                self.to_i64(),
            )
        };
    }

    /// Close the dialog element as a modal
    pub fn dialog_close(&self) {
        unsafe {
            afia_component_sys::dialog_element_close(self.component_imports_ptr(), self.to_i64())
        };
    }
}
