-
Notifications
You must be signed in to change notification settings - Fork 68
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
Как использовать кастомные иконки в vkui? #998
Comments
Привет, Можно создать себе вот такой компонент import React from 'react';
export interface SvgIconProps extends React.SVGProps<SVGSVGElement> {
width?: number;
height?: number;
getRootRef?: React.Ref<SVGSVGElement>;
title?: string;
}
const SvgIcon = ({
width = 0,
height = 0,
display = 'block',
'aria-hidden': ariaHidden = true,
iconId,
className,
fill,
getRootRef,
'style': propsStyle,
title,
children,
...restProps
}: SvgIconProps) => {
const size = Math.max(width, height);
const style = {
width,
height,
...propsStyle,
};
return (
<svg
aria-hidden={ariaHidden}
display={display}
className={[
'vkuiIcon',
`vkuiIcon--${size}`,
`vkuiIcon--w-${width}`,
`vkuiIcon--h-${height}`,
className,
]
.join(' ')
.trim()}
width={width}
height={height}
style={{ fill: 'currentColor', color: fill, ...style }}
ref={getRootRef}
{...restProps}
>
{title && <title>{title}</title>}
{children}
</svg>
);
}; а потом const Icon12SomeName = (props: SvgIconProps) => (
<SvgIcon width="12" height="12" viewBox="0 0 12 12" {...props}>
<path d="..." />
</SvgIcon>
);
const Icon24SomeName = (props: SvgIconProps) => (
<SvgIcon width="24" height="24" viewBox="0 0 24 24" {...props}>
<path d="..." />
</SvgIcon>
); |
благодарю |
В планах нет, но создал задачку #1011 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Есть ли возможность оборачивать свои svg иконки так, чтобы внутри vkui было идентичное поведение? Или нужно делать форк и паблишить со своими иконками в свой репозиторий?
The text was updated successfully, but these errors were encountered: