Skip to content

Commit

Permalink
Add destructive primary action to modal (#431)
Browse files Browse the repository at this point in the history
feat: add destructive primary action to modal
  • Loading branch information
remy727 authored Jul 13, 2024
1 parent 9d4aab8 commit fb7cf35
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/assets/stylesheets/polaris_view_components.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion app/assets/stylesheets/polaris_view_components/button.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ html[class~="Polaris-Summer-Editions-2023"] .Polaris-Button {
}

/* Destructive */
&.Polaris-Button--destructive {
&.Polaris-Button--destructive,
&.Polaris-Button--destructive:is(.Polaris-Button--primary) {
--pc-button-color: var(--p-color-bg-fill-critical);
--pc-button-text: var(--p-color-bg-surface);
--pc-button-color-hover: var(--p-color-bg-fill-critical-hover);
Expand Down
3 changes: 3 additions & 0 deletions demo/app/previews/modal_component_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def multiple_sections
def with_primary_action
end

def with_destructive_primary_action
end

def without_title
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%= polaris_button(data: {
controller: "polaris",
target: "#demo-modal",
action: "polaris#openModal",
}) { "Open" } %>
<%= polaris_modal(
id: "demo-modal",
title: "Reach more shoppers with Instagram product tags",
open: true,
) do |modal| %>
<%= polaris_text_container do %>
<p>
Use Instagram posts to share your products with millions of
people. Let shoppers buy from your store without leaving
Instagram.
</p>
<% end %>
<% modal.with_primary_action(destructive: true) { "Discard changes" } %>
<% modal.with_secondary_action(data: { action: "polaris-modal#close" }) { "Continue editing" } %>
<% end %>

0 comments on commit fb7cf35

Please sign in to comment.