Problem/Motivation

Now we have <button> elements and <a> looking as buttons, which is a bad pattern in several ways. But we have some links that need special attention because they should be more descriptive about where they will take you to. More info in this discussion on the previous Github repo issue for buttons.

Proposed resolution

Implement a new component calledAction link to differentiate them from regular links.

Specification

Quick overview

This image is just a quick overview for Horizontal tabs specs. Please use the Figma link to full specification as the main resource for specks.
Action link

Full specification

FIGMA: https://www.figma.com/file/OqWgzAluHtsOd5uwm1lubFeH/Drupal-Design-system...
This link is anchored to the board with the full specification. As an anonymous user you can see the design, but to actually be able to pick colours and sizes please login to Figma.

Remaining tasks

  • Plan which elements will use this component
  • Update patch
  • Accessibility review
  • RTL review (Right to left)

User interface changes

Some anchors previously styled as buttons will be action links now.

Test Pages

  • /node/add/article
CommentFileSizeAuthor
#43 interdiff-3036732-40-43.txt7.24 KBhuzooka
#43 claro-action_link_component-3036732-43.patch36.54 KBhuzooka
#40 interdiff-3036732-35-40.txt14.01 KBhuzooka
#40 claro-action_link-3036732-40.patch37.65 KBhuzooka
#37 actionLinkScreenshots--high-contrast.zip1.76 MBhuzooka
#37 actionLinkScreenshots.zip24.63 MBhuzooka
#36 action-link-spacing.png30.62 KBckrina
#35 interdiff-3036732-29-35.txt2.75 KBhuzooka
#35 claro-action_link_component-3036732-35.patch34.37 KBhuzooka
#31 Screen Shot 2019-09-04 at 20.01.08.png23.39 KBlauriii
#31 Screen Shot 2019-09-04 at 20.00.43.png12.44 KBlauriii
#29 interdiff-3036732-20-29.txt3.52 KBhuzooka
#29 interdiff-3036732-25-29.txt27.83 KBhuzooka
#29 claro-action_link_component-3036732-29.patch34.34 KBhuzooka
#27 interdiff-3036732-20-25.txt26.71 KBhuzooka
#25 claro-action_link_component-3036732-20.png8.77 KBkatrienc
#25 claro-action_link_component-3036732-25.patch7.42 KBkatrienc
#24 Screen Shot 2019-09-03 at 21.40.50.png28.15 KBlauriii
#20 interdiff-3036732-18-20.txt39.06 KBhuzooka
#20 claro-action_link_component-3036732-20.patch32.86 KBhuzooka
#18 interdiff-3036732-15-18.txt10.69 KBhuzooka
#18 claro-action_link_component-3036732-18.patch35.1 KBhuzooka
#16 Screen Shot 2019-09-02 at 16.07.35.png2.35 KBlauriii
#15 interdiff-3036732-11-15.txt25.4 KBhuzooka
#15 claro-action_link_component-3036732-15.patch34.73 KBhuzooka
#11 claro-action_link_component-3036732-11.patch9.55 KBhuzooka
#11 interdiff-3036732-8-11.txt38.54 KBhuzooka
action-link.png28.09 KBckrina
#3 claro-action_link-3036732-3.patch1.69 KBhuzooka
#4 claro-action_link-3036732-4.patch7.25 KBkostyashupenko
#4 Снимок экрана 2019-08-21 в 15.40.59.png40.47 KBkostyashupenko
#4 Снимок экрана 2019-08-21 в 15.41.44.png36.56 KBkostyashupenko
#7 interdiff_4-7.txt6.61 KBant1
#7 claro-action_link-3036732-7.patch9.19 KBant1
#8 interdiff_4-8.txt6.61 KBant1
#8 claro-action_link-3036732-8.patch9.19 KBant1

Comments

ckrina created an issue. See original summary.

ckrina’s picture

huzooka’s picture

StatusFileSize
new1.69 KB

Attached the separated patch from #3021087: Buttons#82

kostyashupenko’s picture

Added patch with realisation of `action-link` component.
Added also "delete" variation of `action-link` component.

So default markup and screen:
<a href="/" class="action-link">Test link</a>
Test link

