Git Product home page Git Product logo

ui-kit's Introduction

๐ŸŽน 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

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 { customProperties } from '@commercetools-uikit/design-system';

const primary = customProperties.colorPrimary;

Please look at the custom-properties.js itself to inspect which variables are available.

ui-kit's People

Contributors

adnasa avatar ahmehri avatar damarna85 avatar dependabot[bot] avatar dferber90 avatar dogayuksel avatar emmenko avatar fuchodeveloper avatar github-actions[bot] avatar gnerkus avatar islam3zzat avatar jonnybel avatar lufego avatar luhmann avatar mariabarrena avatar mohib0306 avatar montezume avatar nickpapasavvas avatar noobtw avatar pa3 avatar qmateub avatar renovate-bot avatar renovate[bot] avatar rombelirk avatar tdeekens avatar torihedden avatar transifex-integration[bot] avatar vidurar avatar yahiaeltai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.