owncast/web/components/action-buttons/ActionButton.tsx
gingervitis d5fa81f76e
Draft: rough-ish draft of proposed color theme changes (#2067)
* color experimentation and troubleshooting

* create color scheme, assign colors, more ant overrides

* fun selection color

* Prettified Code!

* Correctly import opensans

* Prettified Code!

* Organize+standardize colors/names and update the app to use them

* Prettified Code!

* Use css var references instead of resolving value of vars in css files

* Prettified Code!

Co-authored-by: gingervitis <gingervitis@users.noreply.github.com>
Co-authored-by: Gabe Kangas <gabek@real-ity.com>
Co-authored-by: gabek <gabek@users.noreply.github.com>
2022-08-29 23:17:12 -07:00

49 lines
1.1 KiB
TypeScript

import { Button } from 'antd';
import { useState } from 'react';
import Modal from '../ui/Modal/Modal';
import { ExternalAction } from '../../interfaces/external-action';
import s from './ActionButton.module.scss';
interface Props {
action: ExternalAction;
primary?: boolean;
}
ActionButton.defaultProps = {
primary: false,
};
export default function ActionButton({
action: { url, title, description, icon, color, openExternally },
primary = false,
}: Props) {
const [showModal, setShowModal] = useState(false);
const buttonClicked = () => {
if (openExternally) {
window.open(url, '_blank');
} else {
setShowModal(true);
}
};
return (
<>
<Button
type={primary ? 'primary' : 'default'}
className={`${s.button}`}
onClick={buttonClicked}
style={{ backgroundColor: color }}
>
<img src={icon} className={`${s.icon}`} alt={description} />
{title}
</Button>
<Modal
title={description || title}
url={url}
visible={showModal}
height="80vh"
handleCancel={() => setShowModal(false)}
/>
</>
);
}