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

feat: createContentScriptUi helper #143

Merged
merged 7 commits into from
Oct 1, 2023
Merged

Conversation

aklinker1
Copy link
Collaborator

@aklinker1 aklinker1 commented Sep 30, 2023

This closes #139. See demo project for example usage:

const ui = await createContentScriptUi(ctx, {
name: 'demo-ui',
type: 'inline',
append: 'before',
anchor: 'form[role=search]',
mount: (uiContainer) => {
const app = document.createElement('div');
app.textContent = 'Custom content script UI';
uiContainer.append(app);
},
});
ui.mount();
setTimeout(ui.remove, 5000);

Todo

  • Basic implementation
  • Unit test createContentScriptUi
  • Automatically add cssInjectionMode: !"manifest" content script CSS files to manifest web_accessible_resources
  • Only add styles if cssInjectionMode: "ui"
  • Add inline docs to all the new functions and types

@netlify
Copy link

netlify bot commented Sep 30, 2023

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 8b3601f
🔍 Latest deploy log https://app.netlify.com/sites/creative-fairy-df92c4/deploys/6518de9904a10f0008c3c327
😎 Deploy Preview https://deploy-preview-143--creative-fairy-df92c4.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.

@codecov
Copy link

codecov bot commented Oct 1, 2023

Codecov Report

Merging #143 (8b3601f) into main (61e57b7) will increase coverage by 0.80%.
The diff coverage is 99.51%.

@@            Coverage Diff             @@
##             main     #143      +/-   ##
==========================================
+ Coverage   84.45%   85.26%   +0.80%     
==========================================
  Files          52       61       +9     
  Lines        3995     4615     +620     
  Branches      366      426      +60     
==========================================
+ Hits         3374     3935     +561     
- Misses        621      680      +59     
Files Coverage Δ
src/client/createContentScriptUi.ts 100.00% <100.00%> (ø)
src/client/index.ts 100.00% <100.00%> (ø)
src/client/utils/ContentScriptContext.ts 74.73% <100.00%> (ø)
src/core/types/external.ts 100.00% <100.00%> (ø)
src/core/utils/manifest.ts 71.84% <100.00%> (+4.28%) ⬆️
vitest.setup.ts 100.00% <100.00%> (ø)
src/core/server.ts 22.14% <66.66%> (+1.55%) ⬆️

... and 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@aklinker1 aklinker1 marked this pull request as ready for review October 1, 2023 02:51
@aklinker1 aklinker1 merged commit 4150e42 into main Oct 1, 2023
@aklinker1 aklinker1 deleted the mount-content-script-ui branch October 1, 2023 02:57
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.

Builtin util for mounting UI's in content scripts.
1 participant