Files
nym/ts-packages/react-webpack-with-theme-example
tommy 7f2027ca6b Delegation UI:
Update QA vars

fmt

re-map coin type for qa

add correct bech32 address as the network-explorer-api was complaining

clean up

fmt

Delegation components

Show delegation story on paper

Remove actions header from delegations list

Add copy to clipboard for delegation list node ids

Move tooltip

Modals

Extract modal styles

Fix exports

Rewards summary and redeem modal

Factor out simple modal

Delegations actions modals: delegate, delegate more, undelegate

Coin mark and move logo stories

Rust types

React components handle currency

Form field to enter and display an Identity Key

Fix up build order

Update README

Flat buttons

End adornment

Currency form field

Add more props

Export components

Add currency and mixnode fields

Group stories into folders and add flow

Change exports from shared packages to stop webpack bundling issues

Fix logo import

Add mock for tauri api in storybook that shows a console error for operations that are not mocked

Delegations views and routes for wallet

Delegations list show pending delegations and undelegations

wip - delegations page status

Add typescript type checking to storybook webpack config and more mocks for tauri

Add more interstitial states and confirmation modals

Copy change

Move config to inside source tree

Fix up `Console` typings

Add wrapper around Tauri `invoke` that logs operations in development mode

wip

wip

wip

ts-rs: remove old files

ts-rs: update paths to `ts-packages/types`

ts-rs: remove old files

ts-rs: export new types to `ts-packages/types`

Add `MajorCurrencyAmount` to convert to and from TS types for various backend currency types

New crate `nym-types` to provide types for frontend apps (wallet, explorer, etc)

wip

update type imports and fix some lint errors

update packages

update type imports

update type imports

update type imports

update type imports

start pulling out use of  minorMajor and majorMinor

update type imports

update import

Add missing types generated by ts-rs

fix types

Adding denom to account

type updates

Handle micro currency denoms

Fix type conversion mistake

Add clean target

eslint: formatting

Update React currency components to use `MajorCurrencyAmount`

Add separators and extra props to currency components

replace currency mapper with denom returning from service

Adjust type while generation is broken

start integrating new CurrencyFormField component

update balance and vesting on client change (not only client address)

Fix up conversion from cosmwasm coin to major currency for minor denoms

Fix up typings and validations to remove more `Coin` usage

fix conflict

fix delegations form

start fixing validation

type update

remove console log

tidy up

remove more unused types

remove more unused types

Fix `Coin` denom to be `minor`

Fix up to minor_cosmos_coin

Fix up send

Remove `Coin` type

Fix up exported types

start delegation UI

more UI work

close actions modal on action select

update label

fix old delegateion form

minor updates

undo change to currency in stringD

Fix up types

Add feature flag for generating typescript
Generate types behind feature flag

Use custom cli tool to export `ts-rs` types

`ts-rs-cli` moves files into place and fix up `Makefile`

Update generations target

Add missing types for generation

Generate typescript types

reorder imports

use make generate-typescript for new types + type import updates

update types

Add delegate with everything

Add get block to nymd client

More conversions

Get a big list of delegations with lots of stuff

Add `avg_uptime_percent`

component api updates

ui updates and fixes

Add delegation history and pending events

Fix up addition

Fix up pending delegation event types

Filter pending delegation events

add history and pending events

set total delegations

rebase

fix breaking type change on delegate page

Fix mixnode mapping

Add back refresh and set periodic refresh

upgrade to react router 6

Add logging
Export new types for gas and transactions

increase container size!

add sendtx type

update onOK to return MAjorCurrencyAmount

align table items

display dash if amount not availble

work on delegate and undelegate

Make serializable

More types

Fix up errors

align item icon

type updates

Add operation to get all pending delegation/undelegation events

Fix up logging

Add more logging

Fix undelegate error

get pending delegation events

remove unused import
2022-05-27 16:50:16 +01:00
..
2022-05-27 16:50:16 +01:00
2022-03-23 19:46:50 +00:00
2022-05-27 16:50:16 +01:00

Example with React + Typescript + Webpack 5 + MUI

An example of using default Webpack and Typescript settings with React and MUI, including theming.

You can use this example as a seed for a new project.

Remember to build the dependency packages from the root of this repo by running:

yarn
yarn build

If you need to make changes to the dependency packages, you can run yarn watch in that package to watch for chagnes and build them. This project will pick up the changes in the built package and hot-reload / recompile.

Features

Yarn workspaces

Packages from ts-packages are shared using Yarn workspaces. Make sure you add you new project to package.json to use the shared packages.

⚠️ Warning: Yarn workspaces will share all dependencies between projects and works by falling back to parent directories until a node_modules directory is found. So be careful when messing around with node_modules and resolution, because unexpected things could happen - for example, if you do not run yarn from the root and you have a node_modules in a directory that is a parent of the directory where you checkout out this repository, that node_modules will be used for resolving packages 🙀.

Typescript

Shared Typescript config is in tsconfig.json, with specific production settings in tsconfig.prod.json that:

  • exclude Storybook stories and Jest tests
  • do not output typing *.d.ts files

Webpack

Inherit config for Webpack 5 with additional tweaks including:

  • favicon generation from favicon asset files
  • asset handling (svg, png, fonts, css, etc)
  • minification

The development settings include:

  • ts-loader for quick transpilation
  • threaded type checking using tsc
  • hot reloading using react-refresh

Storybook

Storybook is available in @nymproject/react and can be run using yarn storybook.

MUI and theming

The Nym theme provides a theme provider that you can add as follows:

export const App: React.FC = () => (
  <AppContextProvider>
    <AppTheme>
      <Content />
    </AppTheme>
  </AppContextProvider>
);

export const AppTheme: React.FC = ({ children }) => {
  const { mode } = useAppContext();

  return <NymThemeProvider mode={mode}>{children}</NymThemeProvider>;
};

export const Content: React.FC = () => {
...
}

And augment typings for the Theme by adding mui-theme.d.ts:

import { Theme, ThemeOptions, Palette, PaletteOptions } from '@mui/material/styles';
import { NymTheme, NymPaletteWithExtensions, NymPaletteWithExtensionsOptions } from '@nymproject/mui-theme';

declare module '@mui/material/styles' {
  interface Theme extends NymTheme {}
  interface ThemeOptions extends Partial<NymTheme> {}
  interface Palette extends NymPaletteWithExtensions {}
  interface PaletteOptions extends NymPaletteWithExtensionsOptions {}
}

Adding the above, means that any component now has the correct typings, for example, below the Nym palette interface is available for all MUI Theme instances with code completion for VSCode and IntelliJ:

import { Typography } from '@mui/material';

...

<Typography sx={{ color: (theme) => theme.palette.nym.networkExplorer.mixnodes.status.active }}>
  The quick brown fox jumps over the white fence
</Typography>