1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-01-17 08:48:05 +00:00

improve directive info styling

This commit is contained in:
thatmattlove 2021-12-18 21:52:05 -07:00
parent c479a2f2b4
commit 47711fb075
5 changed files with 25 additions and 25 deletions

View file

@ -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>

View file

@ -1 +0,0 @@
export * from './modal';

View file

@ -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;
}

View file

@ -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';

View file

@ -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} />