Skip to content

Commit

Permalink
feat(Ad): Add DOM button to export PDF
Browse files Browse the repository at this point in the history
closes #384
  • Loading branch information
bamdadfr committed Apr 17, 2024
1 parent 1aa5a4a commit ca38c20
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/app/content.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import {getState, StateType} from './state/get-state';
import {getState} from './state/get-state';
import {initializeState} from './state/initialize-state';
import {setState, StateKeys} from './state/set-state';
import {Ad} from './ad/ad';
import {addContentButton} from './utils/add-content-button';

/**
* Content script entry point.
*
* @returns {Promise<StateType>} - The state of the extension.
*/
export async function content(): Promise<StateType> {
export async function content(): Promise<void> {
await initializeState();
const state = await getState();

Expand All @@ -22,7 +18,7 @@ export async function content(): Promise<StateType> {
}
}

return state;
addContentButton();
}

window.addEventListener('load', content);
16 changes: 16 additions & 0 deletions src/app/utils/add-content-button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {StateKeys, setState} from '../state/set-state';

export function addContentButton() {
const container = document.querySelector('.mt-xl');
const button = document.createElement('button');
button.id = 'export';
button.textContent = 'Export PDF';
button.className =
'u-shadow-border-transition box-border inline-flex items-center justify-center gap-md whitespace-nowrap px-lg text-body-1 font-bold focus-visible:outline-none focus-visible:u-ring [&:not(:focus-visible)]:ring-inset bg-transparent border-sm border-current min-w-sz-44 h-sz-44 rounded-lg hover:bg-support/dim-5 enabled:active:bg-support/dim-5 focus-visible:bg-support/dim-5 text-support w-full';

button.onclick = async () => {
await setState(StateKeys.isTriggered, true);
};

container.appendChild(button);
}

0 comments on commit ca38c20

Please sign in to comment.