@developer_tribe/react-builder 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,14 @@ export type ProjectPageProps = {
10
10
  projectColors?: ProjectColors;
11
11
  onSaveProjectColors?: (colors: ProjectColors) => void;
12
12
  name?: string;
13
- fonts: Fonts;
14
- appFont: string | undefined;
13
+ typography: {
14
+ fonts: Fonts;
15
+ };
16
+ /**
17
+ * Optional. If omitted, `ProjectPage` will infer it from `typography.fonts`:
18
+ * - first font with `isMain: true`
19
+ * - else first font in the list
20
+ */
21
+ appFont?: string | undefined;
15
22
  };
16
- export declare function ProjectPage({ project, appConfig, onSaveProject, logLevel, projectColors, onSaveProjectColors, name, fonts, appFont, }: ProjectPageProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare function ProjectPage({ project, appConfig, onSaveProject, logLevel, projectColors, onSaveProjectColors, name, typography, appFont, }: ProjectPageProps): import("react/jsx-runtime").JSX.Element;
@@ -3,10 +3,14 @@ export type FontWeightKey = string;
3
3
  /** URL to a font file (ttf/otf/woff/woff2). */
4
4
  export type FontFileUrl = string;
5
5
  /** Map of font-weight -> font file URL. */
6
- export type FontFamilySources = Record<FontWeightKey, FontFileUrl>;
6
+ export type FontFamilySources = Record<FontWeightKey, FontFileUrl | undefined>;
7
7
  export type FontDefinition = {
8
8
  name: string;
9
9
  family: FontFamilySources;
10
10
  projects?: string[];
11
+ /** Optional language target for this font (e.g. "ar"). */
12
+ targetLanguage?: string;
13
+ /** Optional marker to pick a default app font. */
14
+ isMain?: boolean;
11
15
  };
12
16
  export type Fonts = FontDefinition[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@developer_tribe/react-builder",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "restricted": true,
@@ -44,9 +44,15 @@ export type ProjectPageProps = {
44
44
  projectColors?: ProjectColors;
45
45
  onSaveProjectColors?: (colors: ProjectColors) => void;
46
46
  name?: string;
47
- fonts: Fonts;
48
- // NOTE: appFont is required as a prop to force the host to think about it.
49
- appFont: string | undefined;
47
+ typography: {
48
+ fonts: Fonts;
49
+ };
50
+ /**
51
+ * Optional. If omitted, `ProjectPage` will infer it from `typography.fonts`:
52
+ * - first font with `isMain: true`
53
+ * - else first font in the list
54
+ */
55
+ appFont?: string | undefined;
50
56
  };
51
57
 
52
58
  const MOBILE_BREAKPOINT = 1000;
@@ -59,12 +65,16 @@ export function ProjectPage({
59
65
  projectColors,
60
66
  onSaveProjectColors,
61
67
  name,
62
- fonts,
68
+ typography,
63
69
  appFont,
64
70
  }: ProjectPageProps) {
65
71
  useLogRender('ProjectPage');
66
72
  useSyncHtmlThemeClass();
67
- useProjectFonts({ fonts, appFont });
73
+ const resolvedAppFont =
74
+ appFont ??
75
+ typography.fonts.find((f) => f?.isMain)?.name ??
76
+ typography.fonts[0]?.name;
77
+ useProjectFonts({ fonts: typography.fonts, appFont: resolvedAppFont });
68
78
  const resolvedName = name ?? project.name;
69
79
  const resolvedProjectColors = projectColors ?? project.projectColors;
70
80
  const isEmptyProjectData =
@@ -5,12 +5,16 @@ export type FontWeightKey = string;
5
5
  export type FontFileUrl = string;
6
6
 
7
7
  /** Map of font-weight -> font file URL. */
8
- export type FontFamilySources = Record<FontWeightKey, FontFileUrl>;
8
+ export type FontFamilySources = Record<FontWeightKey, FontFileUrl | undefined>;
9
9
 
10
10
  export type FontDefinition = {
11
11
  name: string;
12
12
  family: FontFamilySources;
13
13
  projects?: string[];
14
+ /** Optional language target for this font (e.g. "ar"). */
15
+ targetLanguage?: string;
16
+ /** Optional marker to pick a default app font. */
17
+ isMain?: boolean;
14
18
  };
15
19
 
16
20
  export type Fonts = FontDefinition[];