Skip to content

Commit

Permalink
v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nhobes committed Oct 2, 2024
1 parent 64afde9 commit ff5a3ff
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog
### 2.1.0 - 2024-10-02 03:12:09

- Adds new ghost table variant for extremely clean look

### 2.0.6 - 2024-09-26 04:23:16

- Items center correctly for the Icon Button by @mitkins in https://github.com/petalframework/petal_components/pull/352
Expand Down
7 changes: 5 additions & 2 deletions assets/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
}

.pc-icon-button__inner {
@apply flex flex-col items-center
@apply flex flex-col items-center
}

.pc-icon-button__inner--tooltip {
Expand Down Expand Up @@ -1001,9 +1001,12 @@

/* Table */

.pc-table {
.pc-table--surface {
@apply min-w-full overflow-hidden rounded-sm shadow table-auto ring-1 ring-gray-200 dark:ring-gray-800 sm:rounded;
}
.pc-table--ghost {
@apply min-w-full overflow-hidden table-auto;
}
.pc-table__th {
@apply px-6 py-3 text-sm font-semibold tracking-wider text-left text-gray-900 bg-gray-50 dark:bg-gray-800 dark:text-gray-300;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/petal_components/table.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defmodule PetalComponents.Table do
"""
attr :id, :string
attr :class, :any, default: nil, doc: "CSS class"
attr :variant, :string, default: "surface", values: ["ghost", "surface"]
attr :rows, :list, default: [], doc: "the list of rows to render"
attr :row_id, :any, default: nil, doc: "the function for generating the row id"
attr :row_click, :any, default: nil, doc: "the function for handling phx-click on each row"
Expand Down Expand Up @@ -46,7 +47,7 @@ defmodule PetalComponents.Table do
assigns = assign_new(assigns, :id, fn -> "table_#{Ecto.UUID.generate()}" end)

~H"""
<table class={["pc-table", @class]} {@rest}>
<table class={["pc-table--#{@variant}", @class]} {@rest}>
<%= if length(@col) > 0 do %>
<thead>
<.tr>
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule PetalComponents.MixProject do
use Mix.Project

@source_url "https://github.com/petalframework/petal_components"
@version "2.0.6"
@version "2.1.0"

def project do
[
Expand Down
14 changes: 13 additions & 1 deletion test/petal/table_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,19 @@ defmodule PetalComponents.TableTest do
""")

assert html =~ "<table"
assert html =~ "pc-table"
assert html =~ "pc-table--surface"
end

test "Basic table (ghost variant)" do
assigns = %{}

html =
rendered_to_string(~H"""
<.table variant="ghost"></.table>
""")

assert html =~ "<table"
assert html =~ "pc-table--ghost"
end

test "tr" do
Expand Down

0 comments on commit ff5a3ff

Please sign in to comment.