Skip to content

Commit

Permalink
Add support for nested bold hostname in popup string (#64)
Browse files Browse the repository at this point in the history
Adds support for nested bold hostname in popup string. 

<img width="350" alt="Screenshot 2024-09-20 at 7 04 53 PM"
src="https://github.com/user-attachments/assets/5dfc230b-4fa4-4ddd-90e5-48361085a429">
  • Loading branch information
lesleyjanenorton committed Sep 23, 2024
1 parent 2d80597 commit 278c24c
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/ui/browserAction/popupPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,23 @@ export class BrowserActionPopup extends LitElement {
this.currentSiteContext = new_cntxt;
};

const getExclusionStringElem = (origin) => {
const originPlaceholder = "dummyString";
const localizedString = tr("exludePageFor", originPlaceholder);
// Create a new <p> element
const el = document.createElement("p");

// Replace "dummyString" with <span>origin</span>
const parts = localizedString.split(originPlaceholder);
return html`
<p>
${parts.at(0)}
<span class="bold">${origin}</span>
${parts.at(-1)}
</p>
`;
};

return BrowserActionPopup.sitePreferencesTemplate(
this.currentSiteContext,
this.openServerList.bind(this),
Expand All @@ -180,7 +197,8 @@ export class BrowserActionPopup extends LitElement {
return Utils.nameFor(ctx.countryCode, ctx.cityCode, this.servers);
},
resetSitePreferences,
this._siteContext !== null
this._siteContext !== null,
getExclusionStringElem
);
}

Expand Down Expand Up @@ -218,7 +236,8 @@ export class BrowserActionPopup extends LitElement {
return "";
},
removeSiteContext = () => {},
hasSiteContext = false
hasSiteContext = false,
getExclusionStringElem = () => {}
) {
const pageLocationPicker = (() => {
if (siteContext.excluded) {
Expand Down Expand Up @@ -255,7 +274,7 @@ export class BrowserActionPopup extends LitElement {
?checked=${siteContext.excluded}
@click=${toggleExcluded}
/>
<p>${tr("exludePageFor", siteContext.origin)}</p>
${getExclusionStringElem(siteContext.origin)}
</div>
${pageLocationPicker}
${hasSiteContext
Expand Down

0 comments on commit 278c24c

Please sign in to comment.