OctantisWeb.Components.Polaris.Modal (octantis v0.1.12)
View SourceModals are overlays that require merchants to take an action before they can continue interacting with the rest of Shopify. They can be disruptive and should be used thoughtfully and sparingly.
Polaris marks this component as Deprecated
and suggests you use the AppBridge Modal instead.
However, the AppBridge Modal is severly limited and it might be best to still use this for the time being.
See
- https://polaris.shopify.com/components/deprecated/modal
- https://github.com/Shopify/polaris/blob/main/polaris-react/src/components/Modal/Modal.tsx
Open a modal from the server
Hooks.ShopifyModal = {
mounted(){
id = this.el.id
this.handleEvent(`polaris:modal_show_${id}`, (event) => this.liveSocket.execJS(this.el, this.el.getAttribute("data-show")))
this.handleEvent(`polaris:modal_hide_${id}`, (event) => this.liveSocket.execJS(this.el, this.el.getAttribute("data-hide")))
}
}
<.modal id="my_modal_id" title="My Modal" phx_hook="ShopifyModal">
Content
<:action content="Ok"/>
</.modal>
{:noreply, socket |> Modal.push_open("my_modal_id")}
Summary
Functions
Attributes
phx_click
(:string
) - Defaults tonil
.
Attributes
id
(:string
) (required) - id of the modal.title_hidden
(:boolean
) - Hide the title in the modal. Defaults tofalse
.icon
(:any
) - Status icon to display in the header. Defaults tonil
.open
(:boolean
) - Whether the modal is open or not. Defaults tofalse
.size
(:string
) - Set the size of the modal. Defaults tonil
.tone
(:string
) - Sets the status of the banner. Defaults to"tertiary"
.title
(:string
) - The content for the title of the modal. Defaults to""
.limit_height
(:boolean
) - Limits modal height on large sceens with scrolling. Defaults tofalse
.loading
(:boolean
) - Replaces modal content with a spinner while a background action is being performed. Defaults tofalse
.show_backdrop
(:boolean
) - Should the backdrop be show with the modal?. Defaults totrue
.on_close
(:any
) - Callback when the modal clsoe button is clicked.phx_hook
(:string
) - Defaults tonil
.style
(:string
) - Style attribute.display
(:string
) - Style attribute.margin
(:string
) - Style attribute.max_height
(:string
) - Style attribute.min_height
(:string
) - Style attribute.object_fit
(:string
) - Style attribute.flex_grow
(:string
) - Style attribute.justify_content
(:string
) - Style attribute.grid_auto_rows
(:string
) - Style attribute.grid_template_columns
(:string
) - Style attribute.grid_template_rows
(:string
) - Style attribute.align_items
(:string
) - Style attribute.align_self
(:string
) - Style attribute.
Slots
inner_block
action
- Accepts attributes:content
(:string
) - Content the action displays.disabled
(:boolean
) - Whether or not the action is disabled.variant
(:string
) - Changes the visual appearance of the Button.Must be one of"plain"
,"primary"
,"secondary"
,"tertiary"
, or"monochromePlain"
.tone
(:string
) - Sets the color treatment of the Button.Must be one of"critical"
, or"success"
.full_width
(:boolean
) - Allows the button to grow to the width of its container.size
(:string
) - Changes the size of the button, giving it more or less padding.Must be one of"micro"
,"slim"
,"medium"
, or"large"
.navigate
(:string
) - Passes through to .link component.patch
(:string
) - Passes through to .link component.href
(:string
) - Passes through to .link component.target
(:string
) - Passes through to .link component.icon
(:any
) - Source of the icon.Examples include&OctantisWeb.Components.Polaris.Icons.arrow_right/1
.phx_click
(:any
) - Click function passed through to the button.
secondary_action
- Accepts attributes:content
(:string
) - Content the action displays.disabled
(:boolean
) - Whether or not the action is disabled.variant
(:string
) - Changes the visual appearance of the Button.Must be one of"plain"
,"primary"
,"secondary"
,"tertiary"
, or"monochromePlain"
.tone
(:string
) - Sets the color treatment of the Button.Must be one of"critical"
, or"success"
.full_width
(:boolean
) - Allows the button to grow to the width of its container.size
(:string
) - Changes the size of the button, giving it more or less padding.Must be one of"micro"
,"slim"
,"medium"
, or"large"
.navigate
(:string
) - Passes through to .link component.patch
(:string
) - Passes through to .link component.href
(:string
) - Passes through to .link component.target
(:string
) - Passes through to .link component.icon
(:any
) - Source of the icon.Examples include&OctantisWeb.Components.Polaris.Icons.arrow_right/1
.phx_click
(:any
) - Click function passed through to the button.
dismiss_action
- A complext action to use insread of the standard dismiss X. Accepts attributes:content
(:string
) - Content the action displays.disabled
(:boolean
) - Whether or not the action is disabled.variant
(:string
) - Changes the visual appearance of the Button.Must be one of"plain"
,"primary"
,"secondary"
,"tertiary"
, or"monochromePlain"
.tone
(:string
) - Sets the color treatment of the Button.Must be one of"critical"
, or"success"
.full_width
(:boolean
) - Allows the button to grow to the width of its container.size
(:string
) - Changes the size of the button, giving it more or less padding.Must be one of"micro"
,"slim"
,"medium"
, or"large"
.navigate
(:string
) - Passes through to .link component.patch
(:string
) - Passes through to .link component.href
(:string
) - Passes through to .link component.target
(:string
) - Passes through to .link component.icon
(:any
) - Source of the icon.Examples include&OctantisWeb.Components.Polaris.Icons.arrow_right/1
.phx_click
(:any
) - Click function passed through to the button.hidden
(:boolean
)
header
- Pass attrs to the header wrapper, or override it completely.content
- Pass attrs to the content wrapper, or override it completely.footer
- Pass attrs to the header wrapper, or override it completely.
Functions
Attributes
phx_click
(:string
) - Defaults tonil
.
Attributes
id
(:string
) (required) - id of the modal.title_hidden
(:boolean
) - Hide the title in the modal. Defaults tofalse
.icon
(:any
) - Status icon to display in the header. Defaults tonil
.open
(:boolean
) - Whether the modal is open or not. Defaults tofalse
.size
(:string
) - Set the size of the modal. Defaults tonil
.tone
(:string
) - Sets the status of the banner. Defaults to"tertiary"
.title
(:string
) - The content for the title of the modal. Defaults to""
.limit_height
(:boolean
) - Limits modal height on large sceens with scrolling. Defaults tofalse
.loading
(:boolean
) - Replaces modal content with a spinner while a background action is being performed. Defaults tofalse
.show_backdrop
(:boolean
) - Should the backdrop be show with the modal?. Defaults totrue
.on_close
(:any
) - Callback when the modal clsoe button is clicked.phx_hook
(:string
) - Defaults tonil
.style
(:string
) - Style attribute.display
(:string
) - Style attribute.margin
(:string
) - Style attribute.max_height
(:string
) - Style attribute.min_height
(:string
) - Style attribute.object_fit
(:string
) - Style attribute.flex_grow
(:string
) - Style attribute.justify_content
(:string
) - Style attribute.grid_auto_rows
(:string
) - Style attribute.grid_template_columns
(:string
) - Style attribute.grid_template_rows
(:string
) - Style attribute.align_items
(:string
) - Style attribute.align_self
(:string
) - Style attribute.
Slots
inner_block
action
- Accepts attributes:content
(:string
) - Content the action displays.disabled
(:boolean
) - Whether or not the action is disabled.variant
(:string
) - Changes the visual appearance of the Button.Must be one of"plain"
,"primary"
,"secondary"
,"tertiary"
, or"monochromePlain"
.tone
(:string
) - Sets the color treatment of the Button.Must be one of"critical"
, or"success"
.full_width
(:boolean
) - Allows the button to grow to the width of its container.size
(:string
) - Changes the size of the button, giving it more or less padding.Must be one of"micro"
,"slim"
,"medium"
, or"large"
.navigate
(:string
) - Passes through to .link component.patch
(:string
) - Passes through to .link component.href
(:string
) - Passes through to .link component.target
(:string
) - Passes through to .link component.icon
(:any
) - Source of the icon.Examples include&OctantisWeb.Components.Polaris.Icons.arrow_right/1
.phx_click
(:any
) - Click function passed through to the button.
secondary_action
- Accepts attributes:content
(:string
) - Content the action displays.disabled
(:boolean
) - Whether or not the action is disabled.variant
(:string
) - Changes the visual appearance of the Button.Must be one of"plain"
,"primary"
,"secondary"
,"tertiary"
, or"monochromePlain"
.tone
(:string
) - Sets the color treatment of the Button.Must be one of"critical"
, or"success"
.full_width
(:boolean
) - Allows the button to grow to the width of its container.size
(:string
) - Changes the size of the button, giving it more or less padding.Must be one of"micro"
,"slim"
,"medium"
, or"large"
.navigate
(:string
) - Passes through to .link component.patch
(:string
) - Passes through to .link component.href
(:string
) - Passes through to .link component.target
(:string
) - Passes through to .link component.icon
(:any
) - Source of the icon.Examples include&OctantisWeb.Components.Polaris.Icons.arrow_right/1
.phx_click
(:any
) - Click function passed through to the button.
dismiss_action
- A complext action to use insread of the standard dismiss X. Accepts attributes:content
(:string
) - Content the action displays.disabled
(:boolean
) - Whether or not the action is disabled.variant
(:string
) - Changes the visual appearance of the Button.Must be one of"plain"
,"primary"
,"secondary"
,"tertiary"
, or"monochromePlain"
.tone
(:string
) - Sets the color treatment of the Button.Must be one of"critical"
, or"success"
.full_width
(:boolean
) - Allows the button to grow to the width of its container.size
(:string
) - Changes the size of the button, giving it more or less padding.Must be one of"micro"
,"slim"
,"medium"
, or"large"
.navigate
(:string
) - Passes through to .link component.patch
(:string
) - Passes through to .link component.href
(:string
) - Passes through to .link component.target
(:string
) - Passes through to .link component.icon
(:any
) - Source of the icon.Examples include&OctantisWeb.Components.Polaris.Icons.arrow_right/1
.phx_click
(:any
) - Click function passed through to the button.hidden
(:boolean
)
header
- Pass attrs to the header wrapper, or override it completely.content
- Pass attrs to the content wrapper, or override it completely.footer
- Pass attrs to the header wrapper, or override it completely.