-
-
Notifications
You must be signed in to change notification settings - Fork 204
Expand file tree
/
Copy pathAnchor.tsx
More file actions
33 lines (27 loc) · 883 Bytes
/
Anchor.tsx
File metadata and controls
33 lines (27 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import React, { forwardRef } from 'react';
import styled from 'styled-components';
import { CommonStyledProps } from '../types';
type AnchorProps = {
children: React.ReactNode;
underline?: boolean;
} & React.AnchorHTMLAttributes<HTMLAnchorElement> &
CommonStyledProps;
const StyledAnchor = styled.a<{ $underline: boolean }>`
color: ${({ theme }) => theme.anchor};
font-size: inherit;
text-decoration: ${({ $underline }) => ($underline ? 'underline' : 'none')};
&:visited {
color: ${({ theme }) => theme.anchorVisited};
}
`;
const Anchor = forwardRef<HTMLAnchorElement, AnchorProps>(
({ children, underline = true, ...otherProps }: AnchorProps, ref) => {
return (
<StyledAnchor ref={ref} $underline={underline} {...otherProps}>
{children}
</StyledAnchor>
);
}
);
Anchor.displayName = 'Anchor';
export { Anchor, AnchorProps };