Skip to content

Commit

Permalink
fix: use DS local fonts instead of downloading them from third-party …
Browse files Browse the repository at this point in the history
…source

* style: update carbonio configs package
* fix: move out implementations from d.ts files
* chore: ignore carbonio tgz packages
* fix: us DS local fonts instead of downloading them from google

refs: IRIS-3443 (#184)
  • Loading branch information
beawar authored Jan 27, 2023
1 parent e8bacf4 commit 4933726
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 196 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
/coverage/cobertura-coverage.xml
/.vscode/
/.idea/
.dev.json
.dev.json
zextras-carbonio-*.tgz
16 changes: 4 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"postpublish": "pinst --enable && rm -rf lib",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"lint": "eslint --ext .js,.jsx,.ts,.tsx --resolve-plugins-relative-to node_modules/@zextras/zapp-config src",
"lint": "eslint --ext .js,.jsx,.ts,.tsx --resolve-plugins-relative-to node_modules/@zextras/carbonio-ui-configs src",
"build": "sdk build",
"deploy": "sdk deploy",
"start": "sdk watch",
Expand Down Expand Up @@ -97,7 +97,6 @@
"webpack-merge": "5.8.0"
},
"dependencies": {
"@fontsource/roboto": "^4.5.7",
"@sentry/browser": "^6.17.7",
"@tinymce/tinymce-react": "^3.13.0",
"@zextras/carbonio-design-system": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/boot/theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const ThemeProvider: FC = ({ children }) => {
}, [localStorageSettings]);

