Introduce a primary-danger link/button class for contexts where the primary operation is a destructive one, such as confirm forms for entity deletion. The primary button submits the form and deletes the entity, so it should not be marked blue, but red.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

LewisNyman’s picture

Issue tags: +styleguide, +Usability, +CSS, +frontend
cfox612’s picture

Is this for a specific theme? Both Bartik and Seven? All core themes?

Xano’s picture

This must be theme-agnostic, because the classes will be set in module code.

LewisNyman’s picture

The button_types are set in module code, but what a theme chooses to do with it is up to them. We only need to implement the CSS in Seven for now in my opinion.

cmanalansan’s picture

Status: Active » Needs review
FileSize
1.9 KB

I added the CSS classes only, but did not update any styles to any themes.

LewisNyman’s picture

Status: Needs review » Needs work

All the other button class variants are set with using #button-type correct? Shouldn't we be using that here? In any case the class that would need to be added would be button--primary-danger

lauriii’s picture

Status: Needs work » Needs review
FileSize
2.45 KB
13.39 KB
12.82 KB
11.08 KB

Created a style for the button with the danger color presented in the Seven style guide.

I think we should use the button type functionality because it doesn't require any extra code.

Here's pictures of the button:

Normal:
Normal

Hover:
Hover

Focus:
Focus

cmanalansan’s picture

FileSize
1.92 KB

I changed the class to button--primary-danger.

One thing to consider before deriving this class from #button-type:
#button-type only stores one value. From what I can tell, it can be either 'primary' or 'danger' but not both.

We can address this in several ways:

  1. Create a third #button_type called primary-danger. Any elements with this #button type will have the class button--primary-danger
  2. Change #button_type to be an array instead of a string. Any elements with #button_type => array('primary', 'danger'):
  • ... will have the class button--primary-danger - OR -
  • ... will have the classes button--primary and button--danger - OR -
  • ... will have the classes button--primary, button--danger, and button-primary-danger

The best approach here depends on this question: what do you aim to benefit from changing the #button_type?

cmanalansan’s picture

FileSize
13.39 KB

Pardon me, did not mean to remove focus.png file

cmanalansan’s picture

Status: Needs review » Needs work

Actually, I agree with lauriii, I'm currently extending his patch to include ContentEntityConfirmFormBase and EntityConfirmFormBase

cmanalansan’s picture

Status: Needs work » Needs review
FileSize
4.27 KB

Based on lauriii's patch.

Bojhan’s picture

I am not following this, this is about adding a class. The Seven style guide already has a style for remove actions. This patch shouldn't change anything about Seven.

Xano’s picture

I am not familiar with the existing class for remove actions, but this issue is about a generic approach for any primary button that performs a dangerous action. Would you say that is unnecessary, an addition to the remove class, or a replacement for it?

LewisNyman’s picture

@Bojhan Can we consistently call the 'remove' class the 'danger' class to reduce confusion? That's how it's set up in the CSS files and we should be describing it's purpose instead of one use case.

Bojhan’s picture

@Lewis Sure :)

cmanalansan’s picture

I went ahead and removed the changes to the Seven theme.

cmanalansan’s picture

Ack, disregard patch 16, this is the correct one.

idebr’s picture

How does this relate to the danger button that is being added in #2123731: edit CSS file using .button:not(a.button--danger) so that no reset is needed on button--danger? Are we creating both a link--danger and a button--danger?

LewisNyman’s picture

@idebr yes maybe that is the most sensible way to do it, as this danger button styling shares a lot of styling with other buttons

idebr’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

What would be the use case for 'link--danger' if there is already a 'button--danger' with the exact same styling? Is the scope for this issue limited to link--danger or does it also touch button--danger?

Either way:

  1. The last patch is inconsistent with the proposed resolution
  2. @Bojhan in #12:
    The Seven style guide already has a style for remove actions. This patch shouldn't change anything about Seven.

    It doesn't seem like we should introduce a new UI element at this stage.

  3. And if we do, the patch needs the CSS for create the link styling
mondrake’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
1.73 KB
13.09 KB

Just had a try combining #7 with parts of #2469929-18: The confirmation forms' cancel link should be styled as a button, just to see how it looks. Screenshot on top of #2469929: The confirmation forms' cancel link should be styled as a button.

Screenshot:

Status: Needs review » Needs work

The last submitted patch, 21: 2278715-21.patch, failed testing.

mondrake queued 21: 2278715-21.patch for re-testing.

mondrake’s picture

Status: Needs work » Needs review

Green.

Bojhan’s picture

Nope, we are not doing this. Please see the style guide https://groups.drupal.org/node/283223

LewisNyman’s picture

@Bojhan But the styleguide is not a static design, we're proposing an addition to fill a gap in the styleguide. Or we should add guidance on which button type to use when the action is both primary and dangerous. What do you think?

Bojhan’s picture

I don't think we should have "red" buttons. I think we should only have deletes that are styled as links.

LewisNyman’s picture

Issue summary: View changes
FileSize
233.21 KB

@Bojhan Do you mean like this?

lauriii’s picture

LOL thats awesome UX!

Bojhan’s picture

Hmmpf, I guess neither options are really nice.

I am not sure if the delete button class is the right direction though, it will most likely be abused a lot. When its "Delete | Cancel" its kinda fine. But when its Save | Delete for example, you really don't want this.

yoroy’s picture

FileSize
23.11 KB

What I see under OS X is that even the confirmation dialog of a delete action does not make the delete action the primary one.

screenshot of an OS X delete confirmation dialog

If it's a destructive action, maybe it's indeed better to deliberately *not* present the second button/link for confirming the deletion as the primary one. In short, I'm not convinced we need to do something about this.

LewisNyman’s picture

Status: Needs review » Closed (won't fix)

Makes sense to me.