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

Add NavBar #18

Merged
merged 3 commits into from
Apr 1, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- 'develop'

env:
APP_MAPBOX_ACCESS_TOKEN: ${{ vars.APP_MAPBOX_ACCESS_TOKEN }}
GITHUB_WORKFLOW: true

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
generated
dist
dist-ssr
build
Expand Down
17 changes: 17 additions & 0 deletions codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
overwrite: true
schema:
# TODO: Use backend/schema.graphql instead
# NOTE: We may need both GRAPHQL_CODEGEN_ENDPOINT and backend/schema.graphql?
- ${GRAPHQL_CODEGEN_ENDPOINT}
- './schema.graphql'
documents:
- "src/**/*.tsx"
- "src/**/*.ts"
generates:
./generated/types.ts:
plugins:
- "typescript"
- "typescript-operations"
./generated/schema.json:
plugins:
- "introspection"
2 changes: 2 additions & 0 deletions env.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { defineConfig, Schema } from '@julr/vite-plugin-validate-env';

// TODO: Integrate .env for CI and remove optional() call on required fields
export default defineConfig({
APP_TITLE: Schema.string.optional(),
APP_MAPBOX_ACCESS_TOKEN: Schema.string.optional(),
})
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
"@graphql-codegen/introspection": "^4.0.3",
"@graphql-codegen/typescript-operations": "^4.2.0",
"@ifrc-go/icons": "^1.3.3",
"@sentry/react": "^7.108.0",
"@ifrc-go/ui": "^1.0.0",
"@mapbox/mapbox-gl-draw": "^1.4.3",
"@sentry/react": "^7.81.1",
"@togglecorp/fujs": "^2.1.1",
"@togglecorp/re-map": "^0.2.0-beta-6",
"@togglecorp/re-map": "^0.1.4",
"graphql": "^16.8.1",
"mapbox-gl": "^1.13.0",
"react": "^18.2.0",
Expand All @@ -34,8 +36,8 @@
"@eslint/eslintrc": "^3.0.2",
"@julr/vite-plugin-validate-env": "^1.0.1",
"@types/mapbox-gl": "^1.13.0",
"@types/node": "^20.11.30",
"@types/react": "^18.2.70",
"@types/node": "^20.1.3",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.2.22",
"@types/react-router-dom": "^5.3.3",
"@typescript-eslint/eslint-plugin": "^7.4.0",
Expand Down Expand Up @@ -79,4 +81,4 @@
"vite-tsconfig-paths": "^4.2.2",
"vitest": "^1.1.0"
}
}
}
4 changes: 4 additions & 0 deletions src/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import {
createBrowserRouter,
RouterProvider,
} from 'react-router-dom';
import mapboxgl from 'mapbox-gl';

import { mbtoken } from '#config';

import { unwrappedRoutes } from './routes';

const router = createBrowserRouter(unwrappedRoutes);
mapboxgl.accessToken = mbtoken;

function App() {
return (
Expand Down
10 changes: 6 additions & 4 deletions src/App/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import type {
import {
MyInputIndexRouteObject,
MyInputNonIndexRouteObject,
MyInputRouteObject,
MyOutputIndexRouteObject,
MyOutputNonIndexRouteObject,
MyOutputRouteObject,
} from '#utils/routes';
import {
unwrapRoute,
wrapRoute,
} from '#utils/routes';
Expand All @@ -31,7 +29,7 @@ const myWrapRoute: MyWrapRoute = wrapRoute;
const root = myWrapRoute({
title: '',
path: '/',
component: () => import('#views/Root'),
component: () => import('#views/RootLayout'),
componentProps: {},
errorElement: <PageError />,
});
Expand Down Expand Up @@ -59,3 +57,7 @@ export const wrappedRoutes = {
};

export const unwrappedRoutes = unwrapRoute(Object.values(wrappedRoutes));

export default wrappedRoutes;

export type WrappedRoutes = typeof wrappedRoutes;
113 changes: 113 additions & 0 deletions src/assets/icons/go-logo-2020.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions src/components/DropdownMenuItem/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import {
useCallback,
useContext,
} from 'react';
import { LinkProps } from 'react-router-dom';
import {
Button,
ButtonProps,
ConfirmButton,
ConfirmButtonProps,
} from '@ifrc-go/ui';
import { DropdownMenuContext } from '@ifrc-go/ui/contexts';
import { isDefined } from '@togglecorp/fujs';

type CommonProp = {
persist?: boolean;
}

type ButtonTypeProps<NAME> = Omit<ButtonProps<NAME>, 'type'> & {
type: 'button';
}

type LinkTypeProps = LinkProps & {
type: 'link';
}

type ConfirmButtonTypeProps<NAME> = Omit<ConfirmButtonProps<NAME>, 'type'> & {
type: 'confirm-button',
}

type Props<N> = CommonProp & (ButtonTypeProps<N> | LinkTypeProps | ConfirmButtonTypeProps<N>);

function DropdownMenuItem<NAME>(props: Props<NAME>) {
const {
type,
onClick,
persist = false,
} = props;
const { setShowDropdown } = useContext(DropdownMenuContext);

const handleButtonClick = useCallback(
(name: NAME, e: React.MouseEvent<HTMLButtonElement>) => {
if (!persist) {
setShowDropdown(false);
}
if (isDefined(onClick) && type !== 'link') {
onClick(name, e);
}
},
[setShowDropdown, type, onClick, persist],
);

if (type === 'button') {
const {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type: _,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
persist: __,
variant = 'dropdown-item',
...otherProps
} = props;

return (
<Button
// eslint-disable-next-line react/jsx-props-no-spreading
{...otherProps}
variant={variant}
onClick={handleButtonClick}
/>
);
}

if (type === 'confirm-button') {
const {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type: _,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
persist: __,
variant = 'dropdown-item',
...otherProps
} = props;

return (
<ConfirmButton
// eslint-disable-next-line react/jsx-props-no-spreading
{...otherProps}
variant={variant}
onClick={handleButtonClick}
/>
);
}
}

export default DropdownMenuItem;
16 changes: 16 additions & 0 deletions src/components/GlobalFooter/i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"namespace": "common",
"strings": {
"footerAboutAlertHub":"About Alert Hub",
"footerAboutAlertHubDesc":"The aim of IFRC Alert Hub is to provide timely and effective emergency alerts to communities worldwide, empowering them to protect their lives and livelihoods.",
"footerFindOutMore":"Find out more",
"footerHelpfulLinks":"Helpful links",
"footerOpenSourceCode":"Open Source Code",
"footerApiDocumentation":"API Documentation",
"footerOtherResources":"Other Resources",
"footerContactUs":"Contact Us",
"footerIFRC":"© IFRC Alert Hub {year} v{appVersion}",
"globalFindOut": "Find Out More",
"globalHelpfulLinks": "Helpful links"
}
}
Loading