Skip to content

Commit e5c493c

Browse files
committed
Merge branch 'main' of https://github.com/scientist-softserv/webstore-component-library into 137-accept-sow
2 parents 543f7ca + ec89bf0 commit e5c493c

File tree

6 files changed

+42
-24
lines changed

6 files changed

+42
-24
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@scientist-softserv/webstore-component-library",
3-
"version": "0.1.14",
3+
"version": "0.1.15",
44
"description": "A React component library intended for use with WebStore applications",
55
"main": "dist/index.js",
66
"module": "dist/index.es.js",
@@ -13,7 +13,10 @@
1313
"watch-lib": "rollup -c --watch",
1414
"release": "release-it"
1515
},
16-
"repository": "https://github.com/scientist-softserv/webstore-component-library.git",
16+
"repository": {
17+
"type": "git",
18+
"url": "git+https://github.com/scientist-softserv/webstore-component-library.git"
19+
},
1720
"keywords": [
1821
"webstore",
1922
"component",
@@ -88,7 +91,6 @@
8891
}
8992
},
9093
"publishConfig": {
91-
"registry": "https://npm.pkg.github.com",
9294
"ignore": [
9395
".eslintrc"
9496
]

src/components/FilesTable/FilesTable.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const FilesTable = ({ addClass, files }) => {
3434
<td className='text-center'>
3535
<Link
3636
icon='fa-download'
37+
label=''
3738
href={href}
3839
aria-label='download'
3940
/>

src/components/Link/Link.jsx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,39 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
33
import PropTypes from 'prop-types'
44
import './link.css'
55

6-
const Link = ({ addClass, href, icon, label, style, ...props }) => (
7-
<a
8-
href={href}
9-
className={`link ${addClass}`}
10-
style={style}
11-
{...props}
12-
>
13-
{icon && (
14-
<FontAwesomeIcon icon={icon} className={`small ${label.length > 0 && 'me-2'}`} />
15-
)}
16-
{label}
17-
</a>
18-
)
6+
const Link = ({ addClass, href, icon, label, style, ...props }) => {
7+
return (
8+
<a
9+
href={href}
10+
className={`link ${addClass}`}
11+
style={style}
12+
{...props}
13+
>
14+
{icon && (
15+
<FontAwesomeIcon icon={icon} className={`small ${label.length && 'me-2'}`} />
16+
)}
17+
{label && label}
18+
</a>
19+
)
20+
}
1921

22+
/**
23+
* there isn't an easy way to require either the icon OR the label. there are additional packages we could install that have the
24+
* capability, but that would bloat the package unnecessarily. instead, we're requiring that the label be passed. the overwhelming
25+
* majority of instances where a link is used, will want a label anyway. however, in the event a label isn't desired, passing the
26+
* value as an empty string will satisfy prop types, while still only showing an icon.
27+
*/
2028
Link.propTypes = {
2129
addClass: PropTypes.string,
2230
href: PropTypes.string.isRequired,
2331
icon: PropTypes.string,
24-
label: PropTypes.string,
32+
label: PropTypes.string.isRequired,
2533
style: PropTypes.shape({}),
2634
}
2735

2836
Link.defaultProps = {
2937
addClass: '',
3038
icon: '',
31-
label: '',
3239
style: {},
3340
}
3441

src/components/Link/Link.stories.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,26 @@ const Template = (args) => <Link {...args} />
1313

1414
export const Default = Template.bind({})
1515
Default.args = {
16-
href: '',
16+
href: '/',
1717
label: 'I am a link',
1818
style: {},
1919
}
2020

2121
export const Alternate = Template.bind({})
2222
Alternate.args = {
23-
href: '',
23+
href: '/',
24+
icon: 'fa-envelope',
2425
label: 'No underline!',
2526
style: {
2627
textDecoration: 'none',
2728
color: '#AB1289',
2829
},
29-
icon: 'fa-envelope',
30+
}
31+
32+
export const NoLabel = Template.bind({})
33+
NoLabel.args = {
34+
href: '/',
35+
icon: 'fa-download',
36+
label: '',
37+
style: {},
3038
}

src/compounds/LinkedButton/LinkedButton.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const ButtonLinkWrapper = React.forwardRef(({ ...props }, ref) => {
2525
const { addClass, buttonProps, href } = props
2626

2727
return (
28-
<a href={href} ref={ref} className={addClass}>
28+
<a href={href} ref={ref} className={addClass} data-cy='linked-button'>
2929
<Button {...buttonProps} />
3030
</a>
3131
)

0 commit comments

Comments
 (0)