Compare commits

...

2 Commits

Author SHA1 Message Date
Bauke ee70b18781
Add a Using Bangs section. 2022-10-07 18:38:42 +02:00
Bauke 6ba718de35
Add a test link for bangs. 2022-10-07 18:38:28 +02:00
2 changed files with 40 additions and 2 deletions

View File

@ -1,4 +1,8 @@
import {ConfirmButton, FeedbackButton} from '@holllo/preact-components'; import {
ConfirmButton,
FeedbackButton,
PrivacyLink,
} from '@holllo/preact-components';
import {html} from 'htm/preact'; import {html} from 'htm/preact';
import {Component} from 'preact'; import {Component} from 'preact';
import browser from 'webextension-polyfill'; import browser from 'webextension-polyfill';
@ -189,6 +193,18 @@ export class PageMain extends Component<Props, State> {
? undefined ? undefined
: html`<p class="validate-error">${editorError}</p>`; : html`<p class="validate-error">${editorError}</p>`;
const testLinkAttributes: Record<string, any> = {
class: 'button',
};
if (this.state.editorBang.searchUrl.includes('{{bang}}')) {
testLinkAttributes.href = this.state.editorBang.searchUrl.replace(
/{{bang}}/g,
'test',
);
} else {
testLinkAttributes.disabled = true;
}
return html` return html`
<main class="page-main"> <main class="page-main">
<details open class="bang-editor"> <details open class="bang-editor">
@ -198,6 +214,7 @@ export class PageMain extends Component<Props, State> {
${editorInputs} ${editorInputs}
<div class="button-group"> <div class="button-group">
<${PrivacyLink} attributes=${testLinkAttributes}>Test<//>
<${FeedbackButton} <${FeedbackButton}
attributes=${{class: 'button'}} attributes=${{class: 'button'}}
click=${this.saveBang} click=${this.saveBang}
@ -266,6 +283,20 @@ export class PageMain extends Component<Props, State> {
button. button.
</li> </li>
</ul> </ul>
<p>Using Bangs:</p>
<ul>
<li>
Once you have a Bang with a valid Search Link, the "Test" button
will be enabled. Clicking on that will take you to your Search
Link with "test" as the search query.
</li>
<li>On the DuckDuckGo website, use your custom Bangs directly.</li>
<li>
With DuckDuckGo set as your browser's default search engine, use
your custom Bangs in the address bar.
</li>
</ul>
</details> </details>
</main> </main>
`; `;

View File

@ -50,6 +50,8 @@
cursor: pointer; cursor: pointer;
font-weight: bold; font-weight: bold;
padding: 8px; padding: 8px;
text-align: center;
text-decoration: none;
width: 100%; width: 100%;
&.destructive { &.destructive {
@ -57,7 +59,12 @@
border-color: var(--da-1); border-color: var(--da-1);
} }
&:hover { &[disabled] {
cursor: not-allowed;
filter: grayscale(1);
}
&:not([disabled]):hover {
background-color: var(--df-2); background-color: var(--df-2);
border-color: var(--df-2); border-color: var(--df-2);
} }