Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

theme: make imports esm compatible

Abdullah Atta95b50eb5ca73
diff --git a/packages/theme/src/emotion/index.ts b/packages/theme/src/emotion/index.ts
index 3689ee1cd..5b6a12530 100644
--- a/packages/theme/src/emotion/index.ts
+++ b/packages/theme/src/emotion/index.ts
@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-export * from "./theme-provider";
+export * from "./theme-provider.js";
diff --git a/packages/theme/src/emotion/theme-provider.tsx b/packages/theme/src/emotion/theme-provider.tsx
index cc9dd9529..49e22bd4b 100644
--- a/packages/theme/src/emotion/theme-provider.tsx
+++ b/packages/theme/src/emotion/theme-provider.tsx
@@ -18,17 +18,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { ThemeProvider } from "@theme-ui/core";
-import {
- ThemeScopes,
- useThemeColors,
- useThemeEngineStore,
- ScopedThemeProvider as NNScopedThemeProvider,
- ThemeFactory,
- Theme
-} from "../";
import React, { ForwardedRef, PropsWithChildren, useMemo } from "react";
import { Box, BoxProps } from "@theme-ui/components";
import { useTheme } from "@emotion/react";
+import { ThemeScopes } from "../theme-engine/types.js";
+import { Theme, ThemeFactory } from "../theme/index.js";
+import {
+ ScopedThemeProvider,
+ useThemeColors,
+ useThemeEngineStore
+} from "../theme-engine/index.js";
export type EmotionThemeProviderProps = {
scope?: keyof ThemeScopes;
@@ -72,7 +71,7 @@ function _EmotionThemeProvider(
colors: themeProperties.colors
}}
>
- <NNScopedThemeProvider value={scope}>
+ <ScopedThemeProvider value={scope}>
{injectCssVars ? (
<Box
{...restProps}
@@ -86,7 +85,7 @@ function _EmotionThemeProvider(
) : (
children
)}
- </NNScopedThemeProvider>
+ </ScopedThemeProvider>
</ThemeProvider>
);
}
diff --git a/packages/theme/src/index.ts b/packages/theme/src/index.ts
index e4c8ffce1..cfdb333ae 100644
--- a/packages/theme/src/index.ts
+++ b/packages/theme/src/index.ts
@@ -16,12 +16,15 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { SchemeColors, SchemeColorsAsCSSVariables } from "./theme-engine/types";
+import {
+ SchemeColors,
+ SchemeColorsAsCSSVariables
+} from "./theme-engine/types.js";
-export * from "./theme";
-export * from "./theme-engine";
-export * from "./theme-engine/types";
-export * from "./emotion";
+export * from "./theme/index.js";
+export * from "./theme-engine/index.js";
+export * from "./theme-engine/types.js";
+export * from "./emotion/index.js";
declare module "csstype" {
interface Properties {
diff --git a/packages/theme/src/theme-engine/index.ts b/packages/theme/src/theme-engine/index.ts
index 82c24d044..c7c13cc8b 100644
--- a/packages/theme/src/theme-engine/index.ts
+++ b/packages/theme/src/theme-engine/index.ts
@@ -26,8 +26,8 @@ import {
ThemeDefinition,
ThemeScopes,
VariantsWithStaticColors
-} from "./types";
-import { buildVariants } from "./utils";
+} from "./types.js";
+import { buildVariants } from "./utils.js";
const ThemeLight = _ThemeLight as ThemeDefinition;
const ThemeDark = _ThemeDark as ThemeDefinition;
@@ -73,5 +73,5 @@ export const useCurrentThemeScope = () => useContext(ThemeScopeContext);
export const ScopedThemeProvider = ThemeScopeContext.Provider;
export const THEME_COMPATIBILITY_VERSION: ThemeCompatibilityVersion = 1;
export { ThemeLight, ThemeDark, useThemeEngineStore, type ThemeEngineState };
-export { getPreviewColors, themeToCSS } from "./utils";
-export { validateTheme } from "./validator";
+export { getPreviewColors, themeToCSS } from "./utils.js";
+export { validateTheme } from "./validator.js";
diff --git a/packages/theme/src/theme-engine/utils.ts b/packages/theme/src/theme-engine/utils.ts
index b5ce9bad4..de697f185 100644
--- a/packages/theme/src/theme-engine/utils.ts
+++ b/packages/theme/src/theme-engine/utils.ts
@@ -26,7 +26,7 @@ import {
ThemeScopes,
Variants,
VariantsWithStaticColors
-} from "./types";
+} from "./types.js";
import _ThemeLight from "./themes/default-light.json";
import tc from "tinycolor2";
import _ThemeDark from "./themes/default-dark.json";
diff --git a/packages/theme/src/theme-engine/validator.ts b/packages/theme/src/theme-engine/validator.ts
index df49fccfb..53ed46926 100644
--- a/packages/theme/src/theme-engine/validator.ts
+++ b/packages/theme/src/theme-engine/validator.ts
@@ -24,7 +24,7 @@ import {
DEPRECATED_COLORS,
ThemeDefinition,
Variants
-} from "./types";
+} from "./types.js";
const RequiredKeys = [
"version",
diff --git a/packages/theme/src/theme/font/index.ts b/packages/theme/src/theme/font/index.ts
index 01401c214..5490035ae 100644
--- a/packages/theme/src/theme/font/index.ts
+++ b/packages/theme/src/theme/font/index.ts
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { FontSizes, getFontSizes } from "./fontsize";
+import { FontSizes, getFontSizes } from "./fontsize.js";
const SANS_FONT_STACK = [
`"Open Sans"`,
diff --git a/packages/theme/src/theme/index.ts b/packages/theme/src/theme/index.ts
index 9687a4a7d..434df06a2 100644
--- a/packages/theme/src/theme/index.ts
+++ b/packages/theme/src/theme/index.ts
@@ -17,13 +17,14 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { variants } from "./variants";
-import { FontConfig, getFontConfig } from "./font";
-import { ThemeConfig } from "./types";
-import { ThemeColor, VariantsWithStaticColors } from "../theme-engine/types";
-import { ThemeUIConfig } from "@theme-ui/css/dist/declarations/src/options";
+import { variants } from "./variants/index.js";
+import { FontConfig, getFontConfig } from "./font/index.js";
+import { ThemeConfig } from "./types.js";
+import { ThemeColor, VariantsWithStaticColors } from "../theme-engine/types.js";
+import { Theme as ThemeUITheme } from "@theme-ui/css";
-export { createButtonVariant } from "./variants/button";
+export { createButtonVariant } from "./variants/button.js";
+export { getFontConfig } from "./font/index.js";
export type Theme = {
breakpoints: string[];
space: number[] & { small?: number | string };
@@ -41,7 +42,7 @@ export type Theme = {
medium: number;
big: number;
};
- config: ThemeUIConfig;
+ config: ThemeUITheme["config"];
} & FontConfig &
typeof variants;
diff --git a/packages/theme/src/theme/types.ts b/packages/theme/src/theme/types.ts
index ac7ceb86a..cbd9a38f9 100644
--- a/packages/theme/src/theme/types.ts
+++ b/packages/theme/src/theme/types.ts
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { VariantsWithStaticColors } from "../theme-engine/types";
+import { VariantsWithStaticColors } from "../theme-engine/types.js";
export type ThemeConfig = {
colorScheme: "dark" | "light";
scope: VariantsWithStaticColors;
diff --git a/packages/theme/src/theme/variants/button.ts b/packages/theme/src/theme/variants/button.ts
index ecb8937d8..a003a1c1f 100644
--- a/packages/theme/src/theme/variants/button.ts
+++ b/packages/theme/src/theme/variants/button.ts
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { ThemeUIStyleObject } from "@theme-ui/core";
-import { SchemeColors } from "../../theme-engine/types";
+import { SchemeColors } from "../../theme-engine/types.js";
import { alpha } from "@theme-ui/color";
export const createButtonVariant = (
diff --git a/packages/theme/src/theme/variants/index.ts b/packages/theme/src/theme/variants/index.ts
index 986774a3b..2ff3be5f8 100644
--- a/packages/theme/src/theme/variants/index.ts
+++ b/packages/theme/src/theme/variants/index.ts
@@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { buttonVariants } from "./button";
-import { inputVariants } from "./input";
-import { textVariants } from "./text";
-import { createFlexVariants } from "./flex";
+import { buttonVariants } from "./button.js";
+import { inputVariants } from "./input.js";
+import { textVariants } from "./text.js";
+import { createFlexVariants } from "./flex.js";
export const variants = {
buttons: buttonVariants,