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

fix(Input): repair icon props #3248

Merged
merged 1 commit into from
Aug 24, 2023
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
4 changes: 2 additions & 2 deletions packages/react-ui/.creevey/images/Input/Left Icon/chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/react-ui/.creevey/images/Input/Left Icon/firefox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/react-ui/.creevey/images/Input/Left Icon/ie11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/react-ui/.creevey/images/Input/Left Icon/ie118px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/react-ui/.creevey/images/Input/Right Icon/chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/react-ui/.creevey/images/Input/Right Icon/ie11.png
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface InputLayoutAsideProps {
side: 'left' | 'right';
}

export const InputLayoutAside: React.FunctionComponent<InputLayoutAsideProps> = ({ icon = null, text, side }) => {
export const InputLayoutAside: React.FunctionComponent<InputLayoutAsideProps> = ({ icon, text, side }) => {
const asideClassName = stylesLayout.aside();

const _icon = <InputLayoutAsideIcon key="icon" icon={icon} side={side} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface InputLayoutAsideIconProps {
side: 'left' | 'right';
}

export const InputLayoutAsideIcon: React.FunctionComponent<InputLayoutAsideIconProps> = ({ icon, side }) => {
export const InputLayoutAsideIcon: React.FunctionComponent<InputLayoutAsideIconProps> = ({ icon = null, side }) => {
const theme = React.useContext(ThemeContext);
const { focused, disabled, size } = React.useContext(InputLayoutContext);

Expand All @@ -28,9 +28,9 @@ export const InputLayoutAsideIcon: React.FunctionComponent<InputLayoutAsideIconP
large: parseInt(theme.inputIconGapLarge),
};

let _icon = null;
if (icon && isElement(icon)) {
_icon = isKonturIcon(icon) ? React.cloneElement(icon, { size: icon.props.size ?? sizes[size] }) : icon;
let _icon = icon instanceof Function ? icon() : icon;
if (isElement(icon) && isKonturIcon(icon)) {
_icon = React.cloneElement(icon, { size: icon.props.size ?? sizes[size] });
}

const style: React.CSSProperties = {};
Expand Down
27 changes: 25 additions & 2 deletions packages/react-ui/components/Input/__stories__/Input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const LeftIcon: Story = () => (
<ComponentTable
Component={Input}
cols={sizeStates.map((x) => ({ props: x }))}
rows={iconsStates.map((x) => ({ props: x }))}
rows={iconsLeftStates.map((x) => ({ props: x }))}
presetProps={{ leftIcon: <SearchIcon /> }}
/>
);
Expand All @@ -117,13 +117,36 @@ export const RightIcon: Story = () => (
<ComponentTable
Component={Input}
cols={sizeStates.map((x) => ({ props: x }))}
rows={iconsStates.map((x) => ({ props: x }))}
rows={iconsRightStates.map((x) => ({ props: x }))}
presetProps={{ rightIcon: <SearchIcon /> }}
/>
);

const iconFunc = () => <SearchIcon />;
iconFunc.toString = () => '() => <SearchIcon />';

const iconsStates: InputState[] = [{}, { defaultValue: 'Value' }, { disabled: true }];

const iconsLeftStates: InputState[] = [
...iconsStates,
{
leftIcon: iconFunc,
},
{
leftIcon: '₽',
},
];

const iconsRightStates: InputState[] = [
...iconsStates,
{
rightIcon: iconFunc,
},
{
rightIcon: '₽',
},
];

export const Mask: Story = () => (
<ComponentTable
Component={Input}
Expand Down