Skip to content

Commit

Permalink
Merge branch 'main' into timofeyevvv/readme_corrections_from_loc_team
Browse files Browse the repository at this point in the history
  • Loading branch information
vvtimofeev committed Dec 19, 2024
2 parents 963119a + 26d1609 commit 99dd39f
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 20 deletions.
107 changes: 107 additions & 0 deletions README-ru.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# UIKit · [![npm package](https://img.shields.io/npm/v/@gravity-ui/uikit)](https://www.npmjs.com/package/@gravity-ui/uikit) [![CI](https://img.shields.io/github/actions/workflow/status/gravity-ui/uikit/.github/workflows/ci.yml?branch=main&label=CI&logo=github)](https://github.com/gravity-ui/uikit/actions/workflows/ci.yml?query=branch:main) [![storybook](https://img.shields.io/badge/Storybook-deployed-ff4685)](https://preview.gravity-ui.com/uikit/)

Набор гибких, универсальных и высокоэффективных React-компонентов для создания сложных веб-приложений.

<!--GITHUB_BLOCK-->

![Cover image](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/uikit_cover.png)

## Ресурсы

### ![Globe Logo Light](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/globe_light.svg#gh-light-mode-only) ![Globe Logo Dark](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/globe_dark.svg#gh-dark-mode-only) [Веб-сайт](https://gravity-ui.com)

### ![Documentation Logo Light](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/book-open_light.svg#gh-light-mode-only) ![Documentation Logo Dark](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/book-open_dark.svg#gh-dark-mode-only) [Документация](https://gravity-ui.com/components/uikit/alert)

### ![Figma Logo Light](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/figma_light.svg#gh-light-mode-only) ![Figma Logo Dark](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/figma_dark.svg#gh-dark-mode-only) [Figma](<https://www.figma.com/community/file/1271150067798118027/Gravity-UI-Design-System-(Beta)>)

### ![Themer Logo Light](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/bucket-paint_light.svg#gh-light-mode-only) ![Themer Logo Dark](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/bucket-paint_dark.svg#gh-dark-mode-only) [Themer](https://gravity-ui.com/themer)

### ![Storybook Logo Light](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/storybook_light.svg#gh-light-mode-only) ![Storybook Logo Dark](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/storybook_dark.svg#gh-dark-mode-only) [Storybook](https://preview.gravity-ui.com/uikit/)

### ![Community Logo Light](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/telegram_light.svg#gh-light-mode-only) ![Community Logo Dark](https://raw.githubusercontent.com/gravity-ui/uikit/main/docs/assets/telegram_dark.svg#gh-dark-mode-only) [Сообщество](https://t.me/gravity_ui)

<!--/GITHUB_BLOCK-->

## Установка

```shell
npm install --save-dev @gravity-ui/uikit
```

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

```jsx
import React from 'react';
import {Button} from '@gravity-ui/uikit';

const SubmitButton = <Button view="action" size="l" />;
```

### Стили

UIKit включает в себя базовое стилизованное оформление и тему. Чтобы подключить их, добавьте следующий фрагмент кода в начало точки входа приложения:

```js
// index.js

import '@gravity-ui/uikit/styles/fonts.css';
import '@gravity-ui/uikit/styles/styles.css';

// ...
```

UIKit поддерживает несколько тем: светлая, темная и их контрастные версии. Приложение должно быть отрисовано внутри компонента `ThemeProvider`:

```js
import {createRoot} from 'react-dom/client';
import {ThemeProvider} from '@gravity-ui/uikit';

const root = createRoot(document.getElementById('root'));
root.render(
<ThemeProvider theme="light">
<App />
</ThemeProvider>,
);
```

Для предотвращения мигания темы можно сгенерировать исходные CSS-классы для корневого элемента во время серверного рендеринга.

```js
import {getRootClassName} from '@gravity-ui/uikit/server';

const theme = 'dark';
const rootClassName = getRootClassName({theme});

const html = `
<html>
<body>
<div id="root" class="${rootClassName}"></div>
</body>
</html>
`;
```

Также предусмотрен файл с SCSS-[миксинами](styles/mixins.scss), которые можно использовать в приложении.

### I18N

Некоторые компоненты содержат текстовые токены (слова и фразы), доступные на двух языках: `en` (по умолчанию) и `ru`.
Для настройки языка используйте функцию `configure`:

```js
// index.js

import {configure} from '@gravity-ui/uikit';

configure({
lang: 'ru',
});
```

## Разработка

Для запуска Storybook в режиме разработки выполните следующую команду:

```shell
npm start
```
1 change: 0 additions & 1 deletion src/components/Icon/Icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
$block: '.#{variables.$ns}icon';

#{$block} {
color: inherit;
line-height: 0;
vertical-align: top;
}
2 changes: 1 addition & 1 deletion src/components/Progress/ProgressInnerText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import {progressBlock} from './constants';

