Skip to content

Commit

Permalink
Merge pull request #466 from tianenpang/fix/user-prop-tag
Browse files Browse the repository at this point in the history
fix(react-user): prop and link warnings
  • Loading branch information
jrgarciadev committed Jun 6, 2022
2 parents 43f48f8 + 1f31659 commit 5eee8a9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 37 deletions.
3 changes: 1 addition & 2 deletions packages/react/src/user/index.ts
Expand Up @@ -10,8 +10,7 @@ export {
StyledUser,
StyledUserInfo,
StyledUserName,
StyledUserDesc,
StyledUserLink
StyledUserDesc
} from './user.styles';

export default User;
52 changes: 27 additions & 25 deletions packages/react/src/user/user-link.tsx
@@ -1,35 +1,37 @@
import React from 'react';
import Link from '../link';
import { StyledUserLink } from './user.styles';
import { CSS } from '../theme/stitches.config';
import clsx from '../utils/clsx';
import { __DEV__ } from '../utils/assertion';
import type { LinkProps } from '../link';

interface Props {
href?: string;
children?: React.ReactNode;
}
type NativeAttrs = Omit<React.AnchorHTMLAttributes<unknown>, keyof Props>;
export type UserLinkProps = Props & NativeAttrs & { css?: CSS };

const UserLink = React.forwardRef<
HTMLAnchorElement,
React.PropsWithChildren<UserLinkProps>
>(
(
{ href, className, children, ...props },
ref: React.Ref<HTMLAnchorElement>
) => {

export type UserLinkProps = Props & Omit<LinkProps, 'icon'>;

const UserLink = React.forwardRef<HTMLAnchorElement, UserLinkProps>(
(props: UserLinkProps, ref: React.Ref<HTMLAnchorElement>) => {
const {
rel = 'noopener',
color = 'primary',
target = '_blank',
className,
children,
...otherProps
} = props;

return (
<StyledUserLink {...props}>
<Link
ref={ref}
href={href}
color="primary"
target="_blank"
rel="noopener"
>
{children}
</Link>
</StyledUserLink>
<Link
ref={ref}
rel={rel}
color={color}
target={target}
className={clsx('nextui-user-link', className)}
{...otherProps}
>
{children}
</Link>
);
}
);
Expand Down
8 changes: 0 additions & 8 deletions packages/react/src/user/user.styles.ts
Expand Up @@ -53,11 +53,3 @@ export const StyledUserDesc = styled('span', {
mb: 0
}
});

export const StyledUserLink = styled('a', {
a: {
'&:hover': {
opacity: 0.7
}
}
});
6 changes: 4 additions & 2 deletions packages/react/src/user/user.tsx
Expand Up @@ -64,6 +64,8 @@ export const User = React.forwardRef(
bordered,
size,
description,
zoomed,
pointer,
...otherProps
} = props;

Expand Down Expand Up @@ -99,8 +101,8 @@ export const User = React.forwardRef(
src={src}
color={color}
squared={squared}
zoomed={props.zoomed}
pointer={props.pointer}
zoomed={zoomed}
pointer={pointer}
bordered={bordered}
text={text}
size={size}
Expand Down

0 comments on commit 5eee8a9

Please sign in to comment.