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

Fixes #5244 Add examples component #5463

Merged
merged 20 commits into from
Aug 23, 2024
Merged

Fixes #5244 Add examples component #5463

merged 20 commits into from
Aug 23, 2024

Conversation

muuki88
Copy link
Contributor

@muuki88 muuki88 commented Jun 27, 2024

Adds a new include that replaces JS Fiddle.

🏷 Type of documentation

  • new bid adapter
  • update bid adapter
  • new feature
  • text edit only (wording, typos)
  • bugfix (code examples)
  • new examples

📋 Checklist

Usage

<!-- storing the code inside a variable makes it a lot more readable -->
{% capture htmlCode %}<h4>Hello world</h4>
<div id="ad-slot" class="border border-info bg-white mb-2" style="height:250px; width: 300px">Ad Slot</div>
<button type="button" class="btn btn-primary" onclick="exampleFunction()">Interactive</button>
{% endcapture %}

{% capture jsCode %}console.log('hello world');
function exampleFunction() { 
  alert('hey there'); 
}
{% endcapture %}

{% include code/web-example.html id="hello-world" html=htmlCode js=jsCode %}

See the demo page on how it works and looks like.
https://deploy-preview-5463--prebid-docs-preview.netlify.app/docs-examples/web-example.html

Copy link

netlify bot commented Jun 27, 2024

Deploy Preview for prebid-docs-preview ready!

Name Link
🔨 Latest commit 85277f4
🔍 Latest deploy log https://app.netlify.com/sites/prebid-docs-preview/deploys/66c756cee2cd200008d36255
😎 Deploy Preview https://deploy-preview-5463--prebid-docs-preview.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.

@muuki88
Copy link
Contributor Author

muuki88 commented Jul 11, 2024

Add a separate info box in the example layout that explains that the js code can be put anywhere (head, script tag, external script)

@muuki88
Copy link
Contributor Author

muuki88 commented Jul 11, 2024

@muuki88
Copy link
Contributor Author

muuki88 commented Jul 18, 2024

Feedback

  • add a better distinction between the result and the rest of the page
  • add required javascript tags (prebid, gpt.js, ...) to the html and not the outer page

@muuki88
Copy link
Contributor Author

muuki88 commented Jul 22, 2024

Check the debugging module if there are some examples that could benefit as well:
https://docs.prebid.org/dev-docs/modules/debugging.html

@muuki88
Copy link
Contributor Author

muuki88 commented Aug 15, 2024

All Feedback implemented.

  • source tab that shows the full html source code along with the required scripts necessary
  • make the example code more visible

- id: unique id for the example
- html: html code snippet
- js: js code snippet
- scripts: a commad separate list of required scripts. Allowed values are pbjs,gpt,astjs . default is pbjs,ast
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the scripts include an example can specify the scripts required for this example. I chose a sensible default that most examples use

Comment on lines +63 to +66
{% assign scripts = include.scripts | split: "," %}{% for script in scripts %}{% if script == "pbjs" %}&lt;script async src=&quot;https://cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js&quot;&gt;&lt;/script&gt;
{% elsif script == "gpt" %}&lt;script async src=&quot;https://securepubads.g.doubleclick.net/tag/js/gpt.js&quot;&gt;&lt;/script&gt;
{% elsif script == "astjs" %}&lt;script async src=&quot;https://acdn.adnxs.com/ast/ast.js&quot;&gt;&lt;/script&gt;{% else %}&lt;!-- unknown script tag '{{ script }}' required --&gt;{% endif %}{% else %}&lt;script async src=&quot;//cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js&quot;&gt;&lt;/script&gt;
&lt;script async src=&quot;https://securepubads.g.doubleclick.net/tag/js/gpt.js&quot;&gt;&lt;/script&gt;{% endfor %}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This looks ugly in code, but nicer on the page: a lot less whitespace

{% endcapture %}

{% include code/web-example.html id="basic-prebid-example" html=htmlCodePrebid js=jsCode scripts="pbjs,astjs" %}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's an example for a different scripts attribute

@muuki88 muuki88 requested review from bretg and ChrisHuie and removed request for bretg August 22, 2024 14:31
@muuki88
Copy link
Contributor Author

muuki88 commented Aug 22, 2024

@ChrisHuie you are a master 🙏

@ChrisHuie ChrisHuie merged commit 58b1799 into master Aug 23, 2024
5 checks passed
@ChrisHuie ChrisHuie deleted the jsfiddle branch August 23, 2024 02:46
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.

Rework examples, migrate to new GAM instance & rethink JSFiddle
2 participants