export interface ProgressInnerTextProps {
text?: string;
text?: React.ReactNode;
offset?: number;
}

Expand Down
24 changes: 12 additions & 12 deletions src/components/Progress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,18 @@ LANDING_BLOCK-->

## Properties

| Name | Description | Type | Default |
| :-------------- | :------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------: | :---------: |
| className | `class` HTML attribute | `string` | |
| colorStops | Sets breakpoints with themes | `Array<{theme: string; stop: number;}>` | |
| colorStopsValue | Sets the value for choosing the current stop or an alternative value for `colorStops`. The available range is from 0 to 100. | `number` | |
| loading | Toggles the `loading` state | `boolean` | `false` |
| size | Sets the progress bar size. The progress bar text can only be displayed in `"m"` size. | `string` | `"m"` |
| stack | Configuration of composite progress bar. Not required if a `value` is provided. | `Array<Stack>` | |
| stackClassName | `class` HTML attribute of stack | `string` | |
| text | Text inside the progress bar | `string` | |
| theme | Sets the progress color | `string` | `"default"` |
| value | Current progress value. The available range is from 0 to 100. Using the `stack` property value is optional and is used as `maxValue`. | `number` | |
| Name | Description | Type | Default |
| :-------------- | :---------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------: | :---------: |
| className | HTML `class` attribute | `string` | |
| colorStops | Sets breakpoints with themes | `Array<{theme: string; stop: number;}>` | |
| colorStopsValue | Sets the value for choosing the current stop or alternative value for colorStops. The available range is from 0 to 100. | `number` | |
| loading | Toggles the `loading` state | `boolean` | `false` |
| size | Sets the progress bar size. The progress bar text can only be displayed in `"m"` size. | `string` | `"m"` |
| stack | Configuration of composite progress bar. Not required if a `value` is provided. | `Array<Stack>` | |
| stackClassName | HTML `class` attribute of stack | `string` | |
| text | Text inside the progress bar | `ReactNode` | |
| theme | Sets progress color | `string` | `"default"` |
| value | Current progress value. The available range is from 0 to 100. Using the `stack` property value is optional and is used as maxValue. | `number` | |

### `Stack`

Expand Down
2 changes: 1 addition & 1 deletion src/components/Progress/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface ProgressGeneralProps extends QAProps {

export interface ProgressDefaultProps {
/** Text inside progress bar */
text: string;
text: React.ReactNode;
/** Theme */
theme: ProgressTheme;
/** Size. Text of progress bar is displayed in `m` size only. */
Expand Down
8 changes: 6 additions & 2 deletions src/components/Select/components/SelectList/OptionWrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ type OptionWrapProps = {
};

const DefaultOption = ({option}: DefaultOptionProps) => {
const {content, children, disabled} = option;
return <span className={b('option-default-label', {disabled})}>{content || children}</span>;
const {content, children, disabled, title} = option;
return (
<span title={title} className={b('option-default-label', {disabled})}>
{content || children}
</span>
);
};

export const OptionWrap = (props: OptionWrapProps) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ LANDING_BLOCK-->
| meta | Tab description | `string` | |
| hint | HTML title attribute | `string` | |
| icon | Icon displayed at the start | `React.ReactNode` | |
| counter | Number displayed at the end | `React.ReactNode` | |
| counter | Number displayed at the end | `number` `string` | |
| label | `<Label>` displayed at the end | `React.ReactNode` | |
| disabled | Inactive state | `boolean` | |

Expand Down
4 changes: 2 additions & 2 deletions src/components/Tabs/TabsItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface TabsItemProps {
disabled?: boolean;
hasOverflow?: boolean;
icon?: React.ReactNode;
counter?: number;
counter?: number | string;
label?: {
content: React.ReactNode;
theme?: LabelProps['theme'];
Expand Down Expand Up @@ -100,7 +100,7 @@ export function TabsItem({
<div className={b('item-content')}>
{icon && <div className={b('item-icon')}>{icon}</div>}
<div className={b('item-title')}>{title || id}</div>
{typeof counter === 'number' && <div className={b('item-counter')}>{counter}</div>}
{counter !== undefined && <div className={b('item-counter')}>{counter}</div>}
{label && (
<Label className={b('item-label')} theme={label.theme}>
{label.content}
Expand Down
15 changes: 15 additions & 0 deletions styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,18 @@
:root:has(body.g-root_theme_dark-hc) {
color-scheme: dark;
}

@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
/* stylelint-disable-next-line declaration-no-important */
scroll-behavior: auto !important;
/* stylelint-disable-next-line declaration-no-important */
transition-duration: 0.001ms !important;
/* stylelint-disable-next-line declaration-no-important */
animation-duration: 0.001ms !important;
/* stylelint-disable-next-line declaration-no-important */
animation-iteration-count: 1 !important;
}
}

0 comments on commit 99dd39f

Please sign in to comment.