Skip to content

Commit

Permalink
feat: financial statement
Browse files Browse the repository at this point in the history
abide by `@nx/enforce-module-boundaries`, converting packages to be buildable
  • Loading branch information
apexearth committed Sep 29, 2023
1 parent 5b6b7ae commit fc2ad08
Show file tree
Hide file tree
Showing 26 changed files with 385 additions and 104 deletions.
2 changes: 1 addition & 1 deletion libs/financial-statement/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@origin/financial-statement",
"version": "0.0.4",
"version": "0.0.5",
"main": "./index.js",
"types": "./index.d.ts",
"exports": {
Expand Down
6 changes: 0 additions & 6 deletions libs/financial-statement/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
"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": [
{
Expand Down
8 changes: 6 additions & 2 deletions libs/financial-statement/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
"outDir": "../../dist/out-tsc",
"types": [
"node",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts",
"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"
],
"exclude": [
"**/*.spec.ts",
"**/*.test.ts",
Expand Down
3 changes: 1 addition & 2 deletions libs/financial-statement/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export default defineConfig({
plugins: [
dts({
entryRoot: 'src',
tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'),
skipDiagnostics: true,
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
}),
react(),
nxViteTsPaths(),
Expand Down
101 changes: 54 additions & 47 deletions libs/oeth/history/src/components/Filters.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';

import {
alpha,
Expand All @@ -21,6 +21,8 @@ import { useIntl } from 'react-intl';

import { HistoryFilterButton } from './HistoryButton';

import type { HistoryType } from '@origin/oeth/shared';

const styles = {
fontSize: '0.75rem',
fontWeight: 500,
Expand All @@ -29,16 +31,19 @@ const styles = {
};

interface Props {
onChange: (values: string[]) => void;
onChange: (values: HistoryType[]) => void;
}

export function HistoryFilters({ onChange }: Props) {
const [selected, setSelectedTypes] = useState<string[]>([]);
const [selected, setSelectedTypes] = useState<HistoryType[]>([]);
const intl = useIntl();
const theme = useTheme();
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);

function selection(e: React.ChangeEvent<HTMLInputElement>, label: string) {
function selection(
e: React.ChangeEvent<HTMLInputElement>,
label: HistoryType,
) {
setSelectedTypes((prev) => {
if (e.target.checked) {
return [...prev, label];
Expand Down Expand Up @@ -94,52 +99,54 @@ export function HistoryFilters({ onChange }: Props) {
</Typography>
<Divider sx={{ marginBlockEnd: 2 }} />

{['Yield', 'Swap', 'Sent', 'Received'].map((label) => (
<Stack
key={label}
direction="row"
justifyContent="space-between"
alignItems="center"
sx={{
paddingInline: 2,
paddingBlock: 0,
paddingTop: 0,
paddingBottom: 0,
...styles,
':hover': {
background: (theme) => theme.palette.grey[700],
},
}}
>
<FormLabel htmlFor={label} sx={{ color: 'primary.contrastText' }}>
{label}
</FormLabel>

<Checkbox
inputProps={{ id: label }}
checked={selected.includes(label)}
checkedIcon={<CheckboxIcon />}
icon={<EmptyCheckbox />}
{(['Yield', 'Swap', 'Sent', 'Received'] as HistoryType[]).map(
(label) => (
<Stack
key={label}
direction="row"
justifyContent="space-between"
alignItems="center"
sx={{
'& svg, input': {
width: '1.25rem',
height: '1.25rem',
top: 'auto',
left: 'auto',
},
'&:hover:has(input:checked) svg': {
fill: (theme) => alpha(theme.palette.secondary.main, 0.4),
strokeWidth: '1px',
stroke: (theme) => theme.palette.primary.main,
},
'&:hover:has(input:not(:checked)) svg': {
fill: (theme) => alpha(theme.palette.secondary.main, 0.4),
paddingInline: 2,
paddingBlock: 0,
paddingTop: 0,
paddingBottom: 0,
...styles,
':hover': {
background: (theme) => theme.palette.grey[700],
},
}}
onChange={(e) => selection(e, label)}
/>
</Stack>
))}
>
<FormLabel htmlFor={label} sx={{ color: 'primary.contrastText' }}>
{label}
</FormLabel>

<Checkbox
inputProps={{ id: label }}
checked={selected.includes(label)}
checkedIcon={<CheckboxIcon />}
icon={<EmptyCheckbox />}
sx={{
'& svg, input': {
width: '1.25rem',
height: '1.25rem',
top: 'auto',
left: 'auto',
},
'&:hover:has(input:checked) svg': {
fill: (theme) => alpha(theme.palette.secondary.main, 0.4),
strokeWidth: '1px',
stroke: (theme) => theme.palette.primary.main,
},
'&:hover:has(input:not(:checked)) svg': {
fill: (theme) => alpha(theme.palette.secondary.main, 0.4),
},
}}
onChange={(e) => selection(e, label)}
/>
</Stack>
),
)}

<Divider sx={{ marginBlockStart: 2 }} />
<Stack
Expand Down
4 changes: 3 additions & 1 deletion libs/oeth/history/src/components/HistoryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import { ExportData } from './ExportData';
import { HistoryFilters } from './Filters';
import { HistoryTable } from './HistoryTable';

import type { HistoryType } from '@origin/oeth/shared';

const PAGE_SIZE = 20;

export function HistoryCard() {
const intl = useIntl();
const [page, setPage] = useState(0);
const [filters, setFilters] = useState<string[]>([]);
const [filters, setFilters] = useState<HistoryType[]>([]);
const { address, isConnected } = useAccount();

const { data, isFetching } = useHistoryTableWithFiltersQuery(
Expand Down
7 changes: 2 additions & 5 deletions libs/oeth/shared/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
"@nx/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage",
"importSource": "@emotion/react"
"useBuiltIns": "usage"
}
]
],
"plugins": [
"@emotion/babel-plugin"
]
"plugins": []
}
2 changes: 1 addition & 1 deletion libs/oeth/shared/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test oeth-shared` to execute the unit tests via [Jest](https://jestjs.io).
Run `nx test oeth-shared` to execute the unit tests via [Vitest](https://vitest.dev/).
12 changes: 12 additions & 0 deletions libs/oeth/shared/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@origin/oeth/shared",
"version": "0.0.1",
"main": "./index.js",
"types": "./index.d.ts",
"exports": {
".": {
"import": "./index.mjs",
"require": "./index.js"
}
}
}
26 changes: 18 additions & 8 deletions libs/oeth/shared/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
"projectType": "library",
"tags": [],
"targets": {
"codegen-graphql": {
"executor": "nx:run-commands",
"options": {
"commands": [
"pnpm graphql-codegen --config 'libs/oeth/shared/codegen.ts'"
]
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": [
Expand All @@ -23,6 +15,24 @@
"libs/oeth/shared/**/*.{ts,tsx,js,jsx}"
]
}
},
"build": {
"executor": "@nx/vite:build",
"outputs": [
"{options.outputPath}"
],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/libs/oeth/shared"
},
"configurations": {
"development": {
"mode": "development"
},
"production": {
"mode": "production"
}
}
}
}
}
5 changes: 3 additions & 2 deletions libs/oeth/shared/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": false,
"jsxImportSource": "@emotion/react"
"types": [
"vite/client"
]
},
"files": [],
"include": [],
Expand Down
25 changes: 21 additions & 4 deletions libs/oeth/shared/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,31 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"types": ["node"]
"types": [
"node",
"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",
"../../../apps/oeth/src/env.d.ts"
],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
"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/oeth/shared/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/oeth-shared',

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: 'oeth-shared',
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/providers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test shared-providers` to execute the unit tests via [Jest](https://jestjs.io).
Run `nx test shared-providers` to execute the unit tests via [Vitest](https://vitest.dev/).
12 changes: 12 additions & 0 deletions libs/shared/providers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@origin/shared/providers",
"version": "0.0.1",
"main": "./index.js",
"types": "./index.d.ts",
"exports": {
".": {
"import": "./index.mjs",
"require": "./index.js"
}
}
}
Loading

0 comments on commit fc2ad08

Please sign in to comment.