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

[Playground] Code links #1167

Merged
merged 26 commits into from
Sep 13, 2024
Merged

[Playground] Code links #1167

merged 26 commits into from
Sep 13, 2024

Conversation

jamesnw
Copy link
Contributor

@jamesnw jamesnw commented Sep 5, 2024

Adds "Edit in Playground" link to each code example in the documentation. The link will reflect the selected syntax.

If there are multiple sections in the example, for instance in the Modules section, no link is shown. Those examples require importing and a file system, which isn't supported. I'm open to other behavior here if preferred.

Copy link

netlify bot commented Sep 5, 2024

Deploy Preview for sass-lang ready!

Name Link
🔨 Latest commit a0ece3d
🔍 Latest deploy log https://app.netlify.com/sites/sass-lang/deploys/66e394bbc101b7000830df0a
😎 Deploy Preview https://deploy-preview-1167--sass-lang.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@nex3
Copy link
Contributor

nex3 commented Sep 5, 2024

The functionality looks great, but I'm not sure about the styles. A few considerations that occur to me:

  • The link is so much darker than everything else in the page, it really stands out to me in a way that seems contrary to its purpose.
  • Since the focus of the examples and the user editing them is the Sass code, it seems like the playground link should be more visually associated with the source block than the output.
  • Although the playground doesn't have its own logo, it does have the Sass logo on screen at all times, so using that to visually identify the link with the playground page may be more immediately recognizable than pure text.

All that makes me think that something like this:

image

or even potentially like this:

image

would be a better fit.

As prior art here, this is what it looks like in the TypeScript documentation:

image

...where the "Try" button only shows up when the code is being hovered. I'd be fine with just copying that design as well.

Copy link
Contributor

@nex3 nex3 left a comment

Choose a reason for hiding this comment

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

Style looks good, except it would be nice to add a bit more space between the Sass logo and "Playground".

@@ -1,3 +1,3 @@
<li class="ui-tabs-tab{% if syntax == 'css' %} css-tab{% endif %}{% if enabled %} ui-tabs-active{% endif %}">
<li class="ui-tabs-tab{% if syntax == 'css' %} css-tab{% endif %}{% if enabled %} ui-tabs-active{% endif %}" data-syntax="{{ syntax }}">
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this data attribute for?

Copy link
Contributor

Choose a reason for hiding this comment

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

Outdated -- removed in 4612ff1

Comment on lines +343 to +344
scss: string[];
sass: string[];
Copy link
Contributor

Choose a reason for hiding this comment

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

These should both be | false to match the current semantics, although honestly I think null would be a better fit. I'm surprised tsc isn't complaining about this.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the type def for the input args, not the return value. Changed to null in 4612ff1

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see. In that case, this should have a return type 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in 2e22b0d.

@stacyk
Copy link
Contributor

stacyk commented Sep 9, 2024

Style looks good, except it would be nice to add a bit more space between the Sass logo and "Playground".

@nex3 I made a few updates here:

  • Added a small gap between the logo and Playground
  • Fixed bottom alignment (in some cases the links weren't touching the bottom of the panel)
  • The language tabs arrow pseudo elements were sitting under the panel after I added the relative position, so I bumped those up (to avoid the gray border overlapping the arrow)
    Screenshot 2024-09-09 at 2 15 10 PM

Comment on lines +343 to +344
scss: string[];
sass: string[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see. In that case, this should have a return type 🙂

@nex3 nex3 merged commit 0b88893 into sass:main Sep 13, 2024
9 checks passed
@jamesnw jamesnw deleted the code-links branch September 14, 2024 00:51
jgerigmeyer added a commit to oddbird/sass-site that referenced this pull request Sep 20, 2024
* main: (23 commits)
  [Playground] Click to Copy (sass#1177)
  Cut a release for a new Dart Sass version
  [Playground] Debug links (sass#1179)
  Add breaking change page for legacy-js-api (sass#1193)
  [Playground] Autocomplete (sass#1166)
  Add a breaking change page for color functions (sass#1192)
  Remove nonexisting `color.saturate()` function (sass#1190)
  Fix unprefixed `color.adjust()` name (sass#1188)
  Sort color functions alphabetically (sass#1187)
  Document color migrator (sass#1186)
  Cut a release for a new Dart Sass version
  Document new color spaces (sass#1055) (sass#1115)
  Cut a release for a new Dart Sass version
  Bump date-fns from 3.6.0 to 4.0.0 (sass#1181)
  Bump rollup from 4.21.2 to 4.21.3 (sass#1182)
  Bump @codemirror/autocomplete from 6.18.0 to 6.18.1 (sass#1183)
  Bump @typescript-eslint/eslint-plugin from 8.5.0 to 8.6.0 (sass#1185)
  Bump markdown-it-anchor from 9.1.0 to 9.2.0 (sass#1184)
  Fix footer not showing the latest versions. (sass#1178)
  [Playground] Code links (sass#1167)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants