Skip to content

Commit ea08ec4

Browse files
committed
Update svg.d.ts
1 parent 97eb592 commit ea08ec4

File tree

16 files changed

+2415
-186
lines changed

16 files changed

+2415
-186
lines changed

package-lock.json

Lines changed: 2053 additions & 109 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Loading

packages/mobile-app/app/(tabs)/ui.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,26 @@ export default function UiKit() {
99
padding: 10,
1010
}}
1111
>
12-
<Button label="Medium button" />
13-
<Button label="Small button" size="sm" />
12+
{/* Solid */}
13+
<Button label="Click me" />
14+
15+
{/* Solid with icon */}
16+
<Button iconLeft="arrow-left-bottom" label="Click me" />
17+
18+
{/* Solid small */}
19+
<Button label="Click me" size="sm" />
20+
21+
{/* Solid disabled */}
22+
<Button iconLeft="arrow-left-bottom" label="Click me" disabled />
23+
24+
{/* Outline */}
25+
<Button label="Click me" variant="outline" />
26+
27+
{/* Outline with icon */}
28+
<Button iconLeft="arrow-left-bottom" label="Click me" variant="outline" />
29+
30+
{/* Outline small */}
31+
<Button label="Click me" size="sm" variant="outline" />
1432
</View>
1533
);
1634
}

packages/mobile-app/metro.config.js

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,6 @@ const path = require("path");
99
const projectRoot = __dirname;
1010
const monorepoRoot = path.resolve(projectRoot, "../..");
1111

12-
const config = getDefaultConfig(projectRoot);
13-
14-
config.watchFolders = [monorepoRoot];
15-
16-
config.resolver.nodeModulesPaths = [
17-
path.resolve(projectRoot, "node_modules"),
18-
path.resolve(monorepoRoot, "node_modules"),
19-
];
20-
21-
config.resolver.disableHierarchicalLookup = true;
22-
23-
config.transformer = {
24-
...config.transformer,
25-
unstable_allowRequireContext: true,
26-
};
27-
2812
// Modules in our node_modules that are used and require React Native-specific overrides
2913
// (whether because we need them in React Native, or because they're executed when code is required in @ironfish/sdk)
3014
const shims = {
@@ -56,41 +40,63 @@ const emptyModules = new Set([
5640
"sqlite3",
5741
]);
5842

59-
config.resolver.resolveRequest = (context, moduleName, platform) => {
60-
if (shims[moduleName]) {
61-
return shims[moduleName];
62-
}
43+
module.exports = (() => {
44+
const config = getDefaultConfig(projectRoot);
45+
const { transformer, resolver } = config;
6346

64-
if (emptyModules.has(moduleName)) {
65-
return {
66-
type: "empty",
67-
};
68-
}
47+
config.watchFolders = [monorepoRoot];
6948

70-
// Optionally, chain to the standard Metro resolver.
71-
return context.resolveRequest(context, moduleName, platform);
72-
};
49+
config.resolver = {
50+
...resolver,
51+
nodeModulesPaths: [
52+
path.resolve(projectRoot, "node_modules"),
53+
path.resolve(monorepoRoot, "node_modules"),
54+
],
55+
disableHierarchicalLookup: true,
56+
resolveRequest: (context, moduleName, platform) => {
57+
if (shims[moduleName]) {
58+
return shims[moduleName];
59+
}
7360

74-
// Node.js built-in modules that are unused.
75-
// These will only be replaced with empty modules if they can't be found in the project's node_modules.
76-
// If the project includes a module with the same name, it will be used instead.
77-
// Modules with slashes in the name need to go in emptyModules instead.
78-
config.resolver.extraNodeModules = {
79-
...config.resolver.extraNodeModules,
80-
assert: config.resolver.emptyModulePath,
81-
child_process: config.resolver.emptyModulePath,
82-
crypto: config.resolver.emptyModulePath,
83-
events: config.resolver.emptyModulePath,
84-
fs: config.resolver.emptyModulePath,
85-
http: config.resolver.emptyModulePath,
86-
net: config.resolver.emptyModulePath,
87-
os: config.resolver.emptyModulePath,
88-
stream: config.resolver.emptyModulePath,
89-
tls: config.resolver.emptyModulePath,
90-
url: config.resolver.emptyModulePath,
91-
util: config.resolver.emptyModulePath,
92-
worker_threads: config.resolver.emptyModulePath,
93-
v8: config.resolver.emptyModulePath,
94-
};
61+
if (emptyModules.has(moduleName)) {
62+
return {
63+
type: "empty",
64+
};
65+
}
66+
67+
// Optionally, chain to the standard Metro resolver.
68+
return context.resolveRequest(context, moduleName, platform);
69+
},
70+
// Node.js built-in modules that are unused.
71+
// These will only be replaced with empty modules if they can't be found in the project's node_modules.
72+
// If the project includes a module with the same name, it will be used instead.
73+
// Modules with slashes in the name need to go in emptyModules instead.
74+
extraNodeModules: {
75+
...resolver.extraNodeModules,
76+
assert: resolver.emptyModulePath,
77+
child_process: resolver.emptyModulePath,
78+
crypto: resolver.emptyModulePath,
79+
events: resolver.emptyModulePath,
80+
fs: resolver.emptyModulePath,
81+
http: resolver.emptyModulePath,
82+
net: resolver.emptyModulePath,
83+
os: resolver.emptyModulePath,
84+
stream: resolver.emptyModulePath,
85+
tls: resolver.emptyModulePath,
86+
url: resolver.emptyModulePath,
87+
util: resolver.emptyModulePath,
88+
worker_threads: resolver.emptyModulePath,
89+
v8: resolver.emptyModulePath,
90+
},
91+
assetExts: resolver.assetExts.filter((ext) => ext !== "svg"),
92+
sourceExts: [...resolver.sourceExts, "svg"],
93+
};
94+
95+
config.transformer = {
96+
...transformer,
97+
unstable_allowRequireContext: true,
98+
babelTransformerPath: require.resolve("react-native-svg-transformer/expo"),
99+
};
95100

96-
module.exports = config;
101+
return config;
102+
})();

packages/mobile-app/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@
3131
"react-native": "0.74.3",
3232
"react-native-safe-area-context": "4.10.8",
3333
"react-native-screens": "3.32.0",
34+
"react-native-svg": "15.2.0",
3435
"zod": "^3.22.4"
3536
},
3637
"devDependencies": {
3738
"@babel/core": "^7.20.0",
39+
"@svgr/webpack": "^8.1.0",
3840
"@types/react": "~18.2.79",
3941
"eslint-config-expo": "^7.0.0",
4042
"eslint-config-prettier": "^9.1.0",
4143
"eslint-plugin-prettier": "^5.1.3",
42-
"prettier": "^3.3.2"
44+
"prettier": "^3.3.2",
45+
"react-native-svg-transformer": "^1.5.0"
4346
},
4447
"private": true
4548
}

