Skip to content

Commit 3f6649c

Browse files
authored
Merge pull request #3 from jaebradley/fixes
refactor(author): fix minor issues and renamed
2 parents 9ad2ab9 + 45aec9b commit 3f6649c

File tree

5 files changed

+44
-36
lines changed

5 files changed

+44
-36
lines changed

.storybook/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ setTimeout(() => setOptions({
1717

1818
function loadStories() {
1919
require('../src/MadeWith/MadeWith.stories.js');
20-
require('../src/Author/Author.stories.js');
20+
require('../src/Maker/Maker.stories.js');
2121
}
2222

2323
configure(loadStories, module);

src/MadeWith/MadeWith.stories.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ storiesOf('Made With', module)
1717
<MadeWith
1818
love
1919
react
20-
author={{
20+
maker={{
2121
identifier: 'https://github.com/jaebradley'
2222
}}
2323
/>
@@ -26,7 +26,7 @@ storiesOf('Made With', module)
2626
<MadeWith
2727
love
2828
react
29-
author={{
29+
maker={{
3030
identifier: '[email protected]',
3131
display: 'Jae Bradley',
3232
iconColor: 'blue',
@@ -37,7 +37,7 @@ storiesOf('Made With', module)
3737
<MadeWith
3838
react
3939
love
40-
author={{
40+
maker={{
4141
identifier: 'https://github.com/jaebradley',
4242
display: <FontAwesomeIcon icon={ faUserSecret } />,
4343
showIcon: false,
@@ -49,7 +49,7 @@ storiesOf('Made With', module)
4949
love
5050
react
5151
separator={ <FontAwesomeIcon icon={ faPlus } /> }
52-
author={{
52+
maker={{
5353
identifier: 'https://github.com/jaebradley'
5454
}}
5555
/>

src/MadeWith/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33
import classNames from 'classnames';
44

55
import buildIcons from './buildIcons';
6-
import Author from '../Author';
6+
import Maker from '../Maker';
77

88
class MadeWith extends Component {
99
constructor(props) {
@@ -22,18 +22,18 @@ class MadeWith extends Component {
2222
}
2323

2424
render() {
25-
const { className, author } = this.props;
25+
const { className, maker } = this.props;
2626
return (
2727
<div className={ classNames(className, 'made-with') }>
2828
Made with
2929
{ ' ' }
3030
{ this.buildIcons() }
31-
{ author &&
32-
<span className={ 'author-wrapper' }> by
31+
{ maker &&
32+
<span className={ 'maker-wrapper' }> by
3333
{ ' ' }
34-
<Author
35-
className={ 'author' }
36-
{ ...author }
34+
<Maker
35+
{ ...maker }
36+
className={ 'maker' }
3737
/>
3838
</span>
3939
}
@@ -43,7 +43,7 @@ class MadeWith extends Component {
4343
}
4444

4545
MadeWith.defaultProps = {
46-
author: {
46+
maker: {
4747
display: '',
4848
showIcon: true,
4949
iconColor: '',
@@ -55,7 +55,7 @@ MadeWith.defaultProps = {
5555
}
5656

5757
MadeWith.propTypes = {
58-
author: PropTypes.shape({
58+
maker: PropTypes.shape({
5959
identifier: PropTypes.string.isRequired,
6060
display: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
6161
showIcon: PropTypes.bool,
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@ import { withInfo } from '@storybook/addon-info';
44
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
55
import { faUserSecret } from '@fortawesome/fontawesome-free-solid';
66

7-
import Author from './index';
7+
import Maker from './index';
88
// import README from './README.md';
99

1010
// const wrapComponent = (component) => (
1111
// withInfo(README)(() => component)
1212
// );
1313

14-
storiesOf('Author', module)
14+
storiesOf('Maker', module)
1515
.add('basic usage', () => (
16-
<Author identifier={ 'Jae Bradley' } />
16+
<Maker identifier={ 'Jae Bradley' } />
1717
))
1818
.add('with email address, no icon', () => (
19-
<Author identifier={ '[email protected]' } showIcon={ false } />
19+
<Maker identifier={ '[email protected]' } showIcon={ false } />
2020
))
2121
.add('Twitter URL with icon and inferred display name', () => (
22-
<Author identifier={ 'https://twitter.com/jaebradley' } />
22+
<Maker identifier={ 'https://twitter.com/jaebradley' } />
2323
))
2424
.add('GitHub URL with icon and explicit display name', () => (
25-
<Author identifier={ 'https://github.com/jaebradley' } display={ 'Jae Bradley' } />
25+
<Maker identifier={ 'https://github.com/jaebradley' } display={ 'Jae Bradley' } />
2626
))
2727
.add('with email address and envelope icon', () => (
28-
<Author identifier={ '[email protected]' } />
28+
<Maker identifier={ '[email protected]' } />
2929
))
3030
.add('url without explicit display name', () => (
31-
<Author identifier={ 'https://example.com' } />
31+
<Maker identifier={ 'https://example.com' } />
3232
))
3333
.add('url with explicit display name', () => (
34-
<Author identifier={ 'https://example.com' } display={ 'Example Dot Com' } />
34+
<Maker identifier={ 'https://example.com' } display={ 'Example Dot Com' } />
3535
));
Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import isEmail from 'isemail';
44
import urlParse from 'url';
55
import parseGitHubUrl from 'parse-github-url';
66
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
7-
import { faEnvelope } from '@fortawesome/fontawesome-free-solid';
7+
import { faEnvelope, faLink } from '@fortawesome/fontawesome-free-solid';
88
import { faTwitter, faGithub } from '@fortawesome/fontawesome-free-brands';
99

10-
class Author extends Component {
10+
class Maker extends Component {
1111
constructor(props) {
1212
super(props);
1313
}
@@ -26,7 +26,13 @@ class Author extends Component {
2626
{ display || identifier }
2727
</a>
2828
{ showIcon &&
29-
<span className={ 'author-icon' }> { <FontAwesomeIcon icon={ faEnvelope } style={ { color: iconColor } }/> }</span>
29+
<span className={ 'maker-icon' }>
30+
{ ' ' }
31+
<FontAwesomeIcon
32+
icon={ faEnvelope }
33+
style={ { color: iconColor } }
34+
/>
35+
</span>
3036
}
3137
</span>
3238
);
@@ -41,19 +47,20 @@ class Author extends Component {
4147
if (url.hostname === 'twitter.com') {
4248
icon = <FontAwesomeIcon icon={ faTwitter } style={ { color: iconColor || '#00aced' } } />
4349
// https://stackoverflow.com/questions/5948051/regex-extract-twitterusername-from-url#comment43986805_5948248
44-
username = identifier.match(/^https?:\/\/(www\.)?twitter\.com\/(#!\/)?([^/]+)(\/\w+)*$/)[3];
50+
username = `@${identifier.match(/^https?:\/\/(www\.)?twitter\.com\/(#!\/)?([^/]+)(\/\w+)*$/)[3]}`;
4551
} else if (url.hostname === 'github.com') {
4652
icon = <FontAwesomeIcon icon={ faGithub } style={ { color: iconColor || 'black' } } />
47-
username = parseGitHubUrl(identifier).owner;
53+
username = `@${parseGitHubUrl(identifier).owner}`;
4854
} else {
49-
return <a href={ identifier }>{ display || identifier }</a>;
55+
icon = <FontAwesomeIcon icon={ faLink } style={ { color: iconColor || 'black' } } />
56+
username = identifier;
5057
}
5158

5259
return (
5360
<span>
54-
<a href={ identifier }>{ display || `@${username}` }</a>
61+
<a href={ identifier }>{ display || username }</a>
5562
{ showIcon &&
56-
<span className={'author-icon'}> { icon }</span> }
63+
<span className={'maker-icon'}> { icon }</span> }
5764
</span>
5865
);
5966
}
@@ -62,17 +69,18 @@ class Author extends Component {
6269
}
6370
}
6471

65-
Author.defaultProps = {
66-
displayName: '',
72+
Maker.defaultProps = {
73+
identifier: '',
74+
display: '',
6775
showIcon: true,
6876
iconColor: '',
6977
};
7078

71-
Author.propTypes = {
72-
identifier: PropTypes.string.isRequired,
79+
Maker.propTypes = {
80+
identifier: PropTypes.string,
7381
display: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
7482
showIcon: PropTypes.bool,
7583
iconColor: PropTypes.string,
7684
};
7785

78-
export default Author;
86+
export default Maker;

0 commit comments

Comments
 (0)