Skip to content
Open
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
9 changes: 9 additions & 0 deletions .changeset/chore-cui-340-info-icon.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions .changeset/fix-issue-546-alert-icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 4 additions & 4 deletions src/components/Alert/Alert.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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']);
});

Expand Down
4 changes: 2 additions & 2 deletions src/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import styles from './Alert.module.css';
type AlertState = 'neutral' | 'success' | 'warning' | 'danger' | 'info';

const stateIconMap: Record<AlertState, IconName> = {
neutral: 'info-in-circle',
neutral: 'info',
success: 'check',
warning: 'warning',
danger: 'warning',
info: 'info-in-circle',
info: 'info',
};

const sizeIconMap: Record<NonNullable<AlertProps['size']>, AssetSize> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SVGAssetProps } from '@/types';

const Info_In_Circle = (props: SVGAssetProps) => (
const Info = (props: SVGAssetProps) => (
<svg
width="24"
height="24"
Expand Down Expand Up @@ -34,4 +34,4 @@ const Info_In_Circle = (props: SVGAssetProps) => (
</svg>
);

export default Info_In_Circle;
export default Info;
34 changes: 0 additions & 34 deletions src/components/Assets/Icons/Information.tsx

This file was deleted.

6 changes: 2 additions & 4 deletions src/components/Assets/Icons/system/IconsDark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -280,8 +279,7 @@ const IconsDark: Record<IconName, ComponentType<SVGAssetProps>> = {
'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,
Expand Down
6 changes: 2 additions & 4 deletions src/components/Assets/Icons/system/IconsLight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -280,8 +279,7 @@ const IconsLight: Record<IconName, ComponentType<SVGAssetProps>> = {
'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,
Expand Down
3 changes: 1 addition & 2 deletions src/components/Assets/Icons/system/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ export type IconName =
| 'horizontal-loading'
| 'http'
| 'http-monitoring'
| 'info-in-circle'
| 'information'
| 'info'
| 'insert-row'
| 'integrations'
| 'italic'
Expand Down
6 changes: 4 additions & 2 deletions src/components/Assets/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
29 changes: 28 additions & 1 deletion src/components/Icon/Icon.test.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toast/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
} from './Toast.types';
import styles from './Toast.module.css';

export const ToastContext = createContext<ToastContextProps>({

Check warning on line 17 in src/components/Toast/Toast.tsx

View workflow job for this annotation

GitHub Actions / code-quality-checks

Fast refresh only works when a file only exports components. Move your React context(s) to a separate file
createToast: () => null,
});

Expand Down Expand Up @@ -69,7 +69,7 @@
}: 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)) {
Expand Down
Loading