forked from mirrors/thatmattlove-hyperglass
improve directive info styling
This commit is contained in:
parent
c479a2f2b4
commit
47711fb075
5 changed files with 25 additions and 25 deletions
|
|
@ -12,12 +12,19 @@ import {
|
|||
import { DynamicIcon, Markdown } from '~/components';
|
||||
import { useColorValue } from '~/context';
|
||||
|
||||
import type { THelpModal } from './types';
|
||||
import type { ModalContentProps } from '@chakra-ui/react';
|
||||
|
||||
export const HelpModal = (props: THelpModal): JSX.Element => {
|
||||
interface DirectiveInfoModalProps extends Omit<ModalContentProps, 'title'> {
|
||||
title: string | null;
|
||||
item: string | null;
|
||||
name: string;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
export const DirectiveInfoModal = (props: DirectiveInfoModalProps): JSX.Element => {
|
||||
const { visible, item, name, title, ...rest } = props;
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const bg = useColorValue('whiteSolid.50', 'blackSolid.800');
|
||||
const bg = useColorValue('whiteSolid.50', 'blackSolid.700');
|
||||
const color = useColorValue('black', 'white');
|
||||
if (item === null) {
|
||||
return <></>;
|
||||
|
|
@ -34,11 +41,11 @@ export const HelpModal = (props: THelpModal): JSX.Element => {
|
|||
variant="link"
|
||||
onClick={onOpen}
|
||||
colorScheme="blue"
|
||||
aria-label={`${name}_help`}
|
||||
icon={<DynamicIcon icon={{ fi: 'FiInfo' }} />}
|
||||
aria-label={`${title} Details`}
|
||||
icon={<DynamicIcon icon={{ fa: 'InfoCircle' }} />}
|
||||
/>
|
||||
</ScaleFade>
|
||||
<Modal isOpen={isOpen} onClose={onClose} size="xl" motionPreset="slideInRight">
|
||||
<Modal isOpen={isOpen} onClose={onClose} size="xl" motionPreset="scale">
|
||||
<ModalOverlay />
|
||||
<ModalContent bg={bg} color={color} py={4} borderRadius="md" {...rest}>
|
||||
<ModalHeader>{title}</ModalHeader>
|
||||
|
|
@ -1 +0,0 @@
|
|||
export * from './modal';
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
import type { ModalContentProps } from '@chakra-ui/react';
|
||||
|
||||
export interface THelpModal extends Omit<ModalContentProps, 'title'> {
|
||||
title: string | null;
|
||||
item: string | null;
|
||||
name: string;
|
||||
visible: boolean;
|
||||
}
|
||||
|
|
@ -4,13 +4,13 @@ export * from './codeBlock';
|
|||
export * from './countdown';
|
||||
export * from './custom';
|
||||
export * from './debugger';
|
||||
export * from './directive-info-modal';
|
||||
export * from './dynamic-icon';
|
||||
export * from './favicon';
|
||||
export * from './footer';
|
||||
export * from './form';
|
||||
export * from './greeting';
|
||||
export * from './header';
|
||||
export * from './help';
|
||||
export * from './label';
|
||||
export * from './layout';
|
||||
export * from './loadError';
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import vest, { test, enforce } from 'vest';
|
|||
import {
|
||||
FormRow,
|
||||
FormField,
|
||||
HelpModal,
|
||||
DirectiveInfoModal,
|
||||
QueryType,
|
||||
QueryTarget,
|
||||
SubmitButton,
|
||||
|
|
@ -43,8 +43,8 @@ export const LookingGlass = (): JSX.Element => {
|
|||
const locationChange = useFormState(s => s.locationChange);
|
||||
const setTarget = useFormState(s => s.setTarget);
|
||||
const setFormValue = useFormState(s => s.setFormValue);
|
||||
const { form, filtered } = useFormState(
|
||||
useCallback(({ form, filtered }) => ({ form, filtered }), []),
|
||||
const { form, filtered, selections } = useFormState(
|
||||
useCallback(({ form, filtered, selections }) => ({ form, filtered, selections }), []),
|
||||
isEqual,
|
||||
);
|
||||
|
||||
|
|
@ -188,12 +188,14 @@ export const LookingGlass = (): JSX.Element => {
|
|||
name="queryType"
|
||||
label={web.text.queryType}
|
||||
labelAddOn={
|
||||
<HelpModal
|
||||
directive !== null && (
|
||||
<DirectiveInfoModal
|
||||
name="queryType"
|
||||
title={directive?.name ?? null}
|
||||
item={directive?.info ?? null}
|
||||
visible={directive?.info !== null}
|
||||
title={directive.name ?? null}
|
||||
item={directive.info ?? null}
|
||||
visible={selections.queryType !== null && directive.info !== null}
|
||||
/>
|
||||
)
|
||||
}
|
||||
>
|
||||
<QueryType onChange={handleChange} label={web.text.queryType} />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue