Skip to content

Commit b9df791

Browse files
Pask00oliverdunk
andauthored
Fix #1084: quick-api-reference sample (#1099)
* Add README.md * Fix issue related to website update Updated CSS selector and tweaked the TIP button * Update content.js Keeping newline * Update CSS styles Change padding, height and font sizes to make the button style more consistent with the navigation bar * Update functional-samples/tutorial.quick-api-reference/content.js * Update functional-samples/tutorial.quick-api-reference/README.md * Update functional-samples/tutorial.quick-api-reference/README.md --------- Co-authored-by: Oliver Dunk <[email protected]>
1 parent 72eb0a4 commit b9df791

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Tutorial: Handling events
2+
3+
This sample demonstrates how to handle events with service workers.
4+
5+
## Overview
6+
7+
The extension built allows users to quickly navigate to Chrome API reference pages using the omnibox.
8+
9+
The events from the following APIs have been handled: `chrome.runtime`, `chrome.omnibox` and `chrome.alarms`.
10+
11+
The complete tutorial is available [here](https://developer.chrome.com/docs/extensions/get-started/tutorial/service-worker-events).
12+
13+
## Running this extension
14+
15+
1. Clone this repository.
16+
2. Load this directory in Chrome as an [unpacked extension](https://developer.chrome.com/docs/extensions/mv3/getstarted/development-basics/#load-unpacked).
17+
3. Type "api" in the omnibox followed by tab or space and select a suggestion.
18+
4. Click on "Tip" button in the navigation bar.

functional-samples/tutorial.quick-api-reference/content.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
// Popover API https://chromestatus.com/feature/5463833265045504
22

33
(async () => {
4-
const nav = document.querySelector('.navigation-rail__links');
4+
const nav = document.querySelector('.upper-tabs > nav');
55

66
const { tip } = await chrome.runtime.sendMessage({ greeting: 'tip' });
77

88
const tipWidget = createDomElement(`
9-
<button class="navigation-rail__link" popovertarget="tip-popover" popovertargetaction="show" style="padding: 0; border: none; background: none;>
10-
<div class="navigation-rail__icon">
11-
<svg class="icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="24" height="24" viewBox="0 0 24 24" fill="none">
12-
<path d='M15 16H9M14.5 9C14.5 7.61929 13.3807 6.5 12 6.5M6 9C6 11.2208 7.2066 13.1599 9 14.1973V18.5C9 19.8807 10.1193 21 11.5 21H12.5C13.8807 21 15 19.8807 15 18.5V14.1973C16.7934 13.1599 18 11.2208 18 9C18 5.68629 15.3137 3 12 3C8.68629 3 6 5.68629 6 9Z'"></path>
13-
</svg>
14-
</div>
15-
<span>Tip</span>
9+
<button type="button" popovertarget="tip-popover" popovertargetaction="show" style="padding: 0 12px; height: 36px;">
10+
<span style="display: block; font: var(--devsite-link-font,500 14px/20px var(--devsite-primary-font-family));">Tip</span>
1611
</button>
1712
`);
1813

1914
const popover = createDomElement(
20-
`<div id='tip-popover' popover>${tip}</div>`
15+
`<div id='tip-popover' popover style="margin: auto;">${tip}</div>`
2116
);
2217

2318
document.body.append(popover);

0 commit comments

Comments
 (0)