diff --git a/.changeset/chore-cui-340-info-icon.md b/.changeset/chore-cui-340-info-icon.md new file mode 100644 index 000000000..e7460e4da --- /dev/null +++ b/.changeset/chore-cui-340-info-icon.md @@ -0,0 +1,9 @@ +--- +'@clickhouse/click-ui': minor +--- + +**Breaking:** there is now one info icon, `info`. `info-in-circle` is renamed to `info`, and `information` (the plain "i") is removed. + +Visual: anything that used `information` now shows the circled "i". Anything that used `info-in-circle` looks the same. + +Migration: `name="info-in-circle"` and `name="information"` become `name="info"`. The old names still render `info` and log a deprecation warning, but they are no longer in the `IconName` union, so typed props (`Icon.name`, `Button.iconLeft`, `Alert.customIcon`, …) fail typecheck until you rename them. `FileTabs` `icon` also accepts a node, so a string there still compiles: search for the old names. The icon's `aria-label` is now `info`, so update test queries that use the old names. diff --git a/.changeset/fix-issue-546-alert-icon.md b/.changeset/fix-issue-546-alert-icon.md index 82d25e891..345c73212 100644 --- a/.changeset/fix-issue-546-alert-icon.md +++ b/.changeset/fix-issue-546-alert-icon.md @@ -2,6 +2,6 @@ '@clickhouse/click-ui': minor --- -`Alert` neutral and info states now show the `info-in-circle` icon instead of `information`, and the icon follows the alert `size`. +`Alert` neutral and info states now show the circled info icon instead of the plain "i", and the icon follows the alert `size`. -Visual: neutral and info alerts show a circled "i". Medium alerts draw the state icon, including `customIcon`, at 20px instead of 16px. Small alerts keep 16px icons. To keep the previous glyph, pass `customIcon="information"`. +Visual: neutral and info alerts show a circled "i". Medium alerts draw the state icon, including `customIcon`, at 20px instead of 16px. Small alerts keep 16px icons. diff --git a/src/components/Alert/Alert.test.tsx b/src/components/Alert/Alert.test.tsx index 87b80e381..e9cc5e4cf 100644 --- a/src/components/Alert/Alert.test.tsx +++ b/src/components/Alert/Alert.test.tsx @@ -58,8 +58,8 @@ describe('Alert', () => { }); it.each([ - ['neutral', 'info-in-circle'], - ['info', 'info-in-circle'], + ['neutral', 'info'], + ['info', 'info'], ['success', 'check'], ['warning', 'warning'], ['danger', 'warning'], @@ -90,11 +90,11 @@ describe('Alert', () => { expect(icon.parentElement).toHaveClass(iconStyles[sizeClass]); }); - it('renders the default alert with a small info-in-circle icon', () => { + it('renders the default alert with a small info icon', () => { const { getByRole } = renderAlert({ text: 'Default' }); const icon = getByRole('img', { hidden: true }); - expect(icon).toHaveAttribute('aria-label', 'info-in-circle'); + expect(icon).toHaveAttribute('aria-label', 'info'); expect(icon.parentElement).toHaveClass(iconStyles['svg-wrapper_size_sm']); }); diff --git a/src/components/Alert/Alert.tsx b/src/components/Alert/Alert.tsx index d9eb7cbf1..dff46b7e4 100644 --- a/src/components/Alert/Alert.tsx +++ b/src/components/Alert/Alert.tsx @@ -8,11 +8,11 @@ import styles from './Alert.module.css'; type AlertState = 'neutral' | 'success' | 'warning' | 'danger' | 'info'; const stateIconMap: Record = { - neutral: 'info-in-circle', + neutral: 'info', success: 'check', warning: 'warning', danger: 'warning', - info: 'info-in-circle', + info: 'info', }; const sizeIconMap: Record, AssetSize> = { diff --git a/src/components/Assets/Icons/Info-In-Circle.tsx b/src/components/Assets/Icons/Info.tsx similarity index 90% rename from src/components/Assets/Icons/Info-In-Circle.tsx rename to src/components/Assets/Icons/Info.tsx index b66964ff3..7dbedc32f 100644 --- a/src/components/Assets/Icons/Info-In-Circle.tsx +++ b/src/components/Assets/Icons/Info.tsx @@ -1,6 +1,6 @@ import type { SVGAssetProps } from '@/types'; -const Info_In_Circle = (props: SVGAssetProps) => ( +const Info = (props: SVGAssetProps) => ( ( ); -export default Info_In_Circle; +export default Info; diff --git a/src/components/Assets/Icons/Information.tsx b/src/components/Assets/Icons/Information.tsx deleted file mode 100644 index 82081355b..000000000 --- a/src/components/Assets/Icons/Information.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import type { SVGAssetProps } from '@/types'; - -const Information = (props: SVGAssetProps) => ( - - - - - -); - -export default Information; diff --git a/src/components/Assets/Icons/system/IconsDark.ts b/src/components/Assets/Icons/system/IconsDark.ts index a2d877da4..73cc8d415 100644 --- a/src/components/Assets/Icons/system/IconsDark.ts +++ b/src/components/Assets/Icons/system/IconsDark.ts @@ -99,8 +99,7 @@ import Home from '../Home'; import Horizontal_Loading from '../Horizontal-Loading'; import Http from '../Http'; import Http_Monitoring from '../Http-Monitoring'; -import Info_In_Circle from '../Info-In-Circle'; -import Information from '../Information'; +import Info from '../Info'; import Insert_Row from '../Insert-Row'; import Integrations from '../Integrations'; import Italic from '../Italic'; @@ -280,8 +279,7 @@ const IconsDark: Record> = { 'horizontal-loading': Horizontal_Loading, http: Http, 'http-monitoring': Http_Monitoring, - 'info-in-circle': Info_In_Circle, - information: Information, + info: Info, 'insert-row': Insert_Row, integrations: Integrations, italic: Italic, diff --git a/src/components/Assets/Icons/system/IconsLight.ts b/src/components/Assets/Icons/system/IconsLight.ts index 390039024..0df14b5bc 100644 --- a/src/components/Assets/Icons/system/IconsLight.ts +++ b/src/components/Assets/Icons/system/IconsLight.ts @@ -99,8 +99,7 @@ import Home from '../Home'; import Horizontal_Loading from '../Horizontal-Loading'; import Http from '../Http'; import Http_Monitoring from '../Http-Monitoring'; -import Info_In_Circle from '../Info-In-Circle'; -import Information from '../Information'; +import Info from '../Info'; import Insert_Row from '../Insert-Row'; import Integrations from '../Integrations'; import Italic from '../Italic'; @@ -280,8 +279,7 @@ const IconsLight: Record> = { 'horizontal-loading': Horizontal_Loading, http: Http, 'http-monitoring': Http_Monitoring, - 'info-in-circle': Info_In_Circle, - information: Information, + info: Info, 'insert-row': Insert_Row, integrations: Integrations, italic: Italic, diff --git a/src/components/Assets/Icons/system/types.ts b/src/components/Assets/Icons/system/types.ts index 6fa09d796..ba39656de 100644 --- a/src/components/Assets/Icons/system/types.ts +++ b/src/components/Assets/Icons/system/types.ts @@ -97,8 +97,7 @@ export type IconName = | 'horizontal-loading' | 'http' | 'http-monitoring' - | 'info-in-circle' - | 'information' + | 'info' | 'insert-row' | 'integrations' | 'italic' diff --git a/src/components/Assets/config.ts b/src/components/Assets/config.ts index 15e1a2743..c3a15e1cf 100644 --- a/src/components/Assets/config.ts +++ b/src/components/Assets/config.ts @@ -102,8 +102,10 @@ export const ASSET_NAME_MAPPINGS = { HorizontalLoading: 'horizontal-loading', Http: 'http', HttpMonitoring: 'http-monitoring', - InfoInCircleIcon: 'info-in-circle', - InformationIcon: 'information', + InfoInCircleIcon: 'info', + InformationIcon: 'info', + 'info-in-circle': 'info', + information: 'info', InsertRowIcon: 'insert-row', Integrations: 'integrations', Italic: 'italic', diff --git a/src/components/Icon/Icon.test.tsx b/src/components/Icon/Icon.test.tsx index e121b7e03..c81277979 100644 --- a/src/components/Icon/Icon.test.tsx +++ b/src/components/Icon/Icon.test.tsx @@ -1,5 +1,5 @@ import { Icon } from '@/components/Icon'; -import type { ImageName } from '@/components/Icon/Icon.types'; +import type { IconName, ImageName } from '@/components/Icon/Icon.types'; import { within } from '@testing-library/react'; import { renderCUI } from '@/utils/test-utils'; @@ -43,6 +43,33 @@ describe('Icon', () => { expect(arrow.innerHTML).toEqual(share.innerHTML); }); + it.each(['info-in-circle', 'information', 'InfoInCircleIcon', 'InformationIcon'])( + 'renders the deprecated %s name as info and warns (CUI-340)', + name => { + const info = within(renderIcon('info').container).getByRole('img'); + expect(warn).not.toHaveBeenCalled(); + + const deprecated = within(renderIcon(name).container).getByRole('img'); + expect(deprecated).toHaveAttribute('aria-label', 'info'); + expect(deprecated.innerHTML).toEqual(info.innerHTML); + expect(warn).toHaveBeenCalledWith( + expect.stringContaining(`"${name}" is deprecated, use "info"`) + ); + } + ); + + it('keeps only info in IconName (CUI-340)', () => { + const names: IconName[] = [ + 'info', + // @ts-expect-error `info-in-circle` was renamed to `info` + 'info-in-circle', + // @ts-expect-error `information` was removed + 'information', + ]; + + expect(names).toHaveLength(3); + }); + it('renders a deprecated PascalCase name', () => { const { getByRole } = renderIcon('ArrowDown'); expect(getByRole('img')).toBeInTheDocument(); diff --git a/src/components/Toast/Toast.tsx b/src/components/Toast/Toast.tsx index 5532bdb7d..eb4f29a5b 100644 --- a/src/components/Toast/Toast.tsx +++ b/src/components/Toast/Toast.tsx @@ -69,7 +69,7 @@ export const Toast = ({ }: ToastProps & { onClose: (open: boolean) => void }) => { let iconName = ''; if (type === 'default') { - iconName = 'info-in-circle'; + iconName = 'info'; } else if (type === 'success') { iconName = 'check'; } else if (type && ['danger', 'warning'].includes(type)) {