-
Notifications
You must be signed in to change notification settings - Fork 59
feat(snippets): show/hide link functionality #430
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
Conversation
🦋 Changeset detectedLatest commit: c2da4c4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for stacks-editor ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
|
||
| let toggleContainer: HTMLDivElement; | ||
|
|
||
| if (this.snippetMetadata.hide === "true") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches current functionality. Out of scope for this PR, but I wonder if we could improve on what's here by always showing the show/hide accordian rather than keying it off of the snippet config (and instead setting the default based on that config value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also thought this behavior was interesting but I spoke to @KyleMit and it seems like users want to be able to control how the final post will look and if the snippet will have a show/hide link above it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what @threefjefff is still inline with my use cases (although agreed this matches existing behavior). It wouldn't bug me if the link to be able to show/hide was always visible, but the default respected the value set by the config in the post.
That way OP has first say in whether it should be collapsed or visible, but users could also quickly collapse existing snippets in answers
threefjefff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@threefjefff Can you please take a look at the failing test and see if it has something to do with what I changed? I can't seem to figure it out |
No, this is happening on my local machine too, but the new snippets icon is acting the same for me locally. @dancormier any idea why the stacks icon is not rendering correctly? |
|
@alizaberger I'm looking into the icon issue. In the meantime, can you provide instructions on how to test this functionality? |
|
@alizaberger the editor relies on CSS definitions for icons (as opposed to importing SVGs), and only a small subset of icons are included in the icons CSS (see also https://github.com/StackExchange/Stacks-Icons/blob/production/README.md#using-the-css-icons). To use this icon, I suggest importing the icon needed in src/styles/icons.css like this: …
.svg-icon-bg.iconArrowDownSm {
--bg-icon: url("~@stackoverflow/stacks-icons/src/Icon/ArrowDownSm.svg");
}
… |
@dancormier In the snippets preview paste a valid snippet in markdown mode, with the hide param set to true. This should enable the show/hide link for the snippet in rich text mode |
dancormier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes @alizaberger. I noticed a minor styling issue and have suggested some changes. Other than that minor issue, this is good to go from my perspective
Co-authored-by: Dan Cormier <dancormierall@gmail.com>
Co-authored-by: Dan Cormier <dancormierall@gmail.com>



Jira issue
Describe your changes
Adds a "Show/Hide" link to toggle the visibility of code snippets (not the results pane) in the StackSnippetView. This corresponds to how snippets preview worked in the old editor. The link is only rendered when the hide attribute is "true".
PR Checklist
/** ... */docsbug/enhancementand other labels as appropriateEnvironment(s) tested
Additional context
TODO: Need to add the same functionality to the preview pane in the MD+P mode.