@virtuslab/tetrisly-react
TypeScript icon, indicating that this package has built-in type declarations

1.8.0 • Public • Published

css-in-readme

Tetrisly for React

🧩 Tetrisly offers user-friendly components designed for effortless integration. Plus, it's fully compatible with Tetrisly for Figma with a seamless design and development experience in mind.

If you want to know more about Tetrisly, check out our website: tetrisly.com

Tech Stack

We've decided to use xstyled for styling our components. If you are interested in our reasoning, check out our article on this topic: Style Wars: Tailwind vs. CSS-in-JS in Design Systems Implementation

Installation

Install tetrisly-react with npm (you can do the same with yarn, pnpm or any other package manager)

  npm install @virtuslab/tetrisly-react

and dependencies:

  npm install styled-components @xstyled/styled-components

Setup

TetrislyProvider

After installing the package, you need to wrap your application in the TetrislyProvider component. This will provide the theme and other context to your application.

import { TetrislyProvider } from '@virtuslab/tetrisly-react';

function App() {
  return (
    <TetrislyProvider>
      <YourApp />
    </TetrislyProvider>
  );
}

TetrislyProvider accepts optional prop theme which can be used to override default theme.

import { TetrislyProvider } from '@virtuslab/tetrisly-react';

function App() {
  return (
    <TetrislyProvider
      theme={{
        colors: {
          '$color-semantic-brand--4': th.color('$color-raspberry--4'),
          '$color-semantic-brand--3': th.color('$color-raspberry--3'),
          '$color-semantic-brand--2': th.color('$color-raspberry--2'),
          '$color-semantic-brand--1': th.color('$color-raspberry--1'),
          '$color-semantic-brand-0': th.color('$color-raspberry-0'),
          '$color-semantic-brand-+1': th.color('$color-raspberry-+1'),
          '$color-semantic-brand-+2': th.color('$color-raspberry-+2'),
          '$color-semantic-brand-+3': th.color('$color-raspberry-+3'),
          '$color-semantic-brand-+4': th.color('$color-raspberry-+4'),
          '$color-semantic-brand-+5': th.color('$color-raspberry-+5'),
          '$color-semantic-brand-+6': th.color('$color-raspberry-+6'),
          '$color-semantic-brand-+7': th.color('$color-raspberry-+7'),
          '$color-semantic-brand-+8': th.color('$color-raspberry-+8'),
        },
      }}
    >
      <YourApp />
    </TetrislyProvider>
  );
}

Default theme

Our default theme contains all of fundamental Tetrisly Design Tokens, you can use it with xstyled props to easy set up your design. See tet.* utility example of use.

Here you can see the default theme or a complete list of theme options.

Default font

Tetrisly uses Inter font as default. To add it to your app you should link it in your root .html file:

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;450;600&display=swap"
  rel="stylesheet"
/>

tet.* utility

tet function is our extension of xstyled x.* utility. Both has the same API, but we will add some extra features in near future. You can read more here.

Example of use

import {
  TetrislyProvider,
  Button,
  theme,
  tet,
} from '@virtuslab/tetrisly-react';

const App = () => (
  <TetrislyProvider>
    <tet.div
      display="flex"
      justifyContent="center"
      alignItems="center"
      h="100vh"
    >
      <tet.div>
        <tet.h1
          textAlign="center"
          mb="$dimension-200"
          text="$typo-header-4xLarge"
          color="$color-content-primary"
        >
          Hello world!
        </tet.h1>
        <tet.div display="flex" justifyContent="center" alignItems="center">
          <a
            href="https://storybook.tetrisly.com"
            target="_blank"
            rel="noreferrer"
          >
            <Button label="Go to Storybook" appearance="primary" />
          </a>
        </tet.div>
      </tet.div>
    </tet.div>
  </TetrislyProvider>
);

export default App;

Run Locally

Clone the project

  git clone https://github.com/VirtusLab/tetrisly-react

Go to the project directory

  cd tetrisly-react

Install dependencies

  yarn install

Start the storybook server

  yarn storybook

Running Tests

To run tests, run the following command

  yarn test

Documentation

If you want to dive deeper into the components Tetrisly offers, check out our official documentation: Tetrisly Docs

You can also check out our Storybook, which is our Documentation for React components (now in progress): Tetrisly Storybook

Customization

All Tetrisly components have a custom prop. It makes it possible to customize the component without the need to create a new one. Below you can see an example of Button customization

Button

If you want to change any of button styles, you can make it by passing custom props with object based on specific component config.

For instance, to change background-color of appearance="primary" intent="secondary" variant to pink, just pass referenced object structure:

<Button
  label="Button label"
  appearance="primary"
  intent="success"
  custom={{
    default: {
      appearance: {
        primary: {
          intent: {
            success: {
              backgroundColor: 'raspberry-0', // you can also pass any color value not included in default theme
            },
          },
        },
      },
    },
  }}
/>

we are still working on it, thanks for your feedback here!

Useful links

Getting Help

If at any point you need help, feel lost, or have some feedback for us, you can create issues on our GitHub repository, or reach out to us on out Discord Server: Tetrisly Discord

Testimonials

If you want to share with us your thoughts on Tetrisly, or showcase what you have built with it (it could be any aspect of our product, not only the React library), you can do it here: Tetrisly Testimonials Form

License

We are using the Apache License 2.0 for our library of components

VirtusLab

Meet VirtusLab, the visionary team behind Tetrisly for React and the Tetrisly design system. Trusted by clients, they excel in product design, design systems and front-end engineering, creating mission-critical solutions across the product lifecycle.

Package Sidebar

Install

npm i @virtuslab/tetrisly-react

Homepage

tetrisly.com

Weekly Downloads

93

Version

1.8.0

License

Apache-2.0

Unpacked Size

2.89 MB

Total Files

430

Last publish

Collaborators

  • cyp3r
  • adrian-potepa
  • jkoziel
  • kusmierz
  • mstrag
  • mixvar