return (
<UIThemeProvider extension={aggregatedExtensions}>
<UIThemeProvider extension={aggregatedExtensions} loadDefaultFont>
<ThemeCallbacksContext.Provider value={{ addExtension, setDarkReaderState }}>
<GlobalStyle baseFontSize={baseFontSize} />
{children}
Expand Down
23 changes: 17 additions & 6 deletions src/custom-hooks/useDarkReaderResultValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,23 @@ import { useMemo } from 'react';
import { find, size } from 'lodash';
import { useUserSettings } from '../store/account';
import { useLoginConfigStore } from '../store/login/store';
import {
DarkReaderPropValues,
isZappDarkreaderModeZimletProp,
ZappDarkreaderModeZimletProp,
ZimletProp
} from '../../types';
import type { DarkReaderPropValues, ZappDarkreaderModeZimletProp, ZimletProp } from '../../types';
import { DARK_READER_PROP_KEY, DARK_READER_VALUES, SHELL_APP_ID } from '../constants';

export function isZappDarkreaderModeZimletProp(
prop: ZimletProp
): prop is ZappDarkreaderModeZimletProp {
return prop.name === DARK_READER_PROP_KEY && prop.zimlet === SHELL_APP_ID;
}

export function isDarkReaderPropValues(
maybeDarkReaderPropValue: unknown
): maybeDarkReaderPropValue is DarkReaderPropValues {
return (
typeof maybeDarkReaderPropValue === 'string' &&
DARK_READER_VALUES.includes(maybeDarkReaderPropValue as DarkReaderPropValues)
);
}

// return the final calculated value between ZappDarkreaderModeZimletProp value and carbonioWebUiDarkMode config
export function useDarkReaderResultValue(): undefined | DarkReaderPropValues {
Expand Down
6 changes: 0 additions & 6 deletions src/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<!-- connect to domain of font files -->
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin>
<!-- optionally increase loading priority -->
<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=Roboto">
<!-- async CSS -->
<link rel="stylesheet" media="print" onload="this.onload=null;this.removeAttribute('media');" href="https://fonts.googleapis.com/css?family=Roboto">
</head>

<body>
Expand Down
4 changes: 0 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import './index.css';
import React, { lazy, Suspense } from 'react';
import { render } from 'react-dom';
import LoadingView from './boot/splash';
import '@fontsource/roboto/300.css';
import '@fontsource/roboto/400.css';
import '@fontsource/roboto/500.css';
import '@fontsource/roboto/700.css';

window.addEventListener('contextmenu', (ev) => {
if (
Expand Down
3 changes: 2 additions & 1 deletion src/reporting/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import create, { StoreApi, UseBoundStore } from 'zustand';
import { BrowserClient, Hub } from '@sentry/browser';
import { reduce } from 'lodash';
import { CarbonioModule, SHELL_APP_ID } from '../../types';
import type { CarbonioModule } from '../../types';
import { SHELL_APP_ID } from '../constants';

type ReporterState = {
clients: Record<string, Hub>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
import { Select, SelectItem, SingleSelectionOnChange, Text } from '@zextras/carbonio-design-system';
import { find } from 'lodash';
import React, { FC, useCallback, useContext, useEffect, useMemo, useState } from 'react';
import { AddMod, DarkReaderPropValues, isDarkReaderPropValues, RemoveMod } from '../../../../types';
import type { AddMod, DarkReaderPropValues, RemoveMod } from '../../../../types';
import { ThemeCallbacksContext } from '../../../boot/theme-provider';
import { DARK_READER_PROP_KEY, SHELL_APP_ID } from '../../../constants';
import { getT } from '../../../store/i18n';
import { useDarkReaderResultValue } from '../../../custom-hooks/useDarkReaderResultValue';
import {
isDarkReaderPropValues,
useDarkReaderResultValue
} from '../../../custom-hooks/useDarkReaderResultValue';

const DarkThemeSettingSection: FC<{
addMod: AddMod;
Expand Down
10 changes: 2 additions & 8 deletions src/shell/shell-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@

import { Responsive, Row } from '@zextras/carbonio-design-system';
import { PreviewManager } from '@zextras/carbonio-ui-preview';
import { find, size } from 'lodash';
import React, { FC, useContext, useEffect, useMemo, useState } from 'react';
import React, { FC, useContext, useEffect, useState } from 'react';
import styled from 'styled-components';
import {
AppRoute,
isZappDarkreaderModeZimletProp,
ZappDarkreaderModeZimletProp,
ZimletProp
} from '../../types';
import type { AppRoute } from '../../types';
import { ThemeCallbacksContext } from '../boot/theme-provider';
import { IS_STANDALONE } from '../constants';
import { useCurrentRoute } from '../history/hooks';
Expand Down
3 changes: 2 additions & 1 deletion src/store/integrations/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import produce from 'immer';
import create from 'zustand';
import { forEach, omit, reduce } from 'lodash';
import { ComponentType } from 'react';
import { ActionFactory, AnyFunction, IntegrationsState, SHELL_APP_ID } from '../../../types';
import type { ActionFactory, AnyFunction, IntegrationsState } from '../../../types';
import Composer from './composer';
import { SHELL_APP_ID } from '../../constants';

export const useIntegrationsStore = create<IntegrationsState>((set) => ({
actions: {},
Expand Down
3 changes: 2 additions & 1 deletion src/utility-bar/bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import {
} from '@zextras/carbonio-design-system';
import { map, noop } from 'lodash';
import React, { FC, useCallback, useMemo } from 'react';
import { SHELL_APP_ID, UtilityView } from '../../types';
import type { UtilityView } from '../../types';
import { noOp } from '../network/fetch';
import { logout } from '../network/logout';
import { useUserAccount } from '../store/account';
import { addBoard } from '../store/boards';
import { getT } from '../store/i18n';
import { useUtilityBarStore } from './store';
import { useUtilityViews } from './utils';
import { SHELL_APP_ID } from '../constants';

const UtilityBarItem: FC<{ view: UtilityView }> = ({ view }) => {
const { mode, setMode, current, setCurrent } = useUtilityBarStore();
Expand Down
11 changes: 3 additions & 8 deletions types/account/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/

import { DARK_READER_PROP_KEY, SHELL_APP_ID } from '../../src/constants';
import { DarkReaderPropValues } from '../misc';
import type { DarkReaderPropValues } from '../misc';
import { DARK_READER_PROP_KEY } from '../../src/constants';
import type { SHELL_APP_ID } from '../exports';

export interface ZimletProp {
name: string;
Expand All @@ -19,12 +20,6 @@ export interface ZappDarkreaderModeZimletProp extends ZimletProp {
_content: DarkReaderPropValues;
}

export function isZappDarkreaderModeZimletProp(
prop: ZimletProp
): ZimletProp is ZappDarkreaderModeZimletProp {
return prop.name === DARK_READER_PROP_KEY && prop.zimlet === SHELL_APP_ID;
}

export type SoapFetch = <Request, Response>(
api: string,
body: Request,
Expand Down
Loading

0 comments on commit 4933726

Please sign in to comment.