0.3.88 • Published 2 years ago

@polkadotcloud/core-ui v0.3.88

Weekly downloads
-
License
GPL-3.0-only
Repository
-
Last release
2 years ago

example workflow License npm version

Polkadot Core UI

CSS themes and core components for Polkadot dashboards, using React, TypeScript, Vite, SCSS. Built using Rollup, publishable to NPM.

Managing the Package

Start the development server for real-time component feedback.

yarn dev

Build the package into an optimised Rollup build.

Update your dist.package.json before building the package. dist.package.json is injected into the dist folder as package.json after a build completes.

yarn build

Publish the package to NPM.

cd dist && npm publish --access public

Using the Package

1. Import the CSS file in your app index.

import '@polkadotcloud/core-ui/index.css';

2. Wrap your app with Entry, providing the current theme mode and active network.

import { Entry } from '@polkadotcloud/core-ui';

export const WrappedApp: React.FC = () => {

  // light, dark
  const { mode } = useTheme();

  // polkadot, kusama, westend
  const { network } = useApi();

  return (
    <Entry mode={mode} network={network}>
      <App />
    </Entry>
  );
};

3. Import core components.

Any core component can now be imported and used within the app.

Package Testing in Local Development

Components can be viewed in the sandbox (accessed via yarn dev) while developing, with real time updates via HMR. But it can be challenging to test components like wrappers or large items, that should ideally be tested within an existing app.

So in addition to the sandbox, It is also possible to build the package and test it in other projects locally, before publishing the updated package to NPM. Doing this allows testing of newly updated components in a production app use-case before they are published .

The following walkthrough uses the Polkadot staking dashboard as The App and a local build of the UI library as The Package to test.

The Package Setup

1. Checkout the package-dev branch.

git checkout -b package-dev

This branch should be identical to main, with the exception of the dist.package.json package name property having -dev appended.

2. Build the package.

yarn build

3. Enter dist and link the package as a global namespace.

cd dist && yarn link

The package is now globally accessible to other projects in your development environment.

The App Setup

Polkadot staking dashboard already has a package-dev branch set up for local package development. To allow your own app to import and test local packages, follow these steps.

1. Create a package-dev branch (or any naming of your choosing) specifically for local package development.

git checkout -b package-dev

2. Link the previously linked package to your project.

yarn link @polkadotcloud/core-ui-dev

Ensure that your eslintrc config allows global imports by turning off the extraneous dependencies rule:

Rules: {
  "import/no-extraneous-dependencies": "off",
  …
}

3. Ensure global imports are supported.

Polkadot staking dashboard uses Vite.js as its toolchain. Vite by default does not allow package imports from outside the project directory without explicitly allowing them. To allow global imports, simply turn off strict mode in vite.config.js

server: {
    fs: {
      strict: false,
    }
  }

If you are using a toolchain with similar rules, ensure that they are amended to allow for global imports.

Importing Local CSS and Components

It is now possible to test components from the local package, and replace currently published components with the development version. Before testing updated local components, replace the published CSS file in your app's entry file with the local version. For Polkadot staking dashboard this is src/main.tsx:

// Replace published import:
import '@polkadotcloud/core-ui/index.css';

// with local import:
import '@polkadotcloud/core-ui-dev/index.css';

Now components can be added or replaced with those from your local version:

// Replace published import:
import { ButtonHelp } from '@polkadotcloud/core-ui';

// with local import:
import { ButtonHelp } from '@polkadotcloud/core-ui-dev';

Changes can be committed to this package-dev branch without impacting your main branch configs, linting rules and existing published component imports.

Unlinking

If you wish to rename or deprecate a local development package, it is a good practice to unlink (remove) it by running yarn unlink [package] in The App project directory:

yarn unlink @polkadotcloud/core-ui-dev

Followed by yarn unlink in The Package project directory.

0.3.74

2 years ago

0.3.73

2 years ago

0.3.72

2 years ago

0.3.71

2 years ago

0.3.70

2 years ago

0.3.79

2 years ago

0.3.78

2 years ago

0.3.77

2 years ago

0.3.76

2 years ago

0.3.64

2 years ago

0.3.63

