Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(AlbumDetails): Extract urls from comments and link them to their corresponding sites - #1053 #1570

Conversation

pavithranair
Copy link

Closes #1053

Description: Detect URLs from the comment body and link them to their respective site.

Changes: URL-detection in javascript clientside with regex and styled the links

image
When the user hovers over the links, the color changes.
image

Signed-off-by: Pavithra Nair <pmpavithranair@gmail.com>
Signed-off-by: Pavithra Nair <pmpavithranair@gmail.com>
@@ -112,15 +117,32 @@ const AlbumComment = ({ record }) => {
const classes = useStyles()
const [expanded, setExpanded] = React.useState(false)

const reqClassName = classes.externalLinks
console.log(reqClassName)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this log still needed? If it was just for debugging during development, I suggest to clean it up and prevent collecting clutter in the console panel 🧹

/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi
return text.replace(urlRegex, function (url) {
return (
'<a class=' + reqClassName + ' href="' + url + '">' + url + '</a>'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the vanilla anchor tag works, but to ensure continuity in how links appear and behave (e.g. :visited), I think a <Link> component without extra styles in this file. I would like to test this out, but at the moment I am not finished with setting up the linting stuff in my dev-environment.

More about accessibility in links: https://www.smashingmagazine.com/2021/12/designing-better-links-websites-emails-guideline/#link-accessibility

@rombat
Copy link

rombat commented Jun 10, 2022

You can also use the WWW/URL tag (depending on format), that would be interesting

deluan added a commit that referenced this pull request Oct 7, 2022
Simple approach, may be extended/enhanced in the future.
@deluan
Copy link
Member

deluan commented Oct 7, 2022

I've finished this up in c530ccf. Thanks for your effort!

@deluan deluan closed this Oct 7, 2022
@github-actions
Copy link

github-actions bot commented Mar 8, 2023

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extract urls from comments and link them to their correspoding sites
5 participants