@salutejs/tokens-caldera-online
TypeScript icon, indicating that this package has built-in type declarations

0.6.0-canary.1074.8079625573.0 • Public • Published

Tokens Caldera Online

Пакет предоставляет набор дизайн-токенов реализующих дизайн вертикали «Caldera Online».

Конфигурация пакета

Тема Библиотека Шрифты
caldera @salutejs/caldera SB Sans Display, SB Sans Text
caldera_online @salutejs/caldera-online SB Sans Display, SB Sans Text

Установка и подключение

Установка зависимости:

npm i --save @salutejs/tokens-caldera-online

Типографическая система основана на фирменных шрифтах. Для того чтобы шрифт было удобно поставлять в web-приложения, шрифт был загружен на CDN.

Для использования типографической системы необходимо загрузить два css файла в зависимости от используемых шрифтов в теме. Их необходимо добавить внутрь тега head. Если в качестве основы web-приложения вы используете create-react-app, вам необходимо изменить файл ./public/index.html.

<html>
    <head>
        <link rel="stylesheet" href="https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansText.0.2.0.css" />
        <link
            rel="stylesheet"
            href="https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansDisplay.0.2.0.css"
        />
    </head>
    <body>
        ...
    </body>
</html>

Подключение с помощью styled-component:

import React from 'react';
import styled, { createGlobalStyle } from 'styled-components';

import { Button, BodyL } from '@salutejs/caldera';
import { caldera_online__light } from '@salutejs/tokens-caldera-online';

const Theme = createGlobalStyle(caldera_online__light);

const App = () => {
    return (
        <>
            <Theme />
            <BodyL>Hello world</BodyL>
            <Button text="This is themed button" />
        </>
    );
};

export default App;

Подключение с помощью импорта css файла:

import React from 'react';
import styled, { createGlobalStyle } from 'styled-components';

import '@salutejs/tokens-caldera-online/css/caldera_online__dark.css';

const App = () => {
    return (
        <>
            <BodyL>Hello world</BodyL>
            <Button text="This is themed button" />
        </>
    );
};

export default App;

Подключение с помощью импорта модульного css файла:

Возможно потребуется @ts-ignore

import React from 'react';
import styled, { createGlobalStyle } from 'styled-components';

import styles from '@salutejs/tokens-caldera-online/css/caldera_online.module.css';

const App = () => {
    return (
        <div className={styles.dark}>
            <BodyL>Hello world</BodyL>
            <Button text="This is themed button" />
        </div>
    );
};

export default App;

Использование токенов

Все css токены завернуты в js переменные для более удобного доступа:

/** Основной цвет текста */
export const textPrimary = 'var(--text-primary, #F5F5F5)';
/** Основной фон */
export const backgroundPrimary = 'var(--background-primary, #000000)';

Так же в пакете есть типографические токены, для случаев, когда необходимо точечно применить типографику к контейнеру.

/** Токены типографики для компонента DsplL */
export const dsplL = ({
    fontFamily: 'var(--plasma-typo-dspl-l-font-family)',
    fontSize: 'var(--plasma-typo-dspl-l-font-size)',
    fontStyle: 'var(--plasma-typo-dspl-l-font-style)',
    fontWeight: 'var(--plasma-typo-dspl-l-font-weight)',
    letterSpacing: 'var(--plasma-typo-dspl-l-letter-spacing)',
    lineHeight: 'var(--plasma-typo-dspl-l-line-height)',
} as unknown) as CSSObject;

Пример использования:

import React from 'react';
import styled, { createGlobalStyle } from 'styled-components';

import { textAccent, backgroundPrimary, bodyL } from '@salutejs/tokens-caldera-online/vars';

const AppStyled = styled.div`
    padding: 30px;
    color: ${textAccent};
    background-color: ${backgroundPrimary};
`;

const Container = styled.div`
    ${bodyL};
    margin: 15px;
`;
const App = () => {
    const Theme = themes[theme];

    return (
        <AppStyled>
            <Container>
                <h2>Hello world</h2>
            </Container>
        </AppStyled>
    );
};

export default App;

Readme

Keywords

none

Package Sidebar

Install

npm i @salutejs/tokens-caldera-online

Weekly Downloads

0

Version

0.6.0-canary.1074.8079625573.0

License

MIT

Unpacked Size

693 kB

Total Files

54

Last publish

Collaborators

  • salute-eva
  • awinogradov
  • turanchoks
  • salute-assistant