2 years ago

0.3.62

2 years ago

0.3.61

2 years ago

0.3.60

2 years ago

0.3.69

2 years ago

0.3.68

2 years ago

0.3.67

2 years ago

0.3.66

2 years ago

0.3.65

2 years ago

0.3.53

2 years ago

0.3.52

2 years ago

0.3.51

2 years ago

0.3.50

2 years ago

0.3.59

2 years ago

0.3.58

2 years ago

0.3.57

2 years ago

0.3.56

2 years ago

0.3.55

2 years ago

0.3.54

2 years ago

0.3.42

2 years ago

0.3.49

2 years ago

0.3.48

2 years ago

0.3.47

2 years ago

0.3.45

2 years ago

0.3.44

2 years ago

0.3.43

2 years ago

0.3.86

2 years ago

0.3.85

2 years ago

0.3.84

2 years ago

0.3.83

2 years ago

0.3.82

2 years ago

0.3.81

2 years ago

0.3.80

2 years ago

0.3.88

2 years ago

0.3.87

2 years ago

0.3.41

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.2.81

2 years ago

0.2.80

2 years ago

0.2.74

2 years ago

0.2.73

2 years ago

0.3.40

2 years ago

0.2.72

2 years ago

0.2.71

2 years ago

0.2.70

2 years ago

0.2.79

2 years ago

0.2.78

2 years ago

0.2.77

2 years ago

0.2.76

2 years ago

0.2.75

2 years ago

0.3.31

2 years ago

0.2.63

2 years ago

0.3.30

2 years ago

0.2.62

2 years ago

0.2.61

2 years ago

0.2.60

2 years ago

0.3.39

2 years ago

0.3.38

2 years ago

0.3.37

2 years ago

0.2.69

2 years ago

0.3.36

2 years ago

0.2.68

2 years ago

0.3.35

2 years ago

0.2.67

2 years ago

0.3.34

2 years ago

0.2.66

2 years ago

0.3.33

2 years ago

0.2.65

2 years ago

0.3.32

2 years ago

0.2.64

2 years ago

0.3.29

2 years ago

0.3.20

2 years ago

0.2.52

2 years ago

0.2.51

2 years ago

0.2.50

2 years ago

0.3.28

2 years ago

0.3.27

2 years ago

0.2.59

2 years ago

0.3.26

2 years ago

0.2.58

2 years ago

0.3.25

2 years ago

0.2.57

2 years ago

0.3.24

2 years ago

0.2.56

2 years ago

0.3.23

2 years ago

0.2.55

2 years ago

0.3.22

2 years ago

0.2.54

2 years ago

0.3.21

2 years ago

0.2.53

2 years ago

0.3.19

2 years ago

0.3.18

2 years ago

0.2.41

2 years ago

0.2.40

2 years ago

0.3.9

2 years ago

0.3.17

2 years ago

0.2.49

2 years ago

0.3.16

2 years ago

0.2.48

2 years ago

0.3.15

2 years ago

0.2.47

2 years ago

0.3.14

2 years ago

0.2.46

2 years ago

0.3.13

2 years ago

0.2.45

2 years ago

0.3.12

2 years ago

0.2.44

2 years ago

0.3.11

2 years ago

0.2.43

2 years ago

0.3.10

2 years ago

0.2.42

2 years ago

0.2.39

2 years ago

0.2.30

2 years ago

0.2.38

2 years ago

0.2.37

2 years ago

0.2.34

2 years ago

0.2.33

2 years ago

0.2.32

2 years ago

0.2.31

2 years ago

0.2.29

2 years ago

0.2.28

2 years ago

0.2.27

2 years ago

0.2.16

2 years ago

0.2.26

2 years ago

0.2.15

2 years ago

0.2.25

2 years ago

0.2.14

2 years ago

0.2.24

2 years ago

0.2.13

2 years ago

0.2.23

2 years ago

0.2.12

2 years ago

0.2.22

2 years ago

0.2.11

2 years ago

0.2.21

2 years ago

0.2.10

2 years ago

0.2.20

2 years ago

0.2.19

2 years ago

0.2.18

2 years ago

0.2.17

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago