web.lib.core.components.stuff.tsx Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of code-quarkus Show documentation
Show all versions of code-quarkus Show documentation
Customize a Web Interface to generate Quarkus starter projects.
import * as React from 'react';
import { CSSProperties } from 'react';
import './stuff.scss';
import { CopyToClipboard } from './copy-to-clipboard';
import { Alert, Button } from 'react-bootstrap';
import { FaCog, FaExternalLinkAlt } from 'react-icons/fa';
export function optionalBool(val: (boolean | undefined), defaultValue: boolean): boolean {
return val === undefined ? defaultValue : val!;
}
export function Spin(props: { children: React.ReactNode }) {
return (
{props.children}
);
}
export function Loader(props: { 'aria-label'?: string; error?: any; }) {
return (
{!props || (!props!.error && ( ))}
{props && props.error &&
}
);
}
export function AlertError(props: { error: any }) {
return (
{props.error.message || props.error.toString()}
);
}
export interface EffectSafety {
callSafely: (fn: () => void) => void;
unload: () => void;
}
export function effectSafety(): EffectSafety {
const unMounted = { status: false };
const unload = () => {
unMounted.status = true;
};
const callSafely = (fn: () => void) => {
if(!unMounted.status) {
fn();
}
};
return { callSafely, unload };
}
export function Plural(props: {
count: number;
label: string | {plural: string; singular: string;};
}) {
let isPlural = props.count === 0 || props.count > 1;
if (typeof props.label === 'string') {
return <>{props.label}{isPlural ? 's' : ''}>;
}
if (typeof props.label === 'object') {
return <>{isPlural ? props.label.plural : props.label.singular}>;
}
throw new Error("Invalid type");
}
export function ExternalLink(props: {
'aria-label'?: string;
onClick?: React.MouseEventHandler;
children: React.ReactNode;
href: string;
style?: CSSProperties;
}) {
return (
);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy