1
0
Fork 0
freesewing/packages/react/components/Button/index.mjs
joostdecock c8808695e5 wip: Bunch of changes for v4
From the top of my head (but I'll write this up later):

- We keep the info about the designs in the design
- We use a new about.json file for this
- The auto-generated data.mjs file is no more
- Linedrawings we use in the design picker use the front
- Linedrawings should respect square aspect ration
- Migrated components to use the 'tw-' prefic for tailwind CSS classes
  to avoid conflicts with docusaurus styles
2024-12-26 18:33:49 +01:00

34 lines
1 KiB
JavaScript

import React from 'react'
/**
* A button with an icon and a label. Common across our UI
*
* @param {object} props - All React props
* @param {string} title - The button title
* @param {string} className - Any EXTRA classes to add
* @param {string} color - The main button color
* @param {string} href - Set this to make it a link
*/
export const IconButton = ({
title = '',
className = '',
onClick = false,
href = false,
color = 'primary',
children = [],
btnProps = {},
}) => {
const allProps = {
className: `${staticLinkClasses} tw-daisy-btn-${color} hover:tw-text-${color}-content ${className}`,
title: title,
...btnProps,
}
if (onClick) allProps.onClick = onClick
else if (href) allProps.href = href
return onClick ? <button {...allProps}>{children}</button> : <a {...allProps}>{children}</a>
}
const staticLinkClasses =
'tw-flex tw-flex-row tw-gap-2 lg:tw-gap-12 tw-items-center ' +
'tw-justify-between tw-w-full lg:tw-w-auto tw-daisy-btn hover:tw-no-underline tw-capitalize tw-my-2'