npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@salutejs/sdds-themes

v0.27.0

Published

Sdds-themes package

Downloads

12,184

Readme

SDDS Themes

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

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

| Тема | Библиотека | Шрифты | | ---------------- | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | sdds_serv | @salutejs/sdds-serv | SB Sans Display, SB Sans Text | | sdds_dfa | @salutejs/sdds-dfa | SB Sans Display, SB Sans Text | | sdds_cs | @salutejs/sdds-cs | SB Sans Display, SB Sans Text | | sdds_finportal | @salutejs/sdds-finportal | SB Sans Display, SB Sans Text | | sdds_insol | @salutejs/sdds-insol | SB Sans Display, SB Sans Text |

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

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

npm i --save @salutejs/sdds-themes

Типографическая система основана на фирменных шрифтах. Для того чтобы шрифт было удобно поставлять в 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 { createGlobalStyle } from 'styled-components';

import { Button, BodyL } from '@salutejs/sdds-serv';
import { sdds_serv__light } from '@salutejs/sdds-themes';

const Theme = createGlobalStyle(sdds_serv__light);

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

export default App;

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

import React from 'react';

import { Button, BodyL } from '@salutejs/sdds-serv';

import '@salutejs/sdds-themes/css/sdds_serv__dark.css';

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

export default App;

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

Потребуется дополнительно настроить TypeScript

import React from 'react';

import { Button, BodyL } from '@salutejs/sdds-serv';

import styles from '@salutejs/sdds-themes/css/sdds_serv.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;

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

import React from 'react';
import styled from 'styled-components';

import { textAccent, backgroundPrimary, textL } from '@salutejs/sdds-themes/tokens';

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

const Container = styled.div`
    ${textL};
    margin: 15px;
`;

const App = () => {
    return (
        <AppStyled>
            <Container>
                <span>Hello world</span>
            </Container>
        </AppStyled>
    );
};

export default App;

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

import React from 'react';
import styled from 'linaria';

import { textAccent, backgroundPrimary, textL } from '@salutejs/sdds-themes/tokens';

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

const Container = styled.div`
    ${textL};
    margin: 15px;
`;

const App = () => {
    return (
        <AppStyled>
            <Container>
                <span>Hello world</span>
            </Container>
        </AppStyled>
    );
};

export default App;

Смена тем

Пример на styled-components:

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

import { Switch } from '@salutejs/sdds-serv';
import { sdds_serv__light, sdds_serv__dark } from '@salutejs/sdds-themes';

import './style.css';

const LightTheme = createGlobalStyle(sdds_serv__light);
const DarkTheme = createGlobalStyle(sdds_serv__dark);

const App = () => {
    const [theme, setTheme] = useState('light');

    return (
        <>
            {theme === 'light' ? <LightTheme /> : <DarkTheme />}

            <div className="wrapper">
                <Switch
                    label="dark theme: "
                    onChange={() => {
                        setTheme((theme) => (theme === 'light' ? 'dark' : 'light'));
                    }}
                />
            </div>
        </>
    );
};

export default App;

Пример на emotion:

import React, { useState } from 'react';

import { Global, css } from '@emotion/react';
import { Switch } from '@salutejs/sdds-serv';
import { sdds_serv__light, sdds_serv__dark } from '@salutejs/sdds-themes';

import './style.css';

const lightThemeStyle = css(sdds_serv__light);
const darkThemeStyle = css(sdds_serv__dark);

const App = () => {
    const [theme, setTheme] = useState('light');

    return (
        <>
            <Global styles={theme === 'light' ? lightThemeStyle : darkThemeStyle} />

            <div className="wrapper">
                <Switch
                    label="dark theme: "
                    onChange={() => setTheme((theme) => (theme === 'light' ? 'dark' : 'light'))}
                />
            </div>
        </>
    );
};

export default App;

Пример на css-modules:

import React, { useLayoutEffect, useState } from 'react';

import { Switch } from '@salutejs/sdds-serv';
import webThemes from '@salutejs/sdds-themes/css/sdds_serv.module.css';

import './style.css';

const App = () => {
    const [theme, setTheme] = useState('light');

    useLayoutEffect(() => {
        document.documentElement.className = webThemes[theme];
    }, [theme]);

    return (
        <div className="wrapper">
            <Switch
                label="dark theme: "
                onChange={() => {
                    setTheme((theme) => (theme === 'light' ? 'dark' : 'light'));
                }}
            />
        </div>
    );
};

export default App;

Пример на css:

import React, { useLayoutEffect, useState } from 'react';

import { Switch } from '@salutejs/sdds-serv';

// добавьте импорт в css файл
// @import '@salutejs/sdds-themes/css/sdds_serv.module.css';
import './style.css';

const App = () => {
    const [theme, setTheme] = useState('light');

    useLayoutEffect(() => {
        document.documentElement.className = theme;
    }, [theme]);

    return (
        <div className="wrapper">
            <Switch
                label="dark theme: "
                onChange={() => {
                    setTheme((theme) => (theme === 'light' ? 'dark' : 'light'));
                }}
            />
        </div>
    );
};

export default App;