Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffold out cross-platform ui-kit project #42

Merged
merged 7 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8,792 changes: 5,116 additions & 3,676 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"license": "MPL-2.0",
"private": true,
"scripts": {
"lint": "npm run lint --workspaces --if-present -- --max-warnings=0",
"lint:fix": "npm run lint --workspaces --if-present -- --fix --max-warnings=0",
"typecheck": "npm run typecheck --workspaces --if-present",
"lint": "nx run-many -t lint --max-warnings=0",
"lint:fix": "nx run-many -t lint --fix --max-warnings=0",
"typecheck": "nx run-many -t typecheck",
"postinstall": "git submodule update --init --recursive"
},
"devDependencies": {
Expand Down
9 changes: 9 additions & 0 deletions packages/mobile-app/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export default function Layout() {
),
}}
/>
<Tabs.Screen
name="ui"
options={{
title: "UI Kit",
tabBarIcon: ({ color, size }) => (
<FontAwesome name="paint-brush" size={size} color={color} />
),
}}
/>
</Tabs>
);
}
13 changes: 5 additions & 8 deletions packages/mobile-app/app/(tabs)/contacts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Button } from "@ironfish/ui";
import { View, Text } from "react-native";
import { View, Text, Button } from "react-native";

import { useFacade } from "../../data/facades";

Expand All @@ -26,16 +25,14 @@ export default function Contacts() {
onPress={async () => {
await resumeSyncing.mutateAsync(undefined);
}}
>
Resume Syncing
</Button>
title="Resume Syncing"
/>
<Button
onPress={async () => {
await pauseSyncing.mutateAsync(undefined);
}}
>
Pause Syncing
</Button>
title="Pause Syncing"
/>
</View>
);
}
23 changes: 9 additions & 14 deletions packages/mobile-app/app/(tabs)/transact.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { View, Text, ScrollView, TextInput } from "react-native";
import { View, Text, ScrollView, TextInput, Button } from "react-native";
import { useFacade } from "../../data/facades";
import { Button } from "@ironfish/ui";
import { useQueryClient } from "@tanstack/react-query";
import React from "react";
import { AccountFormat } from "@ironfish/sdk";
Expand Down Expand Up @@ -49,9 +48,8 @@ export default function Transact() {
await removeAccount.mutateAsync({ name: account.name });
console.log("Removed Account", account.name);
}}
>
Remove Account
</Button>
title="Remove Account"
/>
<Button
onPress={async () => {
const otherResult = await exportAccount.mutateAsync({
Expand All @@ -60,19 +58,17 @@ export default function Transact() {
});
console.log("Exported Account:", otherResult);
}}
>
Export Account
</Button>
title="Export Account"
/>
</View>
))}
<Button
onPress={async () => {
const otherResult = await createAccount.mutateAsync({ name: "dave" });
console.log("Created Account:", otherResult);
}}
>
Create Account
</Button>
title="Create Account"
/>
<TextInput
value={importAccountText}
onChangeText={setImportAccountText}
Expand All @@ -86,9 +82,8 @@ export default function Transact() {
});
console.log("Imported Account:", otherResult);
}}
>
Import Account
</Button>
title="Import Account"
/>
</ScrollView>
);
}
16 changes: 16 additions & 0 deletions packages/mobile-app/app/(tabs)/ui.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Button } from "@ironfish/ui";
import { View } from "react-native";

export default function UiKit() {
return (
<View
style={{
gap: 10,
padding: 10,
}}
>
<Button label="Medium button" />
<Button label="Small button" size="sm" />
</View>
);
}
31 changes: 14 additions & 17 deletions packages/mobile-app/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Text } from "react-native";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

import { useColorScheme } from "react-native";
import { UIKitProvider } from "@ironfish/ui";
import { FacadeProvider, useFacade } from "../data/facades";
import { useEffect, useState } from "react";

Expand Down Expand Up @@ -46,22 +45,20 @@ export default function Layout() {
const scheme = useColorScheme();
return (
<ThemeProvider value={scheme === "dark" ? DarkTheme : DefaultTheme}>
<UIKitProvider colorScheme={scheme || "light"}>
<QueryClientProvider client={queryClient}>
<FacadeProvider>
<DatabaseLoader loading={<Text>Loading databases...</Text>}>
<Stack>
<Stack.Screen
name="(tabs)"
options={{
headerShown: false,
}}
/>
</Stack>
</DatabaseLoader>
</FacadeProvider>
</QueryClientProvider>
</UIKitProvider>
<QueryClientProvider client={queryClient}>
<FacadeProvider>
<DatabaseLoader loading={<Text>Loading databases...</Text>}>
<Stack>
<Stack.Screen
name="(tabs)"
options={{
headerShown: false,
}}
/>
</Stack>
</DatabaseLoader>
</FacadeProvider>
</QueryClientProvider>
</ThemeProvider>
);
}
14 changes: 1 addition & 13 deletions packages/mobile-app/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
plugins: [
...(process.env.EAS_BUILD_PLATFORM === "android"
? []
: [
[
"@tamagui/babel-plugin",
{
components: ["@ironfish/ui", "tamagui"],
config: "../../packages/ui-kit/src/theme/config.ts",
},
],
]),
],
plugins: [],
};
};
1 change: 0 additions & 1 deletion packages/mobile-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@tamagui/babel-plugin": "1.102.1",
"@types/react": "~18.2.79",
"eslint-config-expo": "^7.0.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/mobile-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
},
"ios": {
"dependsOn": ["pod-sim"]
},
"lint": {
"dependsOn": ["^build"]
},
"typecheck": {
"dependsOn": ["^build"]
}
}
}
5 changes: 5 additions & 0 deletions packages/ui-kit/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"plugin:storybook/recommended"
]
}
27 changes: 27 additions & 0 deletions packages/ui-kit/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { StorybookConfig } from "@storybook/react-webpack5";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-webpack5-compiler-swc",
"@storybook/addon-onboarding",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-webpack5",
options: {},
},
webpackFinal: async (config) => {
if (config.resolve) {
config.resolve.alias = {
...config.resolve?.alias,
"react-native": "react-native-web",
};
}
return config;
},
};
export default config;
14 changes: 14 additions & 0 deletions packages/ui-kit/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Preview } from "@storybook/react";

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
7 changes: 7 additions & 0 deletions packages/ui-kit/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function (api) {
api.cache(true);
return {
presets: ["module:metro-react-native-babel-preset"],
plugins: ["react-native-web"],
};
};
Loading
Loading