Link.jsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // ./src/stories/Link.jsx
  2. import React from 'react';
  3. /**
  4. * A queue as described in a list.
  5. */
  6. const Link = ({text, url}) => {
  7. if (text === undefined || text === null) {
  8. text = url;
  9. }
  10. if (url !== undefined && url != null && url !== '') {
  11. text = <a href={url}>{text}</a>;
  12. }
  13. return (
  14. <>
  15. {text}
  16. <React.StrictMode/>
  17. </>
  18. )
  19. }
  20. export const createLink = ({
  21. text = '',
  22. url = '',
  23. }) => {
  24. if (text === undefined || text === null) {
  25. text = url;
  26. const link = document.createTextNode(url);
  27. }
  28. if (url !== undefined && url != null && url !== '') {
  29. text = <a href={url}>{text}</a>;
  30. const link = document.createElement('a')
  31. }
  32. const btn = document.createElement('button');
  33. btn.type = 'button';
  34. btn.innerText = label;
  35. btn.addEventListener('click', onClick);
  36. const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
  37. btn.className = ['storybook-button', `storybook-button--${size}`, mode].join(' ');
  38. btn.style.backgroundColor = backgroundColor;
  39. return btn;
  40. };