Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

fix(design-system): restore dark-mode contrast on Toggle + destructive borders (#1932)

Guillem Arias Faustef0e270f578eb
diff --git a/app/assets/tailwind/sure-design-system/_generated.css b/app/assets/tailwind/sure-design-system/_generated.css
index 96a966b867..79ae54d430 100644
--- a/app/assets/tailwind/sure-design-system/_generated.css
+++ b/app/assets/tailwind/sure-design-system/_generated.css
@@ -25,6 +25,8 @@
--color-container-inset: var(--color-gray-50);
--color-container-inset-hover: var(--color-gray-100);
--color-nav-indicator: var(--color-black);
+ --color-toggle-track: var(--color-gray-100);
+ --color-destructive-subtle: var(--color-red-200);
--color-gray-25: #FAFAFA;
--color-gray-50: #F7F7F7;
--color-gray-100: #F0F0F0;
@@ -224,6 +226,8 @@
--color-container-inset: var(--color-gray-800);
--color-container-inset-hover: var(--color-gray-700);
--color-nav-indicator: var(--color-white);
+ --color-toggle-track: var(--color-gray-700);
+ --color-destructive-subtle: var(--color-red-800);
--budget-unused-fill: var(--color-gray-500);
--budget-unallocated-fill: var(--color-gray-700);
--shadow-xs: 0px 1px 2px 0px --alpha(var(--color-white) / 8%);
diff --git a/app/components/DS/alert.rb b/app/components/DS/alert.rb
index 050beaf66d..18204cc5e7 100644
--- a/app/components/DS/alert.rb
+++ b/app/components/DS/alert.rb
@@ -38,7 +38,7 @@ class DS::Alert < DesignSystemComponent
when :warning
"bg-warning/10 border-warning/20"
when :error, :destructive
- "bg-destructive/10 border-destructive/20"
+ "bg-destructive/10 border-destructive-subtle"
end
"#{base_classes} #{variant_classes}"
diff --git a/app/components/DS/toggle.rb b/app/components/DS/toggle.rb
index a795574d8f..e45b69051e 100644
--- a/app/components/DS/toggle.rb
+++ b/app/components/DS/toggle.rb
@@ -14,7 +14,12 @@ class DS::Toggle < DesignSystemComponent
def label_classes
class_names(
"relative block w-9 h-5 cursor-pointer",
- "rounded-full bg-surface-inset",
+ # `bg-toggle-track` lifts the dark-mode off-track to gray-700 so the
+ # switch keeps WCAG 1.4.11 contrast against the surrounding
+ # bg-container (gray-900). `bg-surface-inset` resolves to gray-800
+ # in dark mode and dropped to ~1.5:1 against the container,
+ # making the toggle nearly invisible inside modals.
+ "rounded-full bg-toggle-track",
# `motion-safe:` gates the bg + thumb-translate transitions on
# `prefers-reduced-motion`; reduced-motion users get a snap.
"motion-safe:transition-colors motion-safe:duration-300",
diff --git a/app/components/provider_sync_summary.html.erb b/app/components/provider_sync_summary.html.erb
index 5770c4f563..2ddab4b76e 100644
--- a/app/components/provider_sync_summary.html.erb
+++ b/app/components/provider_sync_summary.html.erb
@@ -123,7 +123,7 @@
<% if error_details.any? %>
<details class="mt-1">
<summary class="text-xs cursor-pointer text-secondary hover:text-primary"><%= t("provider_sync_summary.health.view_error_details") %></summary>
- <div class="mt-1 pl-2 border-l-2 border-destructive space-y-1">
+ <div class="mt-1 pl-2 border-l-2 border-destructive-subtle space-y-1">
<% error_details.each do |detail| %>
<p class="text-xs text-destructive">
<% if detail["name"].present? %><strong><%= detail["name"] %>:</strong> <% end %><%= detail["message"] %>
diff --git a/app/views/settings/providers/_connection_row.html.erb b/app/views/settings/providers/_connection_row.html.erb
index 397e8ee15f..21cf30ebd8 100644
--- a/app/views/settings/providers/_connection_row.html.erb
+++ b/app/views/settings/providers/_connection_row.html.erb
@@ -6,7 +6,7 @@
border_class =
case status
when :warn then "border border-warning/25"
- when :err then "border border-destructive/25"
+ when :err then "border border-destructive-subtle"
else "border border-transparent"
end
sync_action = entry[:partial].present? ? render("settings/providers/sync_button", provider_key: entry[:provider_key], last_synced_at: last_synced) : nil
diff --git a/app/views/simplefin_items/edit.html.erb b/app/views/simplefin_items/edit.html.erb
index a350327bff..acc5761e71 100644
--- a/app/views/simplefin_items/edit.html.erb
+++ b/app/views/simplefin_items/edit.html.erb
@@ -28,7 +28,7 @@
</div>
<% if @error_message %>
- <div class="bg-destructive/10 border border-destructive p-4 rounded-lg">
+ <div class="bg-destructive/10 border border-destructive-subtle p-4 rounded-lg">
<div class="flex items-start gap-3">
<%= icon "alert-triangle", size: "sm", class: "text-destructive mt-0.5 flex-shrink-0" %>
<p class="text-sm text-destructive"><%= @error_message %></p>
diff --git a/design/tokens/sure.tokens.json b/design/tokens/sure.tokens.json
index 6e63b3b6b6..bf36e8743c 100644
--- a/design/tokens/sure.tokens.json
+++ b/design/tokens/sure.tokens.json
@@ -35,6 +35,8 @@
"container-inset": { "$value": "{color.gray.50}", "$type": "color", "$extensions": { "sure.dark": "{color.gray.800}" } },
"container-inset-hover": { "$value": "{color.gray.100}", "$type": "color", "$extensions": { "sure.dark": "{color.gray.700}" } },
"nav-indicator": { "$value": "{color.black}", "$type": "color", "$extensions": { "sure.dark": "{color.white}" } },
+ "toggle-track": { "$value": "{color.gray.100}", "$type": "color", "$extensions": { "sure.dark": "{color.gray.700}" } },
+ "destructive-subtle": { "$value": "{color.red.200}", "$type": "color", "$extensions": { "sure.dark": "{color.red.800}" } },
"gray": {
"25": { "$value": "#FAFAFA", "$type": "color" },