Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Isolate changes to just hook and rename for general use #1399

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React from 'react';
import GoogleForm from '../../google-form';
import { ActionNavItem } from '../types';
import { useFeedbackModal } from '$utils/use-feedback-modal';
import { useDisplay } from '$utils/use-display';

interface NavItemCTAProps {
item: ActionNavItem;
customClasses?: string;
}

export const NavItemCTA = ({ item, customClasses }: NavItemCTAProps) => {
const { isRevealed, show, hide } = useFeedbackModal();
const { isRevealed, show, hide } = useDisplay();

return (
<React.Fragment key={item.id}>
{item.actionId === 'open-google-form' && (
Expand Down
12 changes: 2 additions & 10 deletions app/scripts/context/veda-ui-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { createContext, ReactNode, useContext, useState } from 'react';
import React, { createContext, ReactNode, useContext } from 'react';
import { DATASETS_PATH, STORIES_PATH } from '$utils/routes';
import { isExternalLink } from '$utils/url';
import { SetState } from '$types/aliases';

interface EnvironmentConfig {
envMapboxToken: string;
Expand Down Expand Up @@ -32,8 +31,6 @@ interface VedaUIConfig extends EnvironmentConfig {
navigation: NavigationConfig;
routes: RoutesConfig;
Link: React.FC<LinkProps>;
feedbackModalRevealed: boolean;
setFeedbackModalRevealed: SetState<boolean>;
}

interface VedaUIProviderProps {
Expand Down Expand Up @@ -84,9 +81,6 @@ export function useVedaUI(): VedaUIConfig {
}

export function VedaUIProvider({ config, children }: VedaUIProviderProps) {
const [feedbackModalRevealed, setFeedbackModalRevealed] =
useState<boolean>(false);

const navigation = {
...defaultNavigation,
...config.navigation
Expand Down Expand Up @@ -121,9 +115,7 @@ export function VedaUIProvider({ config, children }: VedaUIProviderProps) {
...config,
navigation,
routes,
Link,
feedbackModalRevealed,
setFeedbackModalRevealed
Link
};

validateConfig(fullConfig);
Expand Down
11 changes: 11 additions & 0 deletions app/scripts/utils/use-display.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useCallback, useState } from 'react';

export function useDisplay() {
const [display, setDisplay] = useState<boolean>(false);

return {
isRevealed: display,
show: useCallback(() => setDisplay(true), [setDisplay]),
hide: useCallback(() => setDisplay(false), [setDisplay])
};
}
20 changes: 0 additions & 20 deletions app/scripts/utils/use-feedback-modal.tsx

This file was deleted.

Loading