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

Add optional filename prop for CodeSnippet #216

Merged
merged 4 commits into from
Jun 22, 2020

Conversation

timglaser
Copy link
Contributor

@timglaser timglaser commented Jun 22, 2020

Description

Adds ability to create display the filename for a markdown CodeSnippet component by adding fileName=src/example/filename.js to the prop definition line.

Truncates the filename in the middle if it is too long to fit in the copy bar.

Reviewer Notes

You can see the truncation by going to the guides/example page and changing the browser width.

Related Issue(s) / Ticket(s)

Screenshot(s)

Screen Shot 2020-06-22 at 1 35 40 PM

<div className={styles.fileName}>
{fileName && (
<MiddleEllipsis>
<span title={fileName}>{fileName}</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, do we have any kind of UX figured out where a user could see the full path? If the value ends up truncated, it might be a bit frustrating if they want to get some context on the full file path.

Copy link
Contributor

Choose a reason for hiding this comment

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

I should have looked at the preview before saying anything. It looks like MiddleEllipsis adds a title attribute which addresses my concern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rational for adding the title attribute to the span was to, at least on desktop browsers, make it possible to see the full path even if it is truncated. Beyond that, no, not yet. It'd be great to have a more robust solution that also supports copying.

@timglaser timglaser merged commit 2097c52 into master Jun 22, 2020
@timglaser timglaser deleted the tglaser/codesnippet-filename branch June 22, 2020 20:58
@nr-opensource-bot
Copy link
Contributor

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants