2.31.2 • Published 9 months ago

@rhoas/app-services-ui-components v2.31.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@rhoas/app-services-ui-components

@rhoas/app-services-ui-components contains a number of components for the Managed Application Services UI.

npm version codecov

The project is documented using Storybook, published on GitHub Pages.

Usage

import { Something } from '@rhoas/app-services-ui-components';

<Something />

Install

With npm installed, add the package to your peer and development dependencies.

$ npm install --save-dev --save-peer --save-exact @rhoas/app-services-ui-components

It's not recommended installing the package as a direct dependency to avoid having it bundled in your project's bundle.

Finally, make sure to list the dependency as a shared singleton in your federated module section on the Webpack's config file.
Be sure to enable the singleton option in order to have the internationalization layer work correctly.

// webpack.js

const { dependencies, peerDependencies } = require('./package.json');

module.exports = () => {
  return {
    // ...
    plugins: [
      // other plugins
      new webpack.container.ModuleFederationPlugin({
        name: 'my-module',
        filename: 'my-module.js',
        exposes: {
          './MyModule': './src/MyModule',
        },
        shared: {
          ...dependencies,
          ...peerDependencies,
          react: {
            eager: true,
            singleton: true,
            requiredVersion: peerDependencies['react'],
          },
          'react-dom': {
            eager: true,
            singleton: true,
            requiredVersion: peerDependencies['react-dom'],
          },
          'react-router-dom': {
            singleton: true,
            requiredVersion: peerDependencies['react-router-dom'],
          },
          '@rhoas/app-services-ui-components': {
            singleton: true,
            requiredVersion: peerDependencies['@rhoas/app-services-ui-components'],
          },
          '@rhoas/app-services-ui-shared': {
            singleton: true,
            requiredVersion: peerDependencies['@rhoas/app-services-ui-shared'],
          },
          '@patternfly/quickstarts': {
            singleton: true,
            requiredVersion: '*',
          },
        },
      })
    ]
  };
}

i18n

This project implements i18n using react-i18next.

You can translate strings by using one of the methods provided by react-18next, like the useTranslation hook.

To make life easier when developing a new Managed Application Services UI or when writing unit tests that also cover translations, the whole react-i18next library is re-exported by @rhoas/app-services-ui-components.

You can translate your content without directly including react-i18next as a direct dependency of your project by doing:

import { useTranslation } from '@rhoas/app-services-ui-components';

const MyComponent = () => {
    const { t } = useTranslation();
    return <span>{t('common:status')}</span>
}

Refer to the react-i18next documentation for more information.

Optional: set up the shared context providers

This step is required only if you want to run your application without the app-services-ui dev server. Never place the following code in components you make available as a federated module!

// App.tsx

import { VoidFunctionComponent } from "react";
import { I18nProvider, ModalProvider } from "@rhoas/app-services-ui-components";

const App: VoidFunctionComponent = () => (
  <I18nProvider
    lng={'en'}
    resources={{
      en: {
        common: () => import('@rhoas/app-services-ui-components/locales/en/common.json'),
        'create-kafka-instance': () => import('@rhoas/app-services-ui-components/locales/en/create-kafka-instance.json'),
        kafka: () => import('@rhoas/app-services-ui-components/locales/en/kafka.json'),
        metrics: () => import('@rhoas/app-services-ui-components/locales/en/metrics.json'),
        overview: () => import('@rhoas/app-services-ui-components/locales/en/overview.json'),
        datascienceoverview: () => import('@rhoas/app-services-ui-components/locales/en/datascienceoverview.json'),
        kafkaoverview: () => import('@rhoas/app-services-ui-components/locales/en/kafkaoverview.json'),
        topic: () => import("../locales/en/topic.json"),
        apimgmtoverview: () => import('@rhoas/app-services-ui-components/locales/en/apimgmtoverview.json'),
        "manage-kafka-permissions": () => import("@rhoas/app-services-ui-components/locales/en/manage-kafka-permissions.json"),},
    }}
    debug={true}
  >
    <ModalProvider>
      my app goes here
    </ModalProvider>
  </I18nProvider>
);

See Also

License

Apache

2.31.1

10 months ago

2.31.2

9 months ago

2.31.0

1 year ago

2.30.0

1 year ago

2.20.8

1 year ago

2.20.9

1 year ago

2.20.6

1 year ago

2.20.7

1 year ago

2.20.2

1 year ago

2.20.3

1 year ago

2.20.1

1 year ago

2.20.4

