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

chore: Remove veda dependency #1398

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion app/scripts/components/common/layout-root/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import styled from 'styled-components';
import { Outlet } from 'react-router';
import { reveal } from '@devseed-ui/animation';
import { NavLink } from 'react-router-dom';

import {
getBannerFromVedaConfig,
getCookieConsentFromVedaConfig,
getSiteAlertFromVedaConfig
} from 'veda';
import { footerSettings } from '../page-footer/default-config';
import MetaTags from '../meta-tags';
import PageFooter from '../page-footer';
import PageFooterLegacy from '../page-footer-legacy';
Expand Down Expand Up @@ -120,6 +120,7 @@ function LayoutRoot(props: { children?: ReactNode }) {
hideFooter={hideFooter}
linkProperties={{ LinkElement: NavLink, pathAttributeKeyName: 'to' }}
logoSvg={<NasaLogoColor />}
footerSettings={footerSettings}
/>
) : (
<PageFooterLegacy hideFooter={hideFooter} />
Expand Down
15 changes: 15 additions & 0 deletions app/scripts/components/common/page-footer/footer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ import { NavItem } from '../page-header/types.js';

import PageFooter from './index';

const defaultFooterSetting = {
secondarySection: {
division: 'NASA EarthData 2024',
version: 'BETA VERSION',
title: 'NASA Official',
name: 'Manil Maskey',
to: '[email protected]',
type: 'email'
},
returnToTop: true
};

const mockMainNavItems: NavItem[] = navItems.mainNavItems;
const mockSubNavItems: NavItem[] = navItems.subNavItems;
// const mockFooterSettings = footerSettings;
Expand Down Expand Up @@ -40,6 +52,7 @@ describe('PageFooter', () => {
hideFooter={hideFooter}
logoSvg={<NasaLogoColor />}
linkProperties={mockLinkProperties}
footerSettings={defaultFooterSetting}
/>
);
const footerElement = document.querySelector('footer');
Expand All @@ -56,6 +69,7 @@ describe('PageFooter', () => {
hideFooter={hideFooter}
logoSvg={<NasaLogoColor />}
linkProperties={mockLinkProperties}
footerSettings={defaultFooterSetting}
/>
);
expect(screen.getByText('Data Catalog')).toBeInTheDocument();
Expand Down Expand Up @@ -89,6 +103,7 @@ describe('PageFooter dynamic settings', () => {
subNavItems={mockSubNavItems}
hideFooter={true}
logoSvg={<NasaLogoColor />}
footerSettings={defaultFooterSetting}
/>
);
const footerElement = document.querySelector('footer');
Expand Down
16 changes: 13 additions & 3 deletions app/scripts/components/common/page-footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { DropdownNavLink, NavLinkItem } from '../types';
import { ActionNavItem, NavItemType } from '../page-header/types';
import { NavItemCTA } from '../page-header/nav/nav-item-cta';
import ReturnToTopButton from './return-to-top-button';
import { footerSettings } from './default-config';

import { LinkProperties } from '$types/veda';
import {
Expand All @@ -19,15 +18,26 @@ interface PageFooterProps {
hideFooter?: boolean;
logoSvg?: SVGElement | JSX.Element;
linkProperties: LinkProperties;
footerSettings: {
secondarySection: {
division: string;
version: string;
title: string;
name: string;
to: string;
type: string;
};
returnToTop: boolean;
};
}


export default function PageFooter({
mainNavItems,
subNavItems,
hideFooter,
logoSvg,
linkProperties
linkProperties,
footerSettings
}: PageFooterProps) {
const { returnToTop, secondarySection } = footerSettings;
const FooterNavItemInternalLink = (item) => {
Expand Down
1 change: 1 addition & 0 deletions app/scripts/components/common/page-header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NavItem } from './types';
import LogoContainer from './logo-container';
import useMobileMenuFix from './use-mobile-menu-fix';
import { createDynamicNavMenuList } from './nav/create-dynamic-nav-menu-list';

import {
USWDSHeader,
USWDSHeaderTitle,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import GoogleForm from '../../google-form';
import { useFeedbackModal } from '../../layout-root';
import { ActionNavItem } from '../types';
import { useFeedbackModal } from '$utils/use-feedback-modal';

interface NavItemCTAProps {
item: ActionNavItem;
Expand Down
12 changes: 10 additions & 2 deletions app/scripts/context/veda-ui-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { createContext, ReactNode, useContext } from 'react';
import React, { createContext, ReactNode, useContext, useState } 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 @@ -31,6 +32,8 @@ interface VedaUIConfig extends EnvironmentConfig {
navigation: NavigationConfig;
routes: RoutesConfig;
Link: React.FC<LinkProps>;
feedbackModalRevealed: boolean;
setFeedbackModalRevealed: SetState<boolean>;
}

interface VedaUIProviderProps {
Expand Down Expand Up @@ -81,6 +84,9 @@ 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 @@ -115,7 +121,9 @@ export function VedaUIProvider({ config, children }: VedaUIProviderProps) {
...config,
navigation,
routes,
Link
Link,
feedbackModalRevealed,
setFeedbackModalRevealed
};

validateConfig(fullConfig);
Expand Down
1 change: 0 additions & 1 deletion app/scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import type {
import type { InternalNavLink } from '$components/common/types';
import type { DatasetData, StoryData, VedaData } from '$types/veda';


import ExplorationAndAnalysis from '$components/exploration';
import useTimelineDatasetAtom from '$components/exploration/hooks/use-timeline-dataset-atom';
import { timelineDatasetsAtom } from '$components/exploration/atoms/datasets';
Expand Down
20 changes: 20 additions & 0 deletions app/scripts/utils/use-feedback-modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useCallback } from 'react';
import { useVedaUI } from '$context/veda-ui-provider';
/**
* Hook to access the feedback modal.
*/
export function useFeedbackModal() {
const { feedbackModalRevealed, setFeedbackModalRevealed } = useVedaUI();
hanbyul-here marked this conversation as resolved.
Show resolved Hide resolved

return {
isRevealed: feedbackModalRevealed,
show: useCallback(
() => setFeedbackModalRevealed(true),
[setFeedbackModalRevealed]
),
hide: useCallback(
() => setFeedbackModalRevealed(false),
[setFeedbackModalRevealed]
)
};
}
Loading