dart-lang / site-www

Source for Dart website
https://dart.dev
Other
936 stars 675 forks source link

Support specifying attributes to DartPad #5884

Closed parlough closed 1 month ago

parlough commented 1 month ago

Enables the mechanism for adding a title attribute to DartPad code blocks.

```dartpad run="true" title="The classic hello world program in Dart!" theme="dark"
void main() {
  print('Hello world!');
}


Contributes to https://github.com/dart-lang/site-www/issues/5251

@atsansone After this lands, feel free to add titles to the embedded DartPads. I'd be happy to review!
dart-github-bot commented 1 month ago

Visit the preview URL for this PR (updated for commit 42287eccdfa0e41f815b9fbccba7ea5e34f9a0dc):

https://dart-dev--pr5884-feat-support-specifiying-dartpad-attr-sv5ci0mm.web.app

parlough commented 1 month ago

Thanks for the review and questions @atsansone!

  1. Why do we not set height on DartPad includes any more?

The new embed mechanism hasn't supported it, so removing the mentions to avoid misconceptions that it is supported. A lot of them time, they run-dartpad portions were copied from elsewhere without paying too much attention I think. If there's a strong desire to bring height adjustment back, open an issue, and I can definitely do so!

  1. Why default to light theme?

That's just what we've always done for embeds since the site body is light theme. Then in codelabs, dark theme indicates it's a conclusion exercise.