Link Buttons #733
Replies: 6 comments
-
|
@ashleynolan Thanks for putting this together 🎖️ I prefer approach 2 I think this makes the most amount of sense to me. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the write-up Ash. My say would be the second approach as well. Approach 1 could work, but seeing the pros/cons, 2 seems like the more logical solution. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for this 😄 I like 2 the most too |
Beta Was this translation helpful? Give feedback.
-
|
Hello, I would vote for the second approach as well as the most straight-forward from both our and consumers perspective. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @ashleynolan! I am also happy with approach 2 :) |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @ashleynolan for opening the discussion. Also I lean for option 2 ✅ I think that semantics connect to how things look as patterns for users to look for. For example, if I see a link style most of the times I would interpret that as a navigation action. Hopefully use cases where links are used functionally, or buttons for navigation, are the exception and not the norm :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I wanted to discuss something that has come up recently that we've tackled as part of previous projects – but I wanted to get a consensus among the team over which approach would be best and to give people the opportunity to share their opinion.
Problem Outline
We currently have two components;
pie-buttonandpie-link. As you may suspect,pie-buttonhandles the display and functionality of buttons, and pie-link handles the display and functionality of links.A common pattern in design is to use what looks like a link, but semantically in HTML should function as a button. An example of this can be found in numerous places across JET platforms, but to take one recent example, our redesigned cookie banner also displays this pattern as shown below by the "Manage Preferences" button. This look like a link, but functionally, it opens a modal and so semantically should use a
buttontag.So the question really is, how and where should we cater for this in our PIE component library?
Proposed solutions
Here are the solutions I can think of for this. I'll outline my preferred approach after discussing each in turn:
1. Extend
pie-buttonThis solution extends
pie-buttonto include alinkvariant. This then styles the button to replicate a link, replicating the style ofpie-linkthrough this prop.We currently take this approach in the Fozzie Vue Components:
Pro's
pie-buttonincludes all the necessary a11y labels and helpers built into the button component.type="reset",pie-buttonis already setup to handle this.Con's
linkalready exist inpie-link, so we'd likely need to abstract these out intopie-cssas a mixin so that they could be shared between bothpie-buttonandpie-link.pie-buttonprops like optional icons, loading states,sizesthat aren't relevant for link styling. We would likely need to validate against these to ensure there weren't clashes between use of the button link and these unneeded props.2. Extend
pie-linkThis solution extends
pie-link. This could be done by including atagprop, which acceptsbuttonas a valid option (with the default beinga.Setting this prop to
buttonwould then change thepie-linkto use abuttonHTML tag, while still replicating the style ofpie-link.A similar approach is used currently in the Snacks component library:
Pro's
pie-link, so there isn't any issue with needing them elsewhereCons
reset(could we just allow a type to be passed onto the link tag potentially and validate it?)pie-buttonare replicated when button tags are used withpie-link.href,target,relprops not needed by a button, so will need to make sure they play nicely whenpie-linktag is set to button.3. New component
pie-linkButton/pie-buttonLink(insert best name here 😆 )The other potential option is to create a new component that just focuses on this use case as something that looks like a link, but is semantically a button.
Pro's
Cons
linkalready exist inpie-link, so we'd likely need to abstract these out intopie-cssas a mixin so that they could be shared between bothpie-linkand this new component.pie-link(such assize,variant,isBold,isStandalone). We could likely abstract these out to be shared between the two components, but this may add a level of complication in terms of component architecture.pie-buttonfor this link-button component.pie-linkcomponent before expecting a completely separate component to exist.Preferred Approach
My own preference is Solution 2. Although I think there will be some things we'll need to handle from having a button tag in
pie-link, I don't think it overcomplicates the component.I also think it makes more sense (to me at least, and likely to those looking first at Figma and then to our component library) to look at the link component and then semantically want to make that component a button, rather than the alternatives. I think having a completely separate component is perhaps overkill, while also creating a component that doesn't exists in the design library, so adds the potential for more confusion.
Thoughts?
It would be great to hear your thoughts, either to support one of the above solutions or if you have a solution I've not thought of, feel free to reply detailing it.
Beta Was this translation helpful? Give feedback.
All reactions