Description
Currently, the way to provide what we render for default, ascending and descending sort options for the collection_order_toggle_indicator
component is only via a "text" option. Also, options for asc
and desc
are rendered as "unescaped", while the default
option gets rendered as plaintext. I can see the why behind this (perhaps to provide some unicode characters as the ascending and descending arrows and wanting those to be unescaped).
I feel a bit limited by the current behavior. Instead, I'd like to use arrow bs_icon
s for example on matestack-ui-bootstrap for these or provide my own rendering or template for what these should render. I propose using slots somewhat similar to the interface as we have in bs_card
on matestack-ui-bootstrap, where you can provide a body
via a text option or define a method that provides the rendering for body
and add it as a slot.
Also, I'd like default
, asc
, and desc
as text to all render as plaintext and not some plaintext and some unescaped. If we want unescaped text for asc
and desc
we could have the text be unescaped from the caller's side. This is more flexible in my opinion and doesn't hide the fact that whatever string/text is passed in as an argument is unescaped.
An example of the desired API would look something like this:
# EXAMPLE 1
# all rendered as plaintext
collection_order_toggle_indicator(
key: :title,
default: "unsorted",
asc: "asc",
desc: "desc"
)
# EXAMPLE 2
# or some as custom provided slots
collection_order_toggle_indicator(
key: :title,
default: "unsorted",
slots: {
asc: method(:asc_partial)
}
desc: "desc"
)
def asc_partial
span do
plain "I came from a method"
end
end
# EXAMPLE 3
# or all as custom provided slots
collection_order_toggle_indicator(
key: :title,
slots: {
default: method(:default_partial),
asc: method(:asc_partial),
desc: method(:desc_partial)
}
)
def default_partial
plain "We all came from a method"
end
def asc_partial
plain "We all came from a method"
end
def desc_partial
plain "We all came from a method"
end