1 year ago

2.20.5

1 year ago

2.19.0

1 year ago

2.18.5

1 year ago

2.18.3

1 year ago

2.18.4

1 year ago

2.18.1

1 year ago

2.18.2

1 year ago

2.18.0

1 year ago

2.17.0

1 year ago

2.17.1

1 year ago

2.20.0

1 year ago

2.16.0

1 year ago

2.15.0

1 year ago

2.14.3

1 year ago

2.14.4

1 year ago

2.14.1

1 year ago

2.14.2

1 year ago

2.14.0

2 years ago

2.13.2

2 years ago

2.13.0

2 years ago

2.13.1

2 years ago

2.12.0

2 years ago

2.11.1

2 years ago

2.9.9

2 years ago

2.9.2

2 years ago

2.9.4

2 years ago

2.9.3

2 years ago

2.9.6

2 years ago

2.9.5

2 years ago

2.11.2

2 years ago

2.9.8

2 years ago

2.9.7

2 years ago

2.10.2

2 years ago

2.10.0

2 years ago

2.0.2

2 years ago

2.4.1

2 years ago

2.4.0

2 years ago

2.8.1

2 years ago

2.0.1

2 years ago

1.40.4

2 years ago

2.0.0

2 years ago

1.40.6

2 years ago

1.40.5

2 years ago

2.9.1

2 years ago

2.3.0

2 years ago

2.7.0

2 years ago

2.2.0

2 years ago

2.6.1

2 years ago

2.6.0

2 years ago

2.5.0

2 years ago

2.5.2

2 years ago

2.5.1

2 years ago

2.9.0

2 years ago

2.1.0

2 years ago

1.37.0

2 years ago

1.40.0

2 years ago

1.40.2

2 years ago

1.40.1

2 years ago

1.40.3

2 years ago

1.34.2

2 years ago

1.34.0

2 years ago

1.34.1

2 years ago

1.38.2

2 years ago

1.38.3

2 years ago

1.38.0

2 years ago

1.38.1

2 years ago

1.38.6

2 years ago

1.38.7

2 years ago

1.38.4

2 years ago

1.38.5

2 years ago

1.38.8

2 years ago

1.38.9

2 years ago

1.35.0

2 years ago

1.39.1

2 years ago

1.39.2

2 years ago

1.39.0

2 years ago

1.39.5

2 years ago

1.39.3

2 years ago

1.39.4

2 years ago

1.36.0

2 years ago

1.36.1

2 years ago

1.36.2

2 years ago

1.29.0

2 years ago

1.27.2

2 years ago

1.32.0

2 years ago

1.30.2

2 years ago

1.30.0

2 years ago

1.30.1

2 years ago

1.28.1

2 years ago

1.28.2

2 years ago

1.28.0

2 years ago

1.28.3

2 years ago

1.31.1

2 years ago

1.33.0

2 years ago

1.31.2

2 years ago

1.31.0

2 years ago

1.25.0

2 years ago

1.23.2

2 years ago

1.25.1

2 years ago

1.23.1

2 years ago

1.27.0

2 years ago

1.25.2

2 years ago

1.24.1

2 years ago

1.26.0

2 years ago

1.24.0

2 years ago

1.14.1

2 years ago

1.14.0

2 years ago

1.12.0

2 years ago

1.18.0

2 years ago

1.16.1

2 years ago

1.16.0

2 years ago

1.14.2

2 years ago

1.11.10

2 years ago

1.11.11

2 years ago

1.21.0

2 years ago

1.23.0

2 years ago

1.15.0

2 years ago

1.11.4

2 years ago

1.13.0

2 years ago

1.19.0

2 years ago

1.11.8

2 years ago

1.11.7

2 years ago

1.17.0

2 years ago

1.11.6

2 years ago

1.11.5

2 years ago

1.11.9

2 years ago

1.22.0

2 years ago

1.20.0

2 years ago

1.22.1

2 years ago

1.22.2

2 years ago

1.2.0

2 years ago

1.11.3

2 years ago

1.11.2

2 years ago

1.11.1

2 years ago

1.9.1

2 years ago

1.8.2

2 years ago

1.9.0

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.1

2 years ago

1.2.2

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.1.2

2 years ago

1.8.7

2 years ago

1.8.6

2 years ago

1.8.5

2 years ago

1.9.3

2 years ago

1.8.4

2 years ago

1.9.2

2 years ago

1.8.3

2 years ago

1.11.0

2 years ago

1.10.0

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago