Skip to content

Commit

Permalink
feat: financial statement
Browse files Browse the repository at this point in the history
as a package, but doesn't abide by `@nx/enforce-module-boundaries`
  • Loading branch information
apexearth committed Sep 28, 2023
1 parent 604063e commit 5b6b7ae
Show file tree
Hide file tree
Showing 17 changed files with 222 additions and 5 deletions.
1 change: 0 additions & 1 deletion libs/analytics/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './TimeLineChart';
export * from './FinancialStatement';
12 changes: 12 additions & 0 deletions libs/financial-statement/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
34 changes: 34 additions & 0 deletions libs/financial-statement/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"extends": [
"plugin:@nx/react",
"../../.eslintrc.json"
],
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts",
"*.tsx",
"*.js",
"*.jsx"
],
"rules": {}
},
{
"files": [
"*.ts",
"*.tsx"
],
"rules": {}
},
{
"files": [
"*.js",
"*.jsx"
],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions libs/financial-statement/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# financial-statement

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test financial-statement` to execute the unit tests via [Vitest](https://vitest.dev/).
12 changes: 12 additions & 0 deletions libs/financial-statement/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@origin/financial-statement",
"version": "0.0.4",
"main": "./index.js",
"types": "./index.d.ts",
"exports": {
".": {
"import": "./index.mjs",
"require": "./index.js"
}
}
}
38 changes: 38 additions & 0 deletions libs/financial-statement/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "financial-statement",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/financial-statement/src",
"projectType": "library",
"tags": [],
"targets": {
"lint": {
"executor": "@nx/linter:eslint",
"outputs": [
"{options.outputFile}"
],
"options": {
"lintFilePatterns": [
"libs/financial-statement/**/*.{ts,tsx,js,jsx}"
]
}
},
"build": {
"executor": "@nx/vite:build",
"outputs": [
"{options.outputPath}"
],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/libs/financial-statement"
},
"configurations": {
"development": {
"mode": "development"
},
"production": {
"mode": "production"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ import {
alpha,
Box,
Button,
Experimental_CssVarsProvider,
Paper,
Stack,
Typography,
useMediaQuery,
useTheme,
} from '@mui/material';
import { queryClient } from '@origin/oeth/shared';
import { useChainlinkEthUsd } from '@origin/shared/providers';
import { theme } from '@origin/shared/theme';
import { QueryClientProvider } from '@tanstack/react-query';
import dayjs from 'dayjs';
import LocalizedFormat from 'dayjs/plugin/localizedFormat';
import RelativeTime from 'dayjs/plugin/relativeTime';
import { useIntl } from 'react-intl';
import { IntlProvider, useIntl } from 'react-intl';
import { formatEther } from 'viem';

import * as colors from './colors';
Expand Down Expand Up @@ -44,6 +48,18 @@ const getTotals = (data: Record<string, Record<string, number[]>>) => {
}, [] as number[]);
};

export default function SelfContainedFinancialStatement() {
return (
<IntlProvider messages={{}} locale="en" defaultLocale="en">
<Experimental_CssVarsProvider theme={theme} defaultMode="dark">
<QueryClientProvider client={queryClient}>
<LiveFinancialStatement />
</QueryClientProvider>
</Experimental_CssVarsProvider>
</IntlProvider>
);
}

export const LiveFinancialStatement = () => {
const endOfToday = dayjs().endOf('day').toISOString();
const [sevenDaysAgo] = useState(dayjs().subtract(7, 'days').toISOString());
Expand Down Expand Up @@ -121,8 +137,6 @@ export const LiveFinancialStatement = () => {
);
};

export default LiveFinancialStatement;

const FinancialStatementContext = createContext({
ethPrice: undefined as number | undefined,
showUsdPrice: false,
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions libs/financial-statement/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './FinancialStatement';
export { default } from './FinancialStatement';
25 changes: 25 additions & 0 deletions libs/financial-statement/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": false,
"types": [
"vite/client"
]
},
"files": [
"../../node_modules/@nx/react/typings/cssmodule.d.ts",
"../../node_modules/@nx/react/typings/image.d.ts",
"../../libs/shared/theme/src/theme.d.ts",
"../../apps/oeth/src/env.d.ts"
],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
],
"extends": "../../tsconfig.base.json"
}
28 changes: 28 additions & 0 deletions libs/financial-statement/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"node",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts",
"vite/client"
]
},
"exclude": [
"**/*.spec.ts",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.test.tsx",
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx"
],
"include": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.ts",
"src/**/*.tsx"
]
}
43 changes: 43 additions & 0 deletions libs/financial-statement/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/// <reference types="vitest" />
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
import react from '@vitejs/plugin-react';
import * as path from 'path';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';

export default defineConfig({
cacheDir: '../../node_modules/.vite/financial-statement',

plugins: [
dts({
entryRoot: 'src',
tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'),
skipDiagnostics: true,
}),
react(),
nxViteTsPaths(),
],

// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },

// Configuration for building your library.
// See: https://vitejs.dev/guide/build.html#library-mode
build: {
lib: {
// Could also be a dictionary or array of multiple entry points.
entry: 'src/index.ts',
name: 'financial-statement',
fileName: 'index',
// Change this to the formats you want to support.
// Don't forget to update your package.json as well.
formats: ['es', 'cjs'],
},
rollupOptions: {
// External packages that should not be bundled into your library.
external: ['react', 'react-dom', 'react/jsx-runtime'],
},
},
});
2 changes: 1 addition & 1 deletion libs/shared/utils/src/BigInt.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const jsonStringifyReplacer = (key, value) =>
export const jsonStringifyReplacer = (key: string, value: unknown) =>
typeof value === 'bigint' ? value.toString() : value;
3 changes: 3 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"@origin/analytics": [
"libs/analytics/src/index.ts"
],
"@origin/financial-statement": [
"libs/financial-statement/src/index.ts"
],
"@origin/oeth/history": [
"libs/oeth/history/src/index.ts"
],
Expand Down

0 comments on commit 5b6b7ae

Please sign in to comment.