ryoung786
Wrapping Flop.Phoenix.table/1, how to avoid missing required slot warning
I’m using the excellent Flop and Flop.Phoenix libraries to handle sorting/filtering/etc, but I’ve run into an annoying warning I haven’t been able to solve.
I want to wrap the provided Flop.Phoenix.table/1 component together with some pagination and styling so that I can re-use it in multiple places throughout my app. I’ve come up with the following, which works well:
def flop_table(assigns) do
~H"""
<div class="flex flex-col items-center gap-4">
<Flop.Phoenix.table
opts={[table_attrs: [class: "table table-zebra w-full"]]}
{assigns}
>
</Flop.Phoenix.table>
<.pagination meta={@meta} path={@path} />
</div>
"""
end
The only problem is that I get this warning:
warning: missing required slot "col" for component Flop.Phoenix.table/1
That makes sense – I’m not explicitly setting the col slot there, but I don’t know a way around this. Is there an idiomatic way to tackle this?
Marked As Solved
ryoung786
After thinking on this a bit, I ended up with something that I think works, but I’m open to other ideas!
def flop_table_and_pagination(assigns) do
~H"""
<div class="flex flex-col items-center gap-4">
{render_slot(@inner_block)}
<.pagination meta={@meta} path={@path} />
</div>
"""
end
def flop_table_opts(pointer_on_hover? \\ true) do
[
table_attrs: [class: "table table-zebra w-full"],
tbody_tr_attrs: [
class:
Enum.join(["hover:bg-base-content/10 ", pointer_on_hover? && "hover:cursor-pointer"])
]
]
end
Then usage is something like
<.flop_table_and_pagination meta={meta} path={~p"/foo"}>
<Flop.Phoenix.table opts={flop_table_opts()} ...>
<:col let={foo} label="Bar" field={:bar}>{foo.bar}</:col>
...
</Flop.Phoenix.table>
</.flop_table_and_pagination>
0
Popular in Questions
For example for a current url like
http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2,
I would like to get:
...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
I am trying to implement my new.html.eex file to create new posts on my website.
new.html.eex:
<h1>Create Post</h1>
<%= ...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I’m writing a test for one of the...
New
Other popular topics
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I forese...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Hi!
Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









