-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid portal dependencies from reference external CDN #4931
ref DEV-2357
- Loading branch information
Showing
40 changed files
with
360 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
|
||
set -x | ||
|
||
# This is how we self-host the runtime assets of FluentUI. | ||
# | ||
# We utilize the public directory feature of Vite. | ||
# See https://v2.vitejs.dev/guide/assets.html#the-public-directory | ||
# This feature merely copies the files in the public directory to the root of the outDir. | ||
# Since we use FileServer to serve asset, assets have to be put in the asset directory. | ||
# We automate this copy process with a NPM postinstall script. (This script) | ||
# | ||
# Finally we tell fluentui to load the assets from the portal backend, instead of from the default CDN. | ||
# This is done with window.FabricConfig. | ||
|
||
# In docker build, the postinstall runs before the src are copied. | ||
# So we run mkdir -p to ensure the directory exist. | ||
mkdir -p ./src/public/shared-assets/ | ||
# In case you wonder why we do not just use shell expansion here, | ||
# if ./src/public/shared-assets is really empty, sh DOES NOT expand, and take '*' literally. | ||
# Since we do not have such a file, the command will fail. | ||
find ./src/public/shared-assets -name 'fabric-icons-*.woff' -print -exec rm '{}' \; | ||
# When window.FabricConfig.iconBaseUrl is set, it loads the font directly in the directory. | ||
# So we just copy the fonts to outDir. | ||
cp -r ./node_modules/@fluentui/font-icons-mdl2/fonts/. ./src/public/shared-assets/. | ||
|
||
# When window.FabricConfig.fontBaseUrl is set, it loads the font with a certain structure. | ||
# The original URL is https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-bold.woff2 | ||
# When fontBaseUrl is set, the URL looks like https://origin/shared-assets/fonts/segoeui-westeuropean/segoeui-bold.woff2 | ||
|
||
# FluentUI actually has support for many fonts. | ||
# For the full list of the fonts it may load at runtime, see ./node_modules/@fluentui/react/dist/css/fabric.css | ||
# Since our site is lang=en, it will ever load "Segoe UI Web (West European)" | ||
# So we just download and copy them. | ||
# Since this process has to be done once only, the following commands are commented out. | ||
# wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-light.woff2 -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-light.woff2 | ||
# wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-light.woff -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-light.woff | ||
# wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-semilight.woff2 -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semilight.woff2 | ||
# wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-semilight.woff -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semilight.woff | ||
# wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-regular.woff2 -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-regular.woff2 | ||
# wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-regular.woff -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-regular.woff | ||
# wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-semibold.woff2 -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semibold.woff2 | ||
# wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-semibold.woff -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semibold.woff | ||
# wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-bold.woff2 -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-bold.woff2 | ||
# wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-bold.woff -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-bold.woff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+37.5 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-bold.woff
Binary file not shown.
Binary file added
BIN
+32.2 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-bold.woff2
Binary file not shown.
Binary file added
BIN
+33 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-light.woff
Binary file not shown.
Binary file added
BIN
+28.1 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-light.woff2
Binary file not shown.
Binary file added
BIN
+41.2 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-regular.woff
Binary file not shown.
Binary file added
BIN
+35.5 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-regular.woff2
Binary file not shown.
Binary file added
BIN
+36.4 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semibold.woff
Binary file not shown.
Binary file added
BIN
+31.1 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semibold.woff2
Binary file not shown.
Binary file added
BIN
+34.5 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semilight.woff
Binary file not shown.
Binary file added
BIN
+29.2 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semilight.woff2
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
import { useCallback, useMemo } from "react"; | ||
import { IStyleFunctionOrObject, IStyleSet } from "@fluentui/react"; | ||
import { IStyleFunctionOrObject } from "@fluentui/react"; | ||
import { | ||
concatStyleSetsWithProps, | ||
concatStyleSets, | ||
IConcatenatedStyleSet, | ||
IStyleSetBase, | ||
} from "@fluentui/merge-styles"; | ||
|
||
export function useMergedStyles<TStylesProps, IStyleSet>( | ||
...styless: (IStyleFunctionOrObject<TStylesProps, IStyleSet> | undefined)[] | ||
): IStyleFunctionOrObject<TStylesProps, IStyleSet> { | ||
export function useMergedStyles<TStylesProps, TStyleSet extends IStyleSetBase>( | ||
...styless: (IStyleFunctionOrObject<TStylesProps, TStyleSet> | undefined)[] | ||
): ( | ||
props: TStylesProps | ||
) => ReturnType<typeof concatStyleSetsWithProps<TStylesProps, TStyleSet>> { | ||
return useCallback( | ||
(props) => { | ||
return concatStyleSetsWithProps(props, ...styless); | ||
}, | ||
// eslint-disable-next-line | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[...styless] | ||
); | ||
} | ||
|
||
export function useMergedStylesPlain( | ||
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents | ||
...styless: (IStyleSet | undefined)[] | ||
): IConcatenatedStyleSet<IStyleSet> { | ||
export function useMergedStylesPlain<TStyleSet extends IStyleSetBase>( | ||
...styless: (TStyleSet | undefined)[] | ||
): IConcatenatedStyleSet<TStyleSet> { | ||
return useMemo( | ||
() => concatStyleSets(...styless), | ||
// eslint-disable-next-line | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[...styless] | ||
) as IConcatenatedStyleSet<IStyleSet>; | ||
) as IConcatenatedStyleSet<TStyleSet>; | ||
} |