@digital-ai/dot-components
TypeScript icon, indicating that this package has built-in type declarations

3.4.0 • Public • Published

@digital-ai/dot-components

npm version npm (prod) dependency version

Welcome! 👋

So you've decided to use dot-components in your application, that's fantastic. Be sure to come say "hi" in the #dot-components channel in Slack and let us know how you're using our library.

Installation

# with npm
npm install @digital-ai/dot-components

# with yarn
yarn add @digital-ai/dot-components

Theme Provider

The DotThemeProvider provides the theme for the components in this library. When using this library you will need to wrap your application with it like this:

<DotThemeProvider>
  <App />
</DotThemeProvider>

Once your application is wrapped with DotThemeProvider, your styled components can use colors and spacings from the theme:

import styled, { css } from 'styled-components';

const StyledWidget = styled.div`
  ${({ theme }) => css`
    background-color: ${theme.palette.secondary[300]};
    border: 1px solid ${theme.palette.primary.main};
    .my-widget-text {
      margin-left: ${theme.spacing(2)};
    }
  `}
`;

export interface MyWidgetProps {
  text: string;
}

export const MyWidget = ({ text }: MyWidgetProps) => {
  return (
    <StyledWidget>
      <div className="my-widget-text">{text}</div>
    </StyledWidget>
  );
};

Note: If you would like to create a custom theme, you can do so by following these directions.

Configuring Jest

We are utilizing @digital-ai/dot-icons which uses @font-face. If you are using Jest then you'll need to update the following files. The location of the files may be different based on the structure of your application

jest.config.js

moduleNameMapper: {
  '@digital-ai/dot-icons': '<rootDir>/testing-utils/style-mock.ts',
  '@digital-ai/dot-illustrations': '<rootDir>/testing-utils/style-mock.ts',
}

style-mock.ts

module.exports = {};

Targeting CSS ClassNames

There are three different types of CSS class names that are used: dot- classes, Mui classes, and styled-components classes. You are encouraged to use the dot- classes in your application styles, but you can also use the Mui classes if you prefer. It is important to note that the Mui classes are subject to change and are not guaranteed to be stable across releases.

Note: The styled-components classes are generated by the library and should NOT be used, they will look like random letters, ex: kMprfx

Resolving Style Conflicts

It is possible that existing application styles might target native elements in ways that will conflict with styles from dot-components.

Because dot- classes are applied to native elements that are part of dot-components, such conflicts can be resolved by making minor changes to the application styles.

For example, suppose the application includes global styling like this:

input {
  background-color: red;
}

To override this styling for dot-components, this could be changed to:

input:not(.dot-input) {
  background-color: red;
}

Updating

When you're ready to pull in the latest version of the dot-components package run the following command.

# with npm
npm update @digital-ai/dot-components@latest

# with yarn
yarn upgrade @digital-ai/dot-components@latest

Font Icons

Find which icon you would like to use by going to .dot design system

Follow the code example shown here

Note: You can use search in the upper right corner to search for an icon if you know its name.

If you're using the DotIcon component then you do not need to pass in the icon- prefix of the icon name.

Contributing

Learn about how to contribute

Code Style Guide

Learn about our code style guide

Change Log

Learn about the latest improvements.

Security Policy

Learn about our security policy

Readme

Keywords

none

Package Sidebar

Install

npm i @digital-ai/dot-components

Weekly Downloads

521

Version

3.4.0

License

SEE LICENSE IN <LICENSE.md>

Unpacked Size

896 kB

Total Files

282

Last publish

Collaborators

  • rgamble
  • jcaldas
  • gvolarevic-dai
  • msnively
  • agavaldas
  • cwsites