Skip to content

Commit

Permalink
Use shoelace
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed Oct 24, 2024
1 parent 4095df4 commit 2eddaf4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 29 deletions.
16 changes: 1 addition & 15 deletions src/apps/illumination/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Revolutionary illumination / solar app</title>
<!-- <link rel="stylesheet" href="./src/index.css" /> -->
<script type="module" src="./index.ts"></script>

<style>
/* FIXME: move to default style */
html {
box-sizing: border-box;
}
*,
*::before,
*::after {
box-sizing: inherit;
}
body {
margin: 0;
}
</style>
<script type="module" src="./index.ts"></script>
</head>
<body>
<noscript>Enable JS!</noscript>
Expand Down
3 changes: 3 additions & 0 deletions src/structure/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* FIXME: include reset css */

@import url('@shoelace-style/shoelace/dist/themes/light.css');
2 changes: 2 additions & 0 deletions src/structure/ngv-structure-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {getLocale} from './helpers/localeHelper.js';
import './ngv-page.js';
import './ngv-structure-header.js';

import './index.css';

export interface INgvStructureApp {
languages: Locale[];
header: {
Expand Down
27 changes: 13 additions & 14 deletions src/structure/ngv-structure-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import {customElement, property} from 'lit/decorators.js';
import type {INgvStructureApp} from './ngv-structure-app.js';
import {getLocale, setLocale} from './helpers/localeHelper.js';

import '@shoelace-style/shoelace/dist/components/select/select.js';
import '@shoelace-style/shoelace/dist/components/option/option.js';
import type SlSelect from '@shoelace-style/shoelace/dist/components/select/select.js';

@customElement('ngv-structure-header')
export class NgvStructureHeader extends LitElement {
@property({type: Object})
Expand All @@ -19,28 +23,23 @@ export class NgvStructureHeader extends LitElement {
`;

render(): HTMLTemplateResult {
const currentLocale = getLocale();
return html`
<header>
<img src="${this.config.header.logo}" />
<div>
<label for="language">Lang:</label>
<select
name="language"
id="language"
@change=${async (evt: Event) => {
const el = evt.target as HTMLSelectElement;
const locale = this.config.languages[el.selectedIndex];
await setLocale(locale);
<sl-select
label="Language"
size="small"
value="${getLocale()}"
@sl-change=${async (evt: Event) => {
const el = evt.target as SlSelect;
await setLocale(el.value as string);
}}
>
${this.config.languages.map(
(l) =>
html`<option value="${l}" ?selected=${l === currentLocale}>
${l}
</option>`,
(l) => html`<sl-option value="${l}">${l}</sl-option>`,
)}
</select>
</sl-select>
</div>
</header>
`;
Expand Down

0 comments on commit 2eddaf4

Please sign in to comment.