Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ ActiveAdmin 4 keeps its menu in a left sidebar and gives breadcrumbs and titles
- Index tables scroll sideways when they are wider than the screen, and cells stay on one line.
- Theme 3 colors, density, and typography on top of ActiveAdmin 4's own dark mode.

Theme 4 needs ActiveAdmin 4 (`>= 4.0.0.beta23`) and Ruby 3.3 or newer. For ActiveAdmin 3, use theme 3.x (branch `3.x`). See [docs/migrating-from-v3.md](docs/migrating-from-v3.md).
Theme 4 needs ActiveAdmin 4 (`>= 4.0.0.beta23`) and Ruby 3.3 or newer. To upgrade from theme 3, see [docs/migrating-from-v3.md](docs/migrating-from-v3.md).

| ActiveAdmin | Theme | Install | Docs |
| --- | --- | --- | --- |
| 4 | 4.0.0.beta1 | `gem "active_admin_theme", github: "activeadmin-plugins/active_admin_theme", tag: "v4.0.0.beta1"` | this README |
| 3 | 3.3.0, maintained on the [`3.x`](https://github.com/activeadmin-plugins/active_admin_theme/tree/3.x) branch | `gem "active_admin_theme", "~> 3.3"` (RubyGems) | [v3.3.0 README](https://github.com/activeadmin-plugins/active_admin_theme/blob/v3.3.0/README.md) |

## Screenshots

Expand Down
14 changes: 10 additions & 4 deletions app/tailwind/active_admin_theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@
.data-table :where(tbody > tr.selected) > td {
background-color: var(--aat-selected-row);
}
/* A table_for in a panel scrolls sideways instead of widening the page. */
.panel-body:has(> .data-table) {
/* A table_for in a panel or a tab scrolls sideways instead of widening the page. */
.panel-body:has(> .data-table),
.aat-tab-panel:has(> .data-table) {
overflow-x: auto;
}
/* Opt-in sticky first column. Body cells keep the stripe, hover and selected fills above. */
Expand Down Expand Up @@ -696,7 +697,12 @@ body {
display: none;
}

/* v3 drew EMPTY in #bbb in both modes; ActiveAdmin's dark gray-600/50 is barely readable. */
/* ActiveAdmin's gray-400/50 and dark gray-600/50 are barely readable. These
* grays keep about 3:1 on white and 4.6:1 on the dark panel, well under values,
* so EMPTY stays readable and reads as a blank. */
.attributes-table-empty-value {
color: #8f969e;
Comment on lines +703 to +704

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is deliberate. EMPTY is a placeholder for a missing value, so it has to read as dimmer than real values. #8f969e is 2.99:1 on white, right at the 3:1 AA level for large text, and keeps EMPTY clearly apart from values (12.4:1). The 4.5:1 alternative, #6b7177 (4.9:1), made EMPTY look like a value. Leaving this open for maintainers to weigh in.

}
.dark .attributes-table-empty-value {
color: #bbbbbb;
color: #8a929c;
}
2 changes: 1 addition & 1 deletion docs/migrating-from-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Theme 4 is a rework for ActiveAdmin 4. ActiveAdmin 4 replaced SCSS and Sprockets with Tailwind CSS 4, ERB partials, and import maps, so theme 3 cannot run on it. On screen the result looks almost the same. In your app, a few things change.

Upgrade ActiveAdmin first, and follow ActiveAdmin's own [upgrade guide](https://github.com/activeadmin/activeadmin/blob/master/UPGRADING.md). Then switch the theme. Theme 3.x stays on the `3.x` branch and keeps getting bug fixes.
Upgrade ActiveAdmin first, and follow ActiveAdmin's own [upgrade guide](https://github.com/activeadmin/activeadmin/blob/master/UPGRADING.md). Then switch the theme. Theme 3 stays on RubyGems as 3.3.0, with its docs in the [v3.3.0 README](https://github.com/activeadmin-plugins/active_admin_theme/blob/v3.3.0/README.md). Theme 3 fixes go to the [`3.x`](https://github.com/activeadmin-plugins/active_admin_theme/tree/3.x) branch.

## Checklist

Expand Down
9 changes: 9 additions & 0 deletions test/components_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ def test_table_in_a_panel_scrolls_with_a_sticky_first_column
assert_equal style(second, "backgroundColor"), style(first, "backgroundColor")
end

def test_table_in_a_tab_scrolls_inside_the_tab
tab = "#tab-table .aat-tab-panel:not(.hidden)"
assert_equal "auto", style(tab, "overflowX")
right = ->(sel) { page.evaluate_script("document.querySelector(#{sel.to_json}).getBoundingClientRect().right") }
assert page.evaluate_script("(() => { const e = document.querySelector(#{tab.to_json}); return e.scrollWidth > e.clientWidth })()")
assert_operator right.(tab), :<=, right.("#tab-table")
assert_operator page.evaluate_script("document.documentElement.scrollWidth"), :<=, 1280
end

def test_body_uses_the_v3_font_without_antialiasing
assert_match(/\A"Helvetica Neue", Arial/, style("body", "fontFamily"))
assert_equal "auto", style("body", "webkitFontSmoothing")
Expand Down
11 changes: 11 additions & 0 deletions test/dummy/app/admin/components_demo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@
end
end

panel "Table in tabs", id: "tab-table" do
tabs do
tab "Wide table" do
table_for (1..2).to_a do
(1..20).each { |c| column("Column #{c}") { |r| "row #{r} / value #{c}" } }
end
end
tab("Other") { para "Another tab" }
end
end

panel "Secret reveal" do
div(id: "secret") { secret_reveal url: "/admin/components/secret" }
end
Expand Down
32 changes: 30 additions & 2 deletions test/form_look_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,38 @@ def test_tabs_in_a_form_keep_their_look_in_dark_mode
assert_equal "rgba(0, 0, 0, 0)", style("#form-panels .aat-panel-toggle", "backgroundColor")
end

def test_empty_values_are_as_bright_as_v3_in_dark_mode
# Contrast ratio (WCAG 2) of the text of +selector+ against the first
# opaque background behind it.
def contrast(selector)
page.evaluate_script(<<~JS)
(() => {
const rgb = (value) => value.match(/[\\d.]+/g).map(Number)
const lum = ([r, g, b]) => [r, g, b].map((c) => { c /= 255; return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4 })
.reduce((sum, c, i) => sum + c * [0.2126, 0.7152, 0.0722][i], 0)
let el = document.querySelector(#{selector.to_json})
const fg = lum(rgb(getComputedStyle(el).color))
while (el && (rgb(getComputedStyle(el).backgroundColor)[3] === 0)) el = el.parentElement
const bg = lum(rgb(getComputedStyle(el || document.body).backgroundColor))
return (Math.max(fg, bg) + 0.05) / (Math.min(fg, bg) + 0.05)
})()
JS
end

def test_empty_values_are_dimmer_than_values_but_readable_in_dark_mode
visit "/admin/components"
page.execute_script("document.documentElement.classList.add('dark')")
assert_equal "rgb(187, 187, 187)", style("#pre-wrap-blank .attributes-table-empty-value", "color")
empty = "#pre-wrap-blank .attributes-table-empty-value"
assert_equal "rgb(138, 146, 156)", style(empty, "color")
assert_operator contrast(empty), :>=, 4.5
assert_operator contrast(empty), :<, contrast("#pre-wrap") / 2
end

def test_empty_values_are_dimmer_than_values_but_readable_in_light_mode
visit "/admin/components"
empty = "#pre-wrap-blank .attributes-table-empty-value"
assert_equal "rgb(143, 150, 158)", style(empty, "color")
assert_operator contrast(empty), :>=, 2.95
assert_operator contrast(empty), :<, contrast("#pre-wrap") / 2
end

def test_a_panel_after_the_form_actions_has_a_gap
Expand Down