Skip to content

Commit c9e3e8b

Browse files
authoredJan 7, 2025··
feat: export theme augmentation
Remove augmentation of styled-components in favor of the carbonio-design-system one * build(deps): update design system dep * chore: update thirdparties * refactor: move augmentation in separated file and remove export * feat: export theme augmentation to make it available to modules Refs: (#560)
1 parent da80503 commit c9e3e8b

10 files changed

+55
-42
lines changed
 

‎THIRDPARTIES

+13-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ MIT License (MIT) applies to:
1010
@microsoft/api-extractor, Copyright (c) Microsoft Corporation. All rights reserved.
1111
@sentry/browser, Copyright (c) 2019 Sentry (https://sentry.io) and individual contributors. All rights reserved.
1212
@svgr/webpack, Copyright 2017 Smooth Code
13+
@testing-library/dom, Copyright (c) 2017 Kent C. Dodds
1314
@testing-library/jest-dom, Copyright (c) 2017 Kent C. Dodds
1415
@testing-library/react, Copyright (c) 2017 Kent C. Dodds
1516
@testing-library/user-event, Copyright (c) 2020 Giorgio Polvara
@@ -21,7 +22,6 @@ MIT License (MIT) applies to:
2122
@types/react-dom, Copyright (c) Microsoft Corporation.
2223
@types/react-router-dom, Copyright (c) Microsoft Corporation.
2324
@types/react, Copyright (c) Microsoft Corporation.
24-
@types/styled-components, Copyright (c) Microsoft Corporation.
2525
@types/ua-parser-js, Copyright (c) Microsoft Corporation.
2626
@types/webpack-env, Copyright (c) Microsoft Corporation.
2727
@types/webpack, Copyright (c) Microsoft Corporation.
@@ -32,6 +32,7 @@ copy-webpack-plugin, Copyright JS Foundation and other contributors
3232
core-js, Copyright (c) 2014-2024 Denis Pushkarev
3333
css-loader, Copyright JS Foundation and other contributors
3434
darkreader, Copyright (c) 2024 Dark Reader Ltd.
35+
date-fns, Copyright (c) 2021 Sasha Koss and Lesha Koss https://kossnocorp.mit-license.org
3536
eslint-plugin-notice, Copyright (c) 2017 Nick Deis
3637
history, Copyright (c) React Training 2016-2020. Copyright (c) Remix Software 2020-2021
3738
html-webpack-plugin, Copyright JS Foundation and other contributors
@@ -49,8 +50,10 @@ lodash, Copyright OpenJS Foundation and other contributors <https://openjsf.org/
4950
mini-css-extract-plugin, Copyright JS Foundation and other contributors
5051
msw, Copyright (c) 2018–present Artem Zakharchenko
5152
postcss-loader, Copyright JS Foundation and other contributors
53+
posthog-js, Copyright 2020 Posthog / Hiberly, Inc.*
5254
react-dom, Copyright (c) Facebook, Inc. and its affiliates.
5355
react-i18next, Copyright (c) 2023 i18next
56+
react-router-dom-v5-compat, Copyright (c) React Training LLC 2015-2019. Copyright (c) Remix Software Inc. 2020-2021. Copyright (c) Shopify Inc. 2022-2023
5457
react-router-dom, Copyright (c) React Training 2015-2019. Copyright (c) Remix Software 2020-2022
5558
react, Copyright (c) Facebook, Inc. and its affiliates.
5659
styled-components, Copyright (c) 2016-present Glen Maddern and Maximilian Stoiber
@@ -405,11 +408,19 @@ You should also get your employer (if you work as a programmer) or school, if an
405408

406409

407410

411+
BSD* (BSD*) applies to:
412+
413+
babel-plugin-transform-import-meta, Copyright (c) 2019 javiertury
414+
415+
416+
417+
418+
408419
BSD 2-Clause "Simplified" License (BSD-2-Clause) applies to:
409420

410421
dotenv, Copyright (c) 2015, Scott Motte. All rights reserved.
411422

412-
Copyright (c) <year> <owner>
423+
Copyright (c) <year> <owner>
413424

414425
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
415426

‎api-extractor/carbonio-shell-ui.api.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { BadgeInfo as BadgeInfo_2 } from '../../lib';
1111
import type { CaptureOptions } from 'posthog-js';
1212
import { CarbonioModule as CarbonioModule_2 } from '../../types/apps';
1313
import type { ComponentType } from 'react';
14-
import type { DefaultTheme } from 'styled-components';
1514
import { DropdownItem } from '@zextras/carbonio-design-system';
1615
import type { DynamicThemeFix } from 'darkreader';
1716
import type { Event as Event_2 } from '@sentry/browser';
@@ -23,6 +22,7 @@ import type { Properties } from 'posthog-js';
2322
import { default as React_2 } from 'react';
2423
import type { ReactNode } from 'react';
2524
import type { TFunction } from 'i18next';
25+
import type { Theme } from '@zextras/carbonio-design-system';
2626
import type { To } from 'history';
2727

2828
// @public (undocumented)
@@ -332,7 +332,7 @@ export type BadgeInfo = {
332332
icon?: string;
333333
count?: number;
334334
showCount?: boolean;
335-
color?: keyof DefaultTheme['palette'];
335+
color?: keyof Theme['palette'];
336336
};
337337

338338
// @public (undocumented)

‎package-lock.json

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"@fontsource/roboto": "^5.0.8",
107107
"@sentry/browser": "^7.103.0",
108108
"@tinymce/tinymce-react": "^4.3.2",
109-
"@zextras/carbonio-design-system": "9.0.0-devel.7",
109+
"@zextras/carbonio-design-system": "9.0.0-devel.13",
110110
"@zextras/carbonio-ui-preview": "^3.1.0",
111111
"darkreader": "^4.9.79",
112112
"date-fns": "^4.1.0",
@@ -128,7 +128,7 @@
128128
"zustand": "^4.5.1"
129129
},
130130
"peerDependencies": {
131-
"@zextras/carbonio-design-system": "9.0.0-devel.7",
131+
"@zextras/carbonio-design-system": "9.0.0-devel.13",
132132
"@zextras/carbonio-ui-preview": "^3.1.0",
133133
"core-js": "^3.39.0",
134134
"lodash": "^4.17.21",

‎src/boot/theme-provider.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ import React, {
1313
useState
1414
} from 'react';
1515

16-
import type { ThemeProviderProps as UIThemeProviderProps } from '@zextras/carbonio-design-system';
16+
import type {
17+
Theme,
18+
ThemeProviderProps as UIThemeProviderProps
19+
} from '@zextras/carbonio-design-system';
1720
import {
1821
generateColorSet,
1922
ThemeProvider as UIThemeProvider
2023
} from '@zextras/carbonio-design-system';
2124
import { auto, disable, enable, setFetchMethod } from 'darkreader';
2225
import { map, reduce } from 'lodash';
23-
import type { DefaultTheme } from 'styled-components';
2426
import { createGlobalStyle, css } from 'styled-components';
2527

2628
import { useGetPrimaryColor } from './use-get-primary-color';
@@ -30,7 +32,7 @@ import { getAutoScalingFontSize } from '../settings/components/utils';
3032
import { useLocalStorage } from '../shell/hooks/useLocalStorage';
3133
import type { ScalingSettings } from '../types/settings';
3234

33-
export type ThemeExtension = (theme: DefaultTheme) => DefaultTheme;
35+
export type ThemeExtension = (theme: Theme) => Theme;
3436

3537
setFetchMethod(window.fetch);
3638

@@ -48,13 +50,13 @@ export const ThemeCallbacksContext = createContext<ThemeCallbacks>({
4850
}
4951
});
5052

51-
type CustomTheme = Partial<Omit<DefaultTheme, 'palette'>> & {
52-
palette?: Partial<DefaultTheme['palette']>;
53+
type CustomTheme = Partial<Omit<Theme, 'palette'>> & {
54+
palette?: Partial<Theme['palette']>;
5355
};
5456

5557
const paletteExtension =
5658
(customTheme: CustomTheme = {}) =>
57-
(theme: DefaultTheme): DefaultTheme => ({
59+
(theme: Theme): Theme => ({
5860
...theme,
5961
...customTheme,
6062
palette: {
@@ -126,14 +128,12 @@ interface ThemeProviderProps {
126128
export const ThemeProvider = ({ children }: ThemeProviderProps): React.JSX.Element => {
127129
const [localStorageSettings] = useLocalStorage<ScalingSettings>(LOCAL_STORAGE_SETTINGS_KEY, {});
128130

129-
const [extensions, setExtensions] = useState<Partial<Record<keyof DefaultTheme, ThemeExtension>>>(
130-
{}
131-
);
131+
const [extensions, setExtensions] = useState<Partial<Record<keyof Theme, ThemeExtension>>>({});
132132

133133
const primaryColor = useGetPrimaryColor();
134134

135135
useLayoutEffect(() => {
136-
const customThemePalette: Partial<DefaultTheme['palette']> = primaryColor
136+
const customThemePalette: Partial<Theme['palette']> = primaryColor
137137
? { primary: generateColorSet({ regular: primaryColor }) }
138138
: {};
139139
setExtensions((extension) => ({

‎src/lib.ts

+2
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,5 @@ export type { BatchRequest, BatchResponse } from './types/network';
113113
export type { Action } from './types/integrations';
114114

115115
export type { HistoryParams } from './types/misc';
116+
117+
import './types/theme';

‎src/styled-components.d.ts

-18
This file was deleted.

‎src/types/apps/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import type { ComponentType } from 'react';
99
import type React from 'react';
1010

11-
import type { DefaultTheme } from 'styled-components';
11+
import type { Theme } from '@zextras/carbonio-design-system';
1212

1313
export type CarbonioModule = {
1414
commit: string;
@@ -36,7 +36,7 @@ export type BadgeInfo = {
3636
icon?: string;
3737
count?: number;
3838
showCount?: boolean;
39-
color?: keyof DefaultTheme['palette'];
39+
color?: keyof Theme['palette'];
4040
};
4141

4242
export type CarbonioView<P> = {

‎src/types/theme.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com>
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only
5+
*/
6+
import type { CSSProperties } from 'react';
7+
8+
import type { ThemeColorObj } from '@zextras/carbonio-design-system';
9+
10+
declare module '@zextras/carbonio-design-system' {
11+
interface Theme {
12+
globalCursors: CSSProperties['cursor'][];
13+
}
14+
15+
interface Palette {
16+
shared: ThemeColorObj;
17+
linked: ThemeColorObj;
18+
}
19+
}

‎tsconfig.lib.json

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"./src/i18next.d.ts",
1515
"./src/assets.d.ts",
1616
"./src/globals.d.ts",
17-
"./src/styled-components.d.ts",
1817
"node"
1918
]
2019
},

0 commit comments

Comments
 (0)
Please sign in to comment.