Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve(ui): ContentWithQuestion icon color #887

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ui/src/BasicLayout/style/Header.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { CSSObject } from '@ant-design/cssinjs';
import type { FullToken, GenerateStyle } from 'antd/es/theme/internal';
import type { FullToken, GenerateStyle } from '@oceanbase/design/es/theme';
import { genComponentStyleHook } from '../../_util/genComponentStyleHook';

export type HeaderToken = FullToken<any>;
Expand Down
29 changes: 7 additions & 22 deletions packages/ui/src/ContentWithQuestion/demo/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
import React from 'react';
import { ContentWithQuestion } from '@oceanbase/ui';
import './index.less';

export default () => {
return (
<>
<div>
<ContentWithQuestion
content="ไป˜่ดนๆœๅŠกๅ ๆฏ”"
tooltip={{
title:
'็™ป่ฎฐ็š„ๆœๅŠกไบบๅคฉไธญๆœ‰ๆœๅŠกๅŒ…ๅฝ’ๅฑž็š„็™พๅˆ†ๆฏ”๏ผŒ่ฎก็ฎ—ๅ…ฌๅผไธบ (ๆœ‰ๆœๅŠกๅŒ…ๅฝ’ๅฑž็š„ๆœๅŠกไบบๅคฉๆ€ปๅ’Œ)/(ๅทฒๆŠ•ๅ…ฅไบบๅคฉ)',
overlayStyle: { maxWidth: '330px' },
}}
/>
</div>
<div>
<ContentWithQuestion
className="customer-className"
content="่‡ชๅฎšไน‰ className"
tooltip={{
title: '่‡ชๅฎšไน‰ๅญ—ไฝ“่“่‰ฒ className',
}}
/>
</div>
</>
<ContentWithQuestion
content="ไป˜่ดนๆœๅŠกๅ ๆฏ”"
tooltip={{
title:
'็™ป่ฎฐ็š„ๆœๅŠกไบบๅคฉไธญๆœ‰ๆœๅŠกๅŒ…ๅฝ’ๅฑž็š„็™พๅˆ†ๆฏ”๏ผŒ่ฎก็ฎ—ๅ…ฌๅผไธบ (ๆœ‰ๆœๅŠกๅŒ…ๅฝ’ๅฑž็š„ๆœๅŠกไบบๅคฉๆ€ปๅ’Œ)/(ๅทฒๆŠ•ๅ…ฅไบบๅคฉ)',
}}
/>
);
};
16 changes: 16 additions & 0 deletions packages/ui/src/ContentWithQuestion/demo/custom.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { ContentWithQuestion } from '@oceanbase/ui';
import { QuestionCircleFilled } from '@oceanbase/icons';

export default () => {
return (
<ContentWithQuestion
content="ไป˜่ดนๆœๅŠกๅ ๆฏ”"
tooltip={{
title:
'็™ป่ฎฐ็š„ๆœๅŠกไบบๅคฉไธญๆœ‰ๆœๅŠกๅŒ…ๅฝ’ๅฑž็š„็™พๅˆ†ๆฏ”๏ผŒ่ฎก็ฎ—ๅ…ฌๅผไธบ (ๆœ‰ๆœๅŠกๅŒ…ๅฝ’ๅฑž็š„ๆœๅŠกไบบๅคฉๆ€ปๅ’Œ)/(ๅทฒๆŠ•ๅ…ฅไบบๅคฉ)',
}}
suffixIcon={<QuestionCircleFilled />}
/>
);
};
3 changes: 0 additions & 3 deletions packages/ui/src/ContentWithQuestion/demo/index.less

This file was deleted.

3 changes: 1 addition & 2 deletions packages/ui/src/ContentWithQuestion/demo/prefix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ export default () => {
tooltip={{
title:
'็™ป่ฎฐ็š„ๆœๅŠกไบบๅคฉไธญๆœ‰ๆœๅŠกๅŒ…ๅฝ’ๅฑž็š„็™พๅˆ†ๆฏ”๏ผŒ่ฎก็ฎ—ๅ…ฌๅผไธบ (ๆœ‰ๆœๅŠกๅŒ…ๅฝ’ๅฑž็š„ๆœๅŠกไบบๅคฉๆ€ปๅ’Œ)/(ๅทฒๆŠ•ๅ…ฅไบบๅคฉ)',
overlayStyle: { maxWidth: '330px' },
}}
prefixIcon
prefixIcon={true}
suffixIcon={null}
/>
);
Expand Down
18 changes: 0 additions & 18 deletions packages/ui/src/ContentWithQuestion/index.less

This file was deleted.

9 changes: 4 additions & 5 deletions packages/ui/src/ContentWithQuestion/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ nav:

## ไปฃ็ ๆผ”็คบ

<code src="./demo/basic.tsx" title="ๅŸบๆœฌ" description="็ป„ไปถ้ป˜่ฎคๆƒ…ๅ†ตๅ›พๆ ‡ๅœจๆ–‡ๅญ—ๅŽ๏ผŒๅฆ‚ไธ้œ€่ฆ่‡ชๅฎšไน‰ๅ›พๆ ‡๏ผŒๅˆ™ไธ้œ€่ฆไผ  suffixIcon
"></code>
<code src="./demo/basic.tsx" title="ๅŸบๆœฌ"></code>

<code src="./demo/prefix.tsx" title="ๅ›พๆ ‡ๅœจๆ–‡ๅญ—ๅ‰" description="ๅ›พๆ ‡่‹ฅๅœจๆ–‡ๅญ—ๅ‰๏ผŒ้œ€ๆŠŠ suffixIcon ็ฝฎไธบ null๏ผŒprefixIcon ไฝฟ็”จ้ป˜่ฎคๅ›พๆ ‡็š„่ฏไผ  true"></code>
<code src="./demo/custom.tsx" title="่‡ชๅฎšไน‰ๅ›พๆ ‡"></code>

<code src="./demo/prefix.tsx" title="ๅ›พๆ ‡ๅ‰็ฝฎ"></code>

## API

Expand All @@ -20,5 +21,3 @@ nav:
| tooltip | Tooltip ้…็ฝฎ | TooltipProps | - | - |
| prefixIcon | ๆ–‡ๅญ—ๅ‰ๅ›พๆ ‡้…็ฝฎ | React.ReactNode \| boolean | null | - |
| suffixIcon | ๆ–‡ๅญ—ๅŽๅ›พๆ ‡้…็ฝฎ | React.ReactNode \| boolean | true | - |
| className | ็ป„ไปถ className | String | - | - |
| style | ็ป„ไปถ style | React.CSSProperties | - | - |
35 changes: 9 additions & 26 deletions packages/ui/src/ContentWithQuestion/index.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { QuestionCircleOutlined } from '@oceanbase/icons';
import { ConfigProvider, Space, Tooltip, TooltipProps } from '@oceanbase/design';
import { ConfigProvider, Space, Tooltip } from '@oceanbase/design';
import type { TooltipProps } from '@oceanbase/design';
import classNames from 'classnames';
import React, { useContext, isValidElement } from 'react';
import useStyle from './style';

export interface ContentWithQuestionProps {
export interface ContentWithQuestionProps
extends Omit<React.HTMLProps<HTMLSpanElement>, 'content'> {
content?: React.ReactNode;
tooltip?: TooltipProps;
prefixIcon?: React.ReactNode | boolean;
suffixIcon?: React.ReactNode | boolean;
className?: string;
style?: React.CSSProperties;
onClick?: (e: React.SyntheticEvent) => void;
prefixCls?: string;
}

const ContentWithQuestion: React.FC<ContentWithQuestionProps> = ({
prefixCls: customizePrefixCls,
content,
tooltip,
prefixIcon = null,
suffixIcon = true,
prefixCls: customizePrefixCls,
className,
children,
...restProps
}: any) => {
}) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
const prefixCls = getPrefixCls('content-with-question', customizePrefixCls);
const { wrapSSR } = useStyle(prefixCls);
Expand All @@ -41,26 +41,9 @@ const ContentWithQuestion: React.FC<ContentWithQuestionProps> = ({
};

return wrapSSR(
<span
className={classNames({
[`${prefixCls}-item`]: true,
[className]: !!className,
})}
{...restProps}
>
<span className={classNames(`${prefixCls}-item`, className)} {...restProps}>
<Space>
{getIcon(
prefixIcon === true ? (
<QuestionCircleOutlined
className={`${prefixCls}-help`}
style={{
marginRight: 4,
}}
/>
) : (
prefixIcon
)
)}
{getIcon(prefixIcon)}
<span data-testid="content">{content ?? children}</span>
{getIcon(suffixIcon)}
</Space>
Expand Down
20 changes: 11 additions & 9 deletions packages/ui/src/ContentWithQuestion/style/index.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import type { CSSObject } from '@ant-design/cssinjs';
import type { GenerateStyle } from '@oceanbase/design/es/theme';
import type { FullToken, GenerateStyle } from '@oceanbase/design/es/theme';
import { genComponentStyleHook } from '../../_util/genComponentStyleHook';

export const genContentWithQuestionStyle: GenerateStyle<any> = (token: any): CSSObject => {
const { componentCls, paddingSM } = token;
export type ContentWithQuestionToken = FullToken<'App'>;

export const genContentWithQuestionStyle: GenerateStyle<any> = (
token: ContentWithQuestionToken
): CSSObject => {
const { componentCls } = token;

return {
[`${componentCls}-item`]: {
display: 'inline-flex',
alignItems: 'center',
[`${componentCls}-prefix`]: {
marginRight: 8,
marginRight: token.marginXS,
},
[`${componentCls}-suffix`]: {
marginLeft: 8,
marginLeft: token.marginXS,
},
[`${componentCls}-help`]: {
cursor: 'help',
},
[`${componentCls}-color`]: {
color: 'red',
color: token.colorIcon,
},
},
};
};

export default (prefixCls: string) => {
const useStyle = genComponentStyleHook('ContentWithQuestion', token => {
return [genContentWithQuestionStyle(token as any)];
return [genContentWithQuestionStyle(token as ContentWithQuestionToken)];
});
return useStyle(prefixCls);
};
2 changes: 1 addition & 1 deletion packages/ui/src/TagSelect/style/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { CSSObject } from '@ant-design/cssinjs';
import type { FullToken, GenerateStyle } from 'antd/es/theme/internal';
import type { FullToken, GenerateStyle } from '@oceanbase/design/es/theme';
import { genComponentStyleHook } from '../../_util/genComponentStyleHook';

export type TagSelectToken = FullToken<any>;
Expand Down
Loading