Skip to content

Commit 659d102

Browse files
WesSouzaarturbien
authored andcommitted
feat(anchor): convert to TypeScript and export types
1 parent cc6ca3e commit 659d102

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

src/Anchor/Anchor.spec.js renamed to src/Anchor/Anchor.spec.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import React from 'react';
21
import { render } from '@testing-library/react';
32

4-
import Anchor from './Anchor';
3+
import { Anchor } from './Anchor';
54

65
const defaultProps = {
76
children: '',

src/Anchor/Anchor.stories.js renamed to src/Anchor/Anchor.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from 'react';
1+
import { ComponentMeta } from '@storybook/react';
22
import styled from 'styled-components';
33

4-
import { Anchor } from 'react95';
4+
import { Anchor } from './Anchor';
55

66
const Wrapper = styled.div`
77
padding: 5rem;
@@ -12,7 +12,7 @@ export default {
1212
title: 'Anchor',
1313
component: Anchor,
1414
decorators: [story => <Wrapper>{story()}</Wrapper>]
15-
};
15+
} as ComponentMeta<typeof Anchor>;
1616

1717
export function Default() {
1818
return (
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import React from 'react';
2-
import propTypes from 'prop-types';
1+
import React, { forwardRef } from 'react';
32

43
import styled from 'styled-components';
54

@@ -12,20 +11,19 @@ const StyledAnchor = styled.a`
1211
}
1312
`;
1413

15-
const Anchor = React.forwardRef(function Anchor(props, ref) {
16-
const { children, ...otherProps } = props;
14+
interface AnchorProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
15+
children: React.ReactNode;
16+
}
1717

18+
const Anchor = forwardRef<HTMLAnchorElement, AnchorProps>(function Anchor(
19+
{ children, ...otherProps }: AnchorProps,
20+
ref
21+
) {
1822
return (
1923
<StyledAnchor ref={ref} {...otherProps}>
2024
{children}
2125
</StyledAnchor>
2226
);
2327
});
2428

25-
Anchor.defaultProps = {};
26-
27-
Anchor.propTypes = {
28-
children: propTypes.node.isRequired
29-
};
30-
31-
export default Anchor;
29+
export { Anchor, AnchorProps };

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export { default as styleReset } from './common/styleReset';
33
export { createScrollbars } from './common/index';
44

55
/* components */
6-
export { default as Anchor } from './Anchor/Anchor';
6+
export * from './Anchor/Anchor';
77
export { default as AppBar } from './AppBar/AppBar';
88
export { default as Avatar } from './Avatar/Avatar';
99
export { default as Bar } from './Bar/Bar';

0 commit comments

Comments
 (0)