Skip to content

Commit 2c19763

Browse files
authored
feat: added new view text content alert (#265)
1 parent a47ec49 commit 2c19763

28 files changed

+145
-3
lines changed

docs/spec.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ You can provide all props of [original component](https://preview.gravity-ui.com
182182
| text | `string` | yes | Text for input |
183183
| icon | `string` | | Icon name from the [library](https://gravity-ui.com/icons) |
184184
| iconColor | `'primary'` `'complementary'` `'secondary'` `'hint'` `'info'` `'info-heavy'` `'positive'` `'positive-heavy'` `'warning'` `'warning-heavy'` `'danger'` `'danger-heavy'` `'utility'` `'utility-heavy'` `'misc'` `'misc-heavy'` `'brand'` `'dark-primary'` `'dark-complementary'` `'dark-secondary'` | | The color of the icon, if it does not have the themeLabel parameter |
185+
| themeIcon | `'normal'` `'info'` `'success'` `'warning'` `'danger'` `'utility'` | | Alert color |
186+
| titleAlert | `string` | | Alert title |
185187

186188
#### SelectParams
187189

src/lib/core/types/specs.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {LabelProps} from '@gravity-ui/uikit';
1+
import {AlertProps, LabelProps} from '@gravity-ui/uikit';
22
import {ColorTextBaseProps} from '@gravity-ui/uikit/build/esm/components/Text/colorText/colorText';
33

44
import {ReadAsMethod, SpecTypes} from '../constants';
@@ -173,6 +173,8 @@ export interface StringSpec<
173173
text: string;
174174
icon?: string;
175175
iconColor?: ColorTextBaseProps['color'];
176+
titleAlert?: string;
177+
themeAlert?: AlertProps['theme'];
176178
};
177179
fileInput?: {
178180
accept?: string;

src/lib/kit/components/Inputs/TextContent/TextContent.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22

3-
import {Label, Text} from '@gravity-ui/uikit';
3+
import {isEmpty} from 'lodash';
4+
5+
import {Alert, Label, Text} from '@gravity-ui/uikit';
46
import cloneDeep from 'lodash/cloneDeep';
57

68
import {StringIndependentInput, StringSpec} from '../../../../core';
@@ -41,7 +43,22 @@ export const TextContentComponent: React.FC<TextContentComponentProps> = ({
4143

4244
let content = <span dangerouslySetInnerHTML={{__html: text}} />;
4345

44-
if (textContentParams?.themeLabel) {
46+
if (textContentParams?.themeAlert) {
47+
const titleAlert =
48+
textContentParams?.titleAlert || !isEmpty(textContentParams?.titleAlert)
49+
? textContentParams.titleAlert
50+
: undefined;
51+
52+
content = (
53+
<Alert
54+
icon={iconLib}
55+
message={content}
56+
// If the title is an empty line, then you need to explicitly write undefined, otherwise there will be an additional indent
57+
title={titleAlert}
58+
theme={textContentParams?.themeAlert}
59+
/>
60+
);
61+
} else if (textContentParams?.themeLabel) {
4562
content = (
4663
<Label
4764
size="m"
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)