mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-26 14:45:50 +00:00
Recreate branch from base, add react-query-params, fix permalinks, fix sidebar use correct params library and upgrade redocly. Fix command text not working with permalink and move more modal logic out of main component. Moved more connection selection logic to connection modal Removed many `data-*` attributes previously used by bootstrap modal css Created a shared modal component which removed 38 lines. WS Tool: Fix Link import fix UL error toggle CurlModal to show/hide on button clicks resolve error: <div> cannot appear as a descendant of <p> remove <span> WS tool: sidebar fixes
82 lines
2.0 KiB
TypeScript
82 lines
2.0 KiB
TypeScript
import React, { JSX, ReactElement, ReactNode } from 'react';
|
|
import { useTranslate } from '@portal/hooks';
|
|
|
|
interface ModalProps {
|
|
id: string // used for targeting animations
|
|
title: string,
|
|
children: ReactNode,
|
|
footer?: ReactNode,
|
|
onClose: () => void;
|
|
}
|
|
|
|
/**
|
|
* Reusable component that leverages bootstrap's jquery library
|
|
*/
|
|
export const Modal = ({title, footer, children, onClose, id}: ModalProps) => {
|
|
return <div
|
|
className="modal fade"
|
|
id={id}
|
|
tabIndex={-1}
|
|
role="dialog"
|
|
aria-hidden="true"
|
|
>
|
|
<div className="modal-dialog modal-dialog-centered" role="document">
|
|
<div className="modal-content">
|
|
<div className="modal-header">
|
|
<h5 className="modal-title">{title}</h5>
|
|
<button
|
|
type="button"
|
|
className="close"
|
|
aria-label="Close"
|
|
onClick={onClose}
|
|
data-dismiss="modal"
|
|
>
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div className="modal-body">
|
|
{children}
|
|
</div>
|
|
<div className="modal-footer">
|
|
{ footer ? footer : (
|
|
<ModalCloseBtn onClick={onClose} />
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
export const ModalCloseBtn = ({onClick}) => {
|
|
const { translate } = useTranslate();
|
|
|
|
return <button
|
|
type="button"
|
|
className="btn btn-outline-secondary"
|
|
data-dismiss="modal"
|
|
onClick={onClick}
|
|
>
|
|
{translate('Close')}
|
|
</button>
|
|
}
|
|
|
|
export const ModalClipboardBtn = ({textareaRef}) => {
|
|
const { translate } = useTranslate();
|
|
|
|
return <button
|
|
title={translate('Copy to clipboard')}
|
|
className="btn btn-outline-secondary clipboard-btn"
|
|
onClick={() => copyToClipboard(textareaRef)}
|
|
>
|
|
<i className="fa fa-clipboard"></i>
|
|
</button>
|
|
}
|
|
|
|
const copyToClipboard = async (textareaRef) => {
|
|
if (textareaRef.current) {
|
|
textareaRef.current.select();
|
|
textareaRef.current.focus();
|
|
await navigator.clipboard.writeText(textareaRef.current.value);
|
|
}
|
|
};
|