defmodule SurfaceBulma.StaticTable do @moduledoc """ A static Bulma HTML table. You can create a table by passing `data` to it and defining columns using the `Table.Column` component. """ use Surface.Component @doc "The data that populates the table internal" prop data, :generator, required: true, root: true @doc "The table is expanded (full-width)" prop expanded, :boolean, default: true @doc "Add borders to all the cells" prop bordered, :boolean, default: false @doc "Add stripes to the table" prop striped, :boolean, default: false @doc "The CSS class for the wrapping `
` element" prop class, :css_class @doc """ A function that returns a class for the item's underlying `` element. The function receives the item and index related to the row. """ prop row_class, :fun @doc "The columns of the table" slot cols, generator_prop: :data, required: true def render(assigns) do ~F"""
{#for col <- @cols, col.show == true} {/for}
{col.label}
<#slot {col} generator_value={item} />
""" end defp row_class_fun(nil), do: fn _, _ -> "" end defp row_class_fun(row_class), do: row_class end