Skip to content

Commit

Permalink
fix: type related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
samshara authored and barshathakuri committed Apr 1, 2024
1 parent 4ea29d1 commit eb48fa0
Show file tree
Hide file tree
Showing 20 changed files with 709 additions and 2,345 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,23 @@ jobs:

- name: Css Lint
run: yarn lint:css
# typecheck:
# name: Typecheck
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: 20
# cache: 'yarn'
typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'

# - name: Install dependencies
# run: yarn install
- name: Install dependencies
run: yarn install

# - name: Typecheck
# run: yarn typecheck
- name: Typecheck
run: yarn typecheck
build:
name: Build
# needs: [lint, css-lint, typecheck, test]
needs: [lint, css-lint, typecheck, test]
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 2 additions & 1 deletion env.ts
Original file line number Diff line number Diff line change
@@ -1,6 +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(),
APP_MAPBOX_ACCESS_TOKEN: Schema.string.optional(),
})
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@
"@sentry/react": "^7.81.1",
"@togglecorp/fujs": "^2.1.1",
"@togglecorp/re-map": "^0.1.4",
"@turf/bbox": "^6.5.0",
"graphql": "^16.8.1",
"mapbox-gl": "^3.2.0",
"mapbox-gl": "^1.13.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.3"
},
"devDependencies": {
"@eslint/eslintrc": "^3.0.2",
"@julr/vite-plugin-validate-env": "^1.0.1",
"@types/mapbox-gl": "^3.1.0",
"@types/mapbox-gl": "^1.13.0",
"@types/node": "^20.1.3",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.2.22",
Expand Down Expand Up @@ -82,4 +81,4 @@
"vite-tsconfig-paths": "^4.2.2",
"vitest": "^1.1.0"
}
}
}
2 changes: 1 addition & 1 deletion src/components/GlobalFooter/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"footerApiDocumentation":"API Documentation",
"footerOtherResources":"Other Resources",
"footerContactUs":"Contact Us",
"footerIFRC":"© IFRC {year} v{appVersion}",
"footerIFRC":"© IFRC Alert Hub {year} v{appVersion}",
"globalFindOut": "Find Out More",
"globalHelpfulLinks": "Helpful links"
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/GlobalFooter/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

