A controlled input component for localized money values with validation states.


Keywords
javascript, typescript, design-system, react, uikit, audit-frontend, commercetools-scp, frontend, ui-kit
License
MIT
Install
npm install @commercetools-uikit/localized-money-input@11.0.0-alpha.3

Documentation

🎹 commercetools UI Kit 💅

Logo

Latest release (latest dist-tag) Latest release (next dist-tag) CI status This project is using Percy.io for visual regression testing Minified + GZipped size GitHub license

✨ Component library based on our design system 🛠

If you are building Custom Applications for the Merchant Center, be sure to check out our documentation

Interactive documentation of UI Kit components can be found in our Storybook

Getting started

The UI Kit is a set of React components that follows commercetools Design System.

Using individual packages

Each UI Kit component is published as a single NPM package under the scope @commercetools-uikit. This is useful if you only need a bunch of React components and do not want to have bigger bundle.

For example:

import PrimaryButton from '@commercetools-uikit/primary-button';
import SpacingsStack from '@commercetools-uikit/spacings-stack';
import { AngleDownIcon } from '@commercetools-uikit/icons';

Using presets

If you plan to use more components, you can also use some of the preset packages that group multiple packages together. This is useful to reduce the number of dependencies and imports.

For example:

import { PrimaryButton } from '@commercetools-uikit/buttons';
import Spacings from '@commercetools-uikit/spacings';

All-in-one

There is also a preset package that re-exports ALL UI Kit components: @commercetools-frontend/ui-kit.

This package is also used for backwards compatibility after we started splitting up the components into single packages.

import {
  PrimaryButton,
  Spacings,
  AngleDownIcon,
} from '@commercetools-frontend/ui-kit';

Required peer dependencies

Each UI Kit package comes with some required peer dependencies to be installed by the consumer.

Depending on which UI Kit packages you use, make sure to have the related peer dependencies installed.

Most of the time the required peer dependencies include react, react-dom, react-intl.

Design System

A design system is a collection of reusable components, guided by clear standards, that can be assembled together to build any number of applications.

Design Systems are becoming more and more useful nowadays, as design and technology strive to find a perfect balance between them.

The UI Kit project is the home of commercetools Design System and its implementation in the form of React components.

The package @commercetools-uikit/design-system exposes the design variables and tokens used to define design rules and constraints for commercetools products.

Importing css variables in css files

You will need a postcss-import plugin, and a postcss variable plugin: either postcss-custom-properties or postcss-css-variables would work.

@import '@commercetools-uikit/design-system/materials/custom-properties.css';

.container {
  padding: var(--spacing-l);
}
// wherever you process your CSS
postcss([postcssImportPlugin(), postcssCustomProperties()]);

Using postcss-custom-properties and importFrom

The css variables can also be injected using postcss-custom-properties, removing the need to import them directly inside your css files.

/* no import required! */
.container {
  padding: var(--spacing-l);
}
// wherever you process your CSS
postcss([
  postcssCustomProperties({
    preserve: false,
    importFrom: require.resolve(
      '@commercetools-uikit/design-system/materials/custom-properties.css'
    ),
  }),
]);

Accessing JavaScript variables and design tokens

You can also access the JavaScript variables like this

import { designTokens } from '@commercetools-uikit/design-system';

const primary = designTokens.colorPrimary;

Please look at the design-tokens.ts itself to inspect which variables are available.