diff --git a/apps/fluent-tester/src/FluentTester/TestComponents/Button/ButtonIconTest.tsx b/apps/fluent-tester/src/FluentTester/TestComponents/Button/ButtonIconTest.tsx
index 401a5d5b1b..e64cb26dc4 100644
--- a/apps/fluent-tester/src/FluentTester/TestComponents/Button/ButtonIconTest.tsx
+++ b/apps/fluent-tester/src/FluentTester/TestComponents/Button/ButtonIconTest.tsx
@@ -4,7 +4,7 @@ import { Stack } from '@fluentui-react-native/stack';
import * as React from 'react';
import { Platform, View } from 'react-native';
import { stackStyle } from '../Common/styles';
-import { SvgIconProps, FontIconProps } from '@fluentui-react-native/icon';
+import { SvgIconProps } from '@fluentui-react-native/icon';
import TestSvg from './test.svg';
const CustomizedIconButton = Button.customize({
@@ -13,48 +13,35 @@ const CustomizedIconButton = Button.customize({
});
export const ButtonIconTest: React.FunctionComponent<{}> = () => {
- if (Platform.OS == ('win32' as any)) {
- const testImage = require('./icon_24x24.png');
- const testTtf = require('./Font Awesome 5 Free-Solid-900.otf');
+ const testImage = require('./icon_24x24.png');
- const fontProps: FontIconProps = {
- fontFamily: `Font Awesome 5 Free`,
- fontSrcFile: testTtf,
- codepoint: 0xf083,
- fontSize: 16,
- };
+ const svgProps: SvgIconProps = {
+ src: TestSvg,
+ viewBox: '0 0 500 500',
+ };
- const svgProps: SvgIconProps = {
- src: TestSvg,
- viewBox: '0 0 500 500',
- };
+ // SVG-based icons are not available on all platforms yet
+ const svgIconsEnabled = ['ios', 'macos', 'win32'].includes(Platform.OS as string);
- return (
-
-
-
-
+ return (
+
+
+
+ {svgIconsEnabled ? (
+ ) : null}
+ {svgIconsEnabled ? (
-
-
- );
- } else {
- return (
-
-
-
-
-
-
- );
- }
+ ) : null}
+
+
+ );
};
diff --git a/apps/fluent-tester/src/FluentTester/TestComponents/Icon/IconTest.tsx b/apps/fluent-tester/src/FluentTester/TestComponents/Icon/IconTest.tsx
index 14510021df..ed7c41aabf 100644
--- a/apps/fluent-tester/src/FluentTester/TestComponents/Icon/IconTest.tsx
+++ b/apps/fluent-tester/src/FluentTester/TestComponents/Icon/IconTest.tsx
@@ -71,11 +71,7 @@ const icons: React.FunctionComponent<{}> = () => {
{showSvgIcons ? (
SVG icons
- {
- // TODO: Enable on macOS and iOS once we get react-native-svg-transformer working properly
- // See https://github.com/microsoft/fluentui-react-native/issues/644
- (Platform.OS == 'ios' || Platform.OS == 'macos') ? null :
- }
+
{
// TODO: Causes TypeError: Network request failed on Android
Platform.OS == 'android' ? null :
diff --git a/apps/ios/metro.config.js b/apps/ios/metro.config.js
index d5258a71f0..5061bdef27 100644
--- a/apps/ios/metro.config.js
+++ b/apps/ios/metro.config.js
@@ -5,16 +5,27 @@
* @format
*/
-const {getWatchFolders} = require('@uifabricshared/build-native');
+const { getWatchFolders } = require('@uifabricshared/build-native');
+const { getDefaultConfig } = require('metro-config');
-module.exports = {
- watchFolders: getWatchFolders(),
- transformer: {
- getTransformOptions: async () => ({
- transform: {
- experimentalImportSupport: false,
- inlineRequires: false,
- },
- }),
- },
-};
+module.exports = (async () => {
+ const {
+ resolver: { sourceExts, assetExts },
+ } = await getDefaultConfig();
+ return {
+ watchFolders: getWatchFolders(),
+ resolver: {
+ assetExts: assetExts.filter((ext) => ext !== 'svg'),
+ sourceExts: [...sourceExts, 'svg'],
+ },
+ transformer: {
+ babelTransformerPath: require.resolve('react-native-svg-transformer'),
+ getTransformOptions: async () => ({
+ transform: {
+ experimentalImportSupport: false,
+ inlineRequires: false,
+ },
+ }),
+ },
+ };
+})();
diff --git a/apps/ios/package.json b/apps/ios/package.json
index c036d437a9..e933bbc18d 100644
--- a/apps/ios/package.json
+++ b/apps/ios/package.json
@@ -34,7 +34,9 @@
"@uifabricshared/eslint-config-rules": "^0.1.1",
"babel-jest": "^24.9.0",
"jest": "^24.9.0",
+ "metro-config": "^0.58.0",
"metro-react-native-babel-preset": "^0.59.0",
+ "react-native-svg-transformer": "^0.14.3",
"react-test-renderer": "~16.13.1"
},
"jest": {
diff --git a/apps/macos/metro.config.js b/apps/macos/metro.config.js
index 0e318c4a79..5e56e674d7 100644
--- a/apps/macos/metro.config.js
+++ b/apps/macos/metro.config.js
@@ -5,25 +5,34 @@
const path = require('path');
const blacklist = require('metro-config/src/defaults/blacklist');
-const {getWatchFolders} = require('@uifabricshared/build-native');
+const { getWatchFolders } = require('@uifabricshared/build-native');
+const { getDefaultConfig } = require('metro-config');
const rnmPath = path.dirname(require.resolve('react-native-macos/package.json'));
-module.exports = {
- watchFolders: getWatchFolders(),
- resolver: {
- extraNodeModules: {
- 'react-native': rnmPath,
- },
- platforms: ['macos', 'ios'],
- blacklistRE: blacklist([/node_modules\/react-native\/.*/]),
- },
- transformer: {
- getTransformOptions: async () => ({
- transform: {
- experimentalImportSupport: false,
- inlineRequires: false,
+module.exports = (async () => {
+ const {
+ resolver: { sourceExts, assetExts },
+ } = await getDefaultConfig();
+ return {
+ watchFolders: getWatchFolders(),
+ resolver: {
+ assetExts: assetExts.filter((ext) => ext !== 'svg'),
+ sourceExts: [...sourceExts, 'svg'],
+ extraNodeModules: {
+ 'react-native': rnmPath,
},
- }),
- },
-};
+ platforms: ['macos', 'ios'],
+ blacklistRE: blacklist([/node_modules\/react-native\/.*/]),
+ },
+ transformer: {
+ babelTransformerPath: require.resolve('react-native-svg-transformer'),
+ getTransformOptions: async () => ({
+ transform: {
+ experimentalImportSupport: false,
+ inlineRequires: false,
+ },
+ }),
+ },
+ };
+})();
diff --git a/apps/macos/package.json b/apps/macos/package.json
index 0a515068c8..9539762de1 100644
--- a/apps/macos/package.json
+++ b/apps/macos/package.json
@@ -35,6 +35,7 @@
"metro-config": "^0.58.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-native": "^0.63.4",
+ "react-native-svg-transformer": "^0.14.3",
"react-test-renderer": "~16.13.1"
},
"peerDependencies": {
diff --git a/change/@fluentui-react-native-tester-2021-05-19-18-05-38-amgleitman-ios-macos-react-native-svg-transformer.json b/change/@fluentui-react-native-tester-2021-05-19-18-05-38-amgleitman-ios-macos-react-native-svg-transformer.json
new file mode 100644
index 0000000000..253d9ab9c0
--- /dev/null
+++ b/change/@fluentui-react-native-tester-2021-05-19-18-05-38-amgleitman-ios-macos-react-native-svg-transformer.json
@@ -0,0 +1,8 @@
+{
+ "type": "patch",
+ "comment": "Add react-native-svg-transformer to iOS and macOS",
+ "packageName": "@fluentui-react-native/tester",
+ "email": "adam.gleitman@gmail.com",
+ "dependentChangeType": "patch",
+ "date": "2021-05-20T01:05:38.730Z"
+}