Delete variation markup and screen:
<a href="/" class="action-link action-link--delete">Delete</a>
Delete

Also this component linked to node/#/edit delete link
Only local images are allowed.

ckrina’s picture

Status: Needs review » Needs work

Thanks @kostyashupenko! I've just done a quick review and I'd suggest to tie the red to the danger variation, but not the icon. Thinking on reusing the icons independently of its color, I'd say each icon should be a variation itself. So the delete action would have .action-link--danger and action-link--trash for example.

ant1’s picture

Assigned: Unassigned » ant1
ant1’s picture

Assigned: ant1 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new6.61 KB
new9.19 KB

Split up .action-link--delete(color) and .action-link--trash(icon).
When both classes are applied on the Action Link, change the color of the trash icon to red.

ant1’s picture

StatusFileSize
new6.61 KB
new9.19 KB

Forgot to change .action-link--delete to .action-link--danger.
Done in this patch.

fhaeberle’s picture

I reviewed this and the patch provided in #8 looks really good already.

I found two trifles:

  1. Only local images are allowed.
    The current delete link looks a bit smaller because of the missing box shadow, that's not even bad but I want to mention it here.
  2. +[dir="rtl"] .action-links {
    +  /* This is required to win over specificity of [dir="rtl"] ul */
    +  margin-right: 0;
    +}
    

    This comment can be moved before/outside the selector.

huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

Assigned: huzooka » Unassigned
StatusFileSize
new38.54 KB
new9.55 KB

Fixed #9.2, and besides that:

