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.
-
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-button
andpie-link
. As you may suspect,pie-button
handles 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
button
tag.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-button
This solution extends
pie-button
to include alink
variant. This then styles the button to replicate a link, replicating the style ofpie-link
through this prop.We currently take this approach in the Fozzie Vue Components:
Pro's
pie-button
includes all the necessary a11y labels and helpers built into the button component.type="reset"
,pie-button
is already setup to handle this.Con's
link
already exist inpie-link
, so we'd likely need to abstract these out intopie-css
as a mixin so that they could be shared between bothpie-button
andpie-link
.pie-button
props like optional icons, loading states,sizes
that 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-link
This solution extends
pie-link
. This could be done by including atag
prop, which acceptsbutton
as a valid option (with the default beinga
.Setting this prop to
button
would then change thepie-link
to use abutton
HTML 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-button
are replicated when button tags are used withpie-link
.href
,target
,rel
props not needed by a button, so will need to make sure they play nicely whenpie-link
tag 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
link
already exist inpie-link
, so we'd likely need to abstract these out intopie-css
as a mixin so that they could be shared between bothpie-link
and 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-button
for this link-button component.pie-link
component 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