fintraffic-design / fds-coreui-components

Fintraffic Design System's Core UI Components. Work heavily in progress.
European Union Public License 1.2
0 stars 0 forks source link

Defect: Navigation elements are not links #64

Open esuomi opened 8 months ago

esuomi commented 8 months ago

Hey,

Seems that for simple items at least the top navbar items are not proper links (<a href="...">), but instead manually built <span>s: https://github.com/fintraffic-design/fds-coreui-components/blob/f14c3a7ead5f148fe28d3b0697a9e66c22696e41/src/navigation.ts#L125-L128

This approach has several issues:

My recommendation for the fix is a bit more involved, but should make sense:

  1. Implement a <Link> component, which renders as <a ...> with some treats;
    • allow composing the link's CSS styles to make it look like normal text link, or maybe colored from a palette, or button-like etc.
    • automatically set the "boring" link metadata when the link points to an outside website, including
      • external-link icon next to the link text
      • rel="nofollow noreferrer noopener" (see why), target="_blank" and whatever else
    • optionally provide a onClick callback for those richer links which actually need to do more than navigation
  2. Replace all links and link-like things in all other components with this <Link>. This has several benefits:
    • For starters, you can be sure no one forgets accessibility/metadata from links because they're always injected through shared component
    • Avoid <button> abuse in general through better styling, form elements are not hyperlinks and should not be used as such
    • they're also SEO friendly