What happened:

  1. action-link--trash changed to action-link--icon-trash.
  2. New action link icons are added for covering the ones on the Appearance page (unblocks #3023319: Card Style Update).
  3. Every possible combination of the implemented modifiers should be covered.
  4. I've defined a custom helper callback for transforming ['#type' => 'link'] renderable arrays to action-links: _claro_convert_link_to_action_link((). That's where most of the magic happens.

Some background: previously, @lauriii, @ckrina and I agreed that we need to implement the variation with the trash icon and the variations that are (or will be) used on the Appearance form page.

Think that are still missing:

  1. Cross-browser testing.
  2. Screenshots.

Think that are a bit weird:

  1. It seems to me that the action links on the appearance page are a bit smaller than the 'Delete' link on the node edit page. Is this really true?
  2. Re #9.1: yes, this is really weird, I agree with you.
    Actually, these action-links are now a separately-themed buttons with a white background and with an icon:
    • The link text does not have underline.
    • They have a notable padding (that becomes visible if you interact with them or when they are placed on a dark(er) background)

I'm setting this to Needs review only for testing this patch.

huzooka’s picture

Status: Needs review » Needs work
lauriii’s picture

For anyone interested in working on this, it seems like interdiff and actual patch are mixed in #11.

huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new34.73 KB
new25.4 KB

Re #13: Actually I completely missed adding the main part of the action link component modifications.

Here is the updated patch with high contrast related improvements, so the only remaining task is generating the screenshots.

lauriii’s picture

Issue summary: View changes
StatusFileSize
new2.35 KB

  1. I think we should remove the icon from the default variation and make it it's own variation instead.
  2. +++ b/claro.theme
    @@ -400,6 +402,106 @@ function claro_preprocess_details(&$variables) {
    +function _claro_convert_link_to_action_link(array &$link, $icon_name = NULL, $variant = 'default') {
    

    Any thoughts on returning a new link instead of editing a referenced link? It seems better for readability and more versatile.

  3. +++ b/claro.theme
    --- a/css/src/components/action-links.css
    +++ b/css/src/components/action-links.css
    

    Should we rename this to action-link.css to be more consistent?

huzooka’s picture

Assigned: Unassigned » huzooka
Status: Needs review » Needs work
huzooka’s picture

Addressing #16.

lauriii’s picture

  1. +++ b/claro.theme
    @@ -400,6 +402,108 @@ function claro_preprocess_details(&$variables) {
    +    _claro_convert_link_to_action_link($form['actions']['delete'], 'trash', 'danger');
    ...
    +            _claro_convert_link_to_action_link($links_item['link'], 'cog');
    ...
    +            _claro_convert_link_to_action_link($links_item['link'], 'ex');
    ...
    +            _claro_convert_link_to_action_link($links_item['link'], 'checkmark');
    

    We have to replace the original link with the action link now that we are not changing it as a reference.

  2. +++ b/css/src/components/action-link.css
    @@ -0,0 +1,238 @@
    +  padding: var(--space-m);
    

    According to the design system, the left padding should be 0.75rem.

  3. +++ b/css/src/components/action-link.css
    @@ -0,0 +1,238 @@
    +  -webkit-font-smoothing: antialiased;  /* 3 */
    

    What is this comment referencing to?

  4. +++ b/css/src/components/action-link.css
    @@ -0,0 +1,238 @@
    +/* Plus - default */
    

    We should remove default from the comment.

  5. +++ b/css/src/layout/action-links.css
    @@ -0,0 +1,43 @@
    + * Layout styles for local actions.
    

    👍

huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new32.86 KB
new39.06 KB
lauriii’s picture

Status: Needs review » Needs work

#19.2 is still not solved by #20.

huzooka’s picture

Re #21: You're wrong. It is resolved.

huzooka’s picture

Status: Needs work » Needs review
lauriii’s picture

Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new28.15 KB

Sorry, that was my mistake. I looked at the patch too quickly and didn't notice the change.

  1. +++ b/css/src/components/action-link.css
    @@ -0,0 +1,256 @@
    +    background-image: url("...") !important;
    ...
    +    background-image: url("...") !important;
    ...
    +    background-image: url("...") !important;
    ...
    +    background-image: url("...") !important;
    ...
    +    background-image: url("...") !important;
    

    Any thoughts on using filter instead of replacing the background image? I used this approach on #3023301: Messages style update. This allows us to get rid of the !important and allows us to have one less variation of the icons.


  2. The margins should be still update to match with the design system.
katrienc’s picture

Patch #20 gives wrong padding on .action-link (like mentioned in #19.2)

Only local images are allowed.

On the screenshot I focused the button elements so you could see the wrong padding.

The padding on action-link class should be the same as the button class. Which now is
calc(1rem - 1px) calc(1.5rem - 1px)

I've changed this

huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

Assigned: huzooka » Unassigned
StatusFileSize
new26.71 KB

Adding the missing interdiff between #20 and #25.

huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new34.34 KB
new27.83 KB
new3.52 KB

This patch fixes #24.2 and #25.

Re #24:

  1. I don't want to say that this is not possible, but due to the fact that CSS3 filters represent relative effects, I was unable to find a filter combination that works for dark AND high contrast mode as well. Since Windows 10 provides not only dark and bright high contrast mode, I'd keep this background replacement.
  2. Thanks for pointing this! I think that also the spacing between form-action buttons has changed in the past, so I've fixed those spacing as well.

Re #25:

  1. 👍 Thanks for this! Height was streched because the pseuso element that holds the icon was higher than the ascender height of the font:

    The pseudo has 1rem height while the font's (ascender height + the descender height) was 1rem. I increased the line-height of action-links and decreased their vertical padding.

lauriii’s picture

+++ b/css/src/components/button.css
@@ -42,10 +43,10 @@
+  margin: var(--space-m) var(--space-xs) var(--space-m) 0; /* LTR */
...
+  margin: var(--space-m) 0 var(--space-m) var(--space-xs);

According to the design system, the margin between buttons should be 12px, but the margin between a button and action link should be 8px 🤠

lauriii’s picture

Here's screenshots of the spec:

huzooka’s picture

huzooka’s picture

Status: Needs review » Needs work
huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new34.37 KB
new2.75 KB

This patch applies the most recent design changes for action-links and buttons.

ckrina’s picture

Issue summary: View changes
StatusFileSize
new30.62 KB

We've been discussing with @lauriii a way to make Action Links implementation easier and we've come up with the solution to avoid having a smaller space between Action Links than the one between Buttons. So for M button&Action Links it'll be a 12px spacing, while for S Action Links and S/XS buttons 8px of horizontal spacing:

huzooka’s picture

Srceenshots attached.

lauriii’s picture

Status: Needs review » Needs work
  1. +++ b/css/src/components/action-link.css
    @@ -0,0 +1,276 @@
    +  .action-link--icon-plus::before {
    ...
    +  .action-link--icon-trash::before {
    ...
    +  .action-link--icon-ex::before {
    ...
    +  .action-link--icon-checkmark::before {
    ...
    +  .action-link--icon-cog::before {
    

    Instead of using !important, maybe we should use the duplicate selector trick to increase the weight of this selector.

  2. +++ b/css/src/components/button.css
    @@ -75,6 +76,17 @@
    +/**
    + * Buttons inside form-actions.
    + */
    +.form-actions .button {
    +  margin-right: var(--space-s);
    +}
    +[dir="rtl"] .form-actions .button {
    +  margin-right: 0;
    +  margin-left: var(--space-s);
    +}
    +
    

    I can't find where it is mentioned that this is specific to form actions.

  3. +++ b/claro.theme
    @@ -400,6 +402,117 @@ function claro_preprocess_details(&$variables) {
    + * @param string|null $icon_name
    + *   The name of the icon.
    ...
    +function _claro_convert_link_to_action_link(array $link, $icon_name = NULL, $variant = NULL, $small = FALSE) {
    

    Should we document which icons are available or where to find a list of available icons?

  4. +++ b/claro.theme
    @@ -400,6 +402,117 @@ function claro_preprocess_details(&$variables) {
    +    $link['#attributes'] = NestedArray::mergeDeep(
    +      $link['#attributes'],
    +      $link['#options']['attributes']);
    +  }
    

    It doesn't seem like Drupal\Core\Render\Element\Link::preRenderLink is using the deep merge. I'm wondering if this difference could lead to unwanted changes in behavior 🤔

  5. +++ b/claro.theme
    @@ -400,6 +402,117 @@ function claro_preprocess_details(&$variables) {
    +  // to the attributes of  the Url object.
    

    Nit: there's double space between of and URL.

  6. +++ b/claro.theme
    @@ -400,6 +402,117 @@ function claro_preprocess_details(&$variables) {
    +  // Make entity form's delete link use the action-link component.
    

    Nit: s/form's/forms

huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new37.65 KB
new14.01 KB

This addresses everything from #38 hopefully.

lauriii’s picture

  1. +++ b/claro.theme
    @@ -449,65 +449,101 @@ function claro_preprocess_links(&$variables) {
    +  if ($variant = $variant === NULL && !empty($link['#options']['attributes']['class']) && in_array('button--danger', $link['#options']['attributes']['class'])) {
    +    $variant = 'danger';
    +  }
    ...
    +  if ($small === NULL && !empty($link['#options']['attributes']['class']) && in_array('button--small', $link['#options']['attributes']['class'])) {
    +    $small = TRUE;
       }
    

    This seems a bit overkill to me. I'd just keep the $variant parameter and let that define the variation. Or do we have a specific use case in mind where it couldn't be used?

  2. +++ b/css/src/components/action-link.css
    @@ -154,8 +154,9 @@
    +  .action-link.action-link--icon-plus::before,
    +  .action-link.action-link--icon-plus.action-link--danger::before {
    
    @@ -183,7 +184,8 @@
    +  .action-link.action-link--icon-trash::before,
    +  .action-link.action-link--icon-trash.action-link--danger::before {
    
    @@ -212,7 +214,8 @@
    +  .action-link.action-link--icon-ex::before,
    +  .action-link.action-link--icon-ex.action-link--danger::before {
    
    @@ -241,7 +244,8 @@
    +  .action-link.action-link--icon-checkmark::before,
    +  .action-link.action-link--icon-checkmark.action-link--danger::before {
    

    This is fine, but it might be clearer to just duplicate the same class name because it makes it obvious that it's used for increasing the weight, not to increase the specificity.

huzooka’s picture

Assigned: Unassigned » huzooka
Status: Needs review » Needs work
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new36.54 KB
new7.24 KB

Addressing #41.

  • lauriii committed 6d6f3d0 on 8.x-1.x
    Issue #3036732 by huzooka, AntoineH, kostyashupenko, lot007, lauriii,...
lauriii’s picture

Status: Needs review » Fixed

Looks great! Good job everyone! 👏

lauriii’s picture

Saving issue credits

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.