.content {
display: flex;
gap: var(--go-ui-spacing-2xl);
flex-wrap: wrap;
gap: var(--go-ui-spacing-2xl);

.section {
display: flex;
Expand Down
6 changes: 6 additions & 0 deletions src/components/MapPopup/i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"namespace": "common",
"strings": {
"messagePopupClose": "Close"
}
}
77 changes: 77 additions & 0 deletions src/components/MapPopup/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { CloseLineIcon } from '@ifrc-go/icons';
import {
Button,
Container,
ContainerProps,
} from '@ifrc-go/ui';
import { useTranslation } from '@ifrc-go/ui/hooks';
import { _cs } from '@togglecorp/fujs';
import { MapPopup as BasicMapPopup } from '@togglecorp/re-map';

import i18n from './i18n.json';
import styles from './styles.module.css';

const popupOptions: mapboxgl.PopupOptions = {
closeButton: false,
closeOnClick: false,
closeOnMove: false,
offset: 8,
className: styles.mapPopup,
maxWidth: 'unset',
};

interface Props extends ContainerProps {
coordinates: mapboxgl.LngLatLike;
children: React.ReactNode;
onCloseButtonClick: () => void;
}

function MapPopup(props: Props) {
const {
children,
coordinates,
onCloseButtonClick,
actions,
childrenContainerClassName,
...containerProps
} = props;

const strings = useTranslation(i18n);

return (
<BasicMapPopup
coordinates={coordinates}
popupOptions={popupOptions}
hidden={false}
trackPointer={false}
>
<Container
// eslint-disable-next-line react/jsx-props-no-spreading
{...containerProps}
className={styles.container}
withoutWrapInHeading
childrenContainerClassName={_cs(styles.content, childrenContainerClassName)}
withHeaderBorder
withInternalPadding
actions={(
<>
{actions}
<Button
className={styles.closeButton}
name={undefined}
variant="tertiary"
onClick={onCloseButtonClick}
title={strings.messagePopupClose}
>
<CloseLineIcon />
</Button>
</>
)}
>
{children}
</Container>
</BasicMapPopup>
);
}

export default MapPopup;
49 changes: 49 additions & 0 deletions src/components/MapPopup/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.map-popup {
display: flex;
padding: 0;
width: 20rem;
min-height: 10rem;
max-height: 20rem;
overflow: auto;
font-family: var(--go-ui-font-family-sans-serif);
font-size: var(--go-ui-font-size-md);

:global {
.mapboxgl-tip {
flex-shrink: 0;
}

.mapboxgl-popup-content {
display: flex;
flex-direction: column;
flex-grow: 1;
padding: 0;
overflow: auto;

>div {
display: flex;
flex-direction: column;
flex-grow: 1;
padding: 0;
overflow: auto;
}
}
}

.container {
flex-grow: 1;
border: var(--go-ui-width-separator-thin) solid var(--go-ui-color-separator);
width: 100%;
height: 100%;
overflow: auto;

.close-button {
font-size: var(--go-ui-height-icon-multiplier);
}

.content {
overflow: auto;
}
}
}

2 changes: 1 addition & 1 deletion src/components/Navbar/i18n.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"namespace": "common",
"strings": {
"headerAppName": "Alert Hub",
"headerAppName": "ALERT HUB",
"headerLogoAltText": "Alert Hub logo",
"appLogin": "Login",
"appAbout": "About",
Expand Down
4 changes: 3 additions & 1 deletion src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function Navbar(props: Props) {
<Heading
level={2}
>
ALERT HUB
{strings.headerAppName}
</Heading>
</Link>
</div>
Expand All @@ -54,12 +54,14 @@ function Navbar(props: Props) {
variant="tertiary"
>
<LangaugeDropdown />
{/* // FIXME: Add About route */}
<Link
className={styles.actionItem}
to="/"
>
{strings.appAbout}
</Link>
{/* // FIXME: Add Resource route */}
<Link
className={styles.actionItem}
to="/"
Expand Down
8 changes: 4 additions & 4 deletions src/components/Navbar/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

.top-content {
display: flex;
align-items: center;
gap: var(--go-ui-spacing-md) var(--go-ui-spacing-lg);
flex-wrap: wrap;
gap: var(--go-ui-spacing-md) var(--go-ui-spacing-lg);
align-items: center;
padding: var(--go-ui-spacing-md) var(--go-ui-spacing-lg);

.brand {
display: flex;
align-items: top;
flex-grow: 1;
flex-wrap: wrap;
gap: var(--go-ui-spacing-sm);
align-items: top;

.go-icon {
height: var(--go-ui-height-brand-icon);
Expand All @@ -32,8 +32,8 @@

.actions {
display: flex;
align-items: center;
flex-wrap: wrap;
align-items: center;

.action-item {
text-decoration: none;
Expand Down
3 changes: 2 additions & 1 deletion src/components/Page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import useCurrentLanguage from '#hooks/domain/useCurrentLanguage';
import i18n from './i18n.json';
import styles from './styles.module.css';

type TranslationModuleOriginalLanguageEnum = components<'read'>['schemas']['TranslationModuleOriginalLanguageEnum'];
// TODO use enum field from alert hub api
type TranslationModuleOriginalLanguageEnum = 'en' | 'es' | 'ar' | 'fr';

interface Props {
className?: string;
Expand Down
15 changes: 15 additions & 0 deletions src/declarations/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// <reference types="vite/client" />

type ImportMetaEnvAugmented = import('@julr/vite-plugin-validate-env').ImportMetaEnvAugmented<
typeof import('../../env').default
>

interface ImportMetaEnv extends ImportMetaEnvAugmented {
// The custom environment variables that are passed through the vite
APP_COMMIT_HASH: string;
APP_VERSION: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv
}
10 changes: 0 additions & 10 deletions src/env.d.ts

This file was deleted.

36 changes: 0 additions & 36 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,9 @@
export const defaultChartMargin = {
top: 0,
right: 0,
bottom: 0,
left: 0,
};

export const defaultChartPadding = {
top: 10,
right: 10,
bottom: 10,
left: 10,
};

// Map
export const DURATION_MAP_ZOOM = 1000;
export const DEFAULT_MAP_PADDING = 50;

// Storage

export const KEY_USER_STORAGE = 'user';
export const KEY_LANGUAGE_STORAGE = 'language';

// Search page

export const KEY_URL_SEARCH = 'keyword';
export const SEARCH_TEXT_LENGTH_MIN = 3;

// Colors

export const COLOR_WHITE = '#ffffff';
export const COLOR_TEXT = '#313131';
export const COLOR_TEXT_ON_DARK = COLOR_WHITE;
export const COLOR_LIGHT_GREY = '#e0e0e0';
export const COLOR_DARK_GREY = '#a5a5a5';
export const COLOR_BLACK = '#000000';
export const COLOR_LIGHT_YELLOW = '#ffd470';
export const COLOR_YELLOW = '#ff9e00';
export const COLOR_BLUE = '#4c5d9b';
export const COLOR_LIGHT_BLUE = '#c7d3e0';
export const COLOR_ORANGE = '#ff8000';
export const COLOR_RED = '#f5333f';
export const COLOR_DARK_RED = '#730413';
export const COLOR_PRIMARY_BLUE = '#011e41';
export const COLOR_PRIMARY_RED = '#f5333f';
Loading

0 comments on commit eb48fa0

Please sign in to comment.