packages/ui-kit/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/icons

packages/ui-kit/.storybook/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const config: StorybookConfig = {
99
"@storybook/addon-essentials",
1010
"@chromatic-com/storybook",
1111
"@storybook/addon-interactions",
12+
"@newhighsco/storybook-addon-svgr",
1213
],
1314
framework: {
1415
name: "@storybook/react-webpack5",

packages/ui-kit/package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"scripts": {
7-
"build": "tsc -p tsconfig.build.json",
8-
"dev": "tsc -p tsconfig.build.json --watch",
7+
"clean": "rimraf dist icons",
8+
"build": "npm run clean && tsc -p tsconfig.build.json && npm run copy-icons",
9+
"dev": "npm run clean && npm run copy-icons && tsc -p tsconfig.build.json --watch",
910
"storybook": "storybook dev -p 6006",
1011
"build-storybook": "storybook build",
12+
"copy-icons": "cpx 'src/components/Icon/**/*.svg' dist/components/Icon",
1113
"typecheck": "tsc --noEmit"
1214
},
1315
"dependencies": {
@@ -20,20 +22,22 @@
2022
},
2123
"devDependencies": {
2224
"@chromatic-com/storybook": "^1.6.1",
25+
"@newhighsco/storybook-addon-svgr": "^2.0.24",
2326
"@storybook/addon-essentials": "^8.2.9",
2427
"@storybook/addon-interactions": "^8.2.9",
2528
"@storybook/addon-links": "^8.2.9",
2629
"@storybook/addon-onboarding": "^8.2.9",
2730
"@storybook/addon-webpack5-compiler-swc": "^1.0.5",
2831
"@storybook/blocks": "^8.2.9",
29-
"@storybook/react-webpack5": "^8.2.9",
3032
"@storybook/react": "^8.2.9",
33+
"@storybook/react-webpack5": "^8.2.9",
3134
"@storybook/test": "^8.2.9",
3235
"@types/react": "~18.2.79",
3336
"babel-loader": "^9.1.3",
3437
"babel-plugin-react-native-web": "^0.19.12",
35-
"eslint-plugin-storybook": "^0.8.0",
38+
"cpx": "^1.5.0",
3639
"eslint": "8.56.0",
40+
"eslint-plugin-storybook": "^0.8.0",
3741
"react": "18.2.0",
3842
"react-dom": "18.2.0",
3943
"react-native": "0.74.3",
Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import React from "react";
12
import type { Meta, StoryObj } from "@storybook/react";
23
import { fn } from "@storybook/test";
34
import { Button } from "./Button";
5+
import { Icon } from "../Icon/Icon";
46

57
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
68
const meta = {
7-
title: "Example/Button",
9+
title: "Components/Button",
810
component: Button,
911
parameters: {
1012
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
@@ -15,6 +17,7 @@ const meta = {
1517
// More on argTypes: https://storybook.js.org/docs/api/argtypes
1618
argTypes: {
1719
label: { control: "text" },
20+
variant: { options: ["outline", "solid"] },
1821
},
1922
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
2023
args: { onPress: fn() },
@@ -23,15 +26,53 @@ const meta = {
2326
export default meta;
2427
type Story = StoryObj<typeof meta>;
2528

26-
export const Primary: Story = {
29+
export const Solid: Story = {
2730
args: {
28-
label: "Medium button",
31+
label: "Click me",
2932
},
3033
};
3134

32-
export const Secondary: Story = {
35+
export const SolidWithIcon: Story = {
3336
args: {
34-
label: "Small button",
37+
iconLeft: "arrow-left-bottom",
38+
label: "Click me",
39+
},
40+
};
41+
42+
export const SolidSmall: Story = {
43+
args: {
44+
label: "Click me",
45+
size: "sm",
46+
},
47+
};
48+
49+
export const SolidDisabled: Story = {
50+
args: {
51+
iconLeft: "arrow-left-bottom",
52+
label: "Click me",
53+
disabled: true,
54+
},
55+
};
56+
57+
export const Outline: Story = {
58+
args: {
59+
label: "Click me",
60+
variant: "outline",
61+
},
62+
};
63+
64+
export const OutlineWithIcon: Story = {
65+
args: {
66+
iconLeft: "arrow-left-bottom",
67+
label: "Click me",
68+
variant: "outline",
69+
},
70+
};
71+
72+
export const OutlineSmall: Story = {
73+
args: {
74+
label: "Click me",
3575
size: "sm",
76+
variant: "outline",
3677
},
3778
};

0 commit comments

Comments
 (0)