Skip to content

Commit

Permalink
Create a stub web component for the locale picker
Browse files Browse the repository at this point in the history
Refs #2044
  • Loading branch information
thewilkybarkid committed Oct 25, 2024
1 parent 915a8f5 commit b0f9f5c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions assets/locale-picker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class LocalePicker extends HTMLElement {
static element = 'locale-picker' as const
}

window.customElements.define(LocalePicker.element, LocalePicker)
11 changes: 8 additions & 3 deletions src/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ export function page({
),
)}
${scripts.map(file => html` <script src="${assets[file].path}" type="module"></script>`)}
${canChooseLocale === true
? html`<script src="${assets['locale-picker.js'].path}" type="module"></script>`
: ''}}
${typeof fathomId === 'string'
? html` <script src="https://cdn.usefathom.com/script.js" data-site="${fathomId}" defer></script>`
: ''}
Expand Down Expand Up @@ -313,9 +316,11 @@ export function page({
<div>
<p>Choose your language:</p>
<ul>
<li><a href="#">English</a></li>
</ul>
<locale-picker>
<ul>
<li><a href="#">English</a></li>
</ul>
</locale-picker>
</div>
`
: ''}
Expand Down
1 change: 1 addition & 0 deletions webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = (env, argv) => ({
'favicon.ico': path.resolve('assets', 'favicon.ico'),
'favicon.svg': path.resolve('assets', 'favicon.svg'),
'html-editor': path.resolve('assets', 'html-editor.ts'),
'locale-picker': path.resolve('assets', 'locale-picker.ts'),
'notification-banner': path.resolve('assets', 'notification-banner.ts'),
'poll-redirect': path.resolve('assets', 'poll-redirect.ts'),
'single-use-form': path.resolve('assets', 'single-use-form.ts'),
Expand Down

0 comments on commit b0f9f5c

Please sign in to comment.