chore: P0 skeleton
Bootstrap the Dashward repo per arch/UBUNTU-DASHBOARD-SPACE.md: - pnpm-workspaces monorepo (sdk, extension, container, widgets-builtin/*) - GNOME extension stub (metadata.json, src/*.ts placeholders for warden, guard, supervisor, entry UX, DBus service) - WebKit container stub (GJS main + page-side runtime + dashboard.html) - TypeScript widget SDK (defineWidget + types) - Builtin clock widget as the first SDK consumer example - DBus interface XML (proto/shell.iface.xml) and shared types - esbuild configs for extension and container; tsc for SDK - Design doc copied in at repo root for discoverability No functional logic yet -- all components are placeholders that compose in extension.ts so the build chain can be exercised. P1 (workspace warden) starts next. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
41
extension/widgets-builtin/clock/src/index.ts
Normal file
41
extension/widgets-builtin/clock/src/index.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { defineWidget } from '@dashward/widget-sdk';
|
||||
|
||||
interface ClockConfig {
|
||||
hour12: boolean;
|
||||
showSeconds: boolean;
|
||||
}
|
||||
|
||||
export default defineWidget<ClockConfig>({
|
||||
id: 'clock',
|
||||
defaultConfig: { hour12: false, showSeconds: true },
|
||||
|
||||
mount(host, { config, lifecycle, system }) {
|
||||
const root = host.element.attachShadow({ mode: 'open' });
|
||||
root.innerHTML = `
|
||||
<style>
|
||||
:host { display: grid; place-items: center; }
|
||||
.time { font: 600 clamp(2rem, 8vw, 5rem) ui-sans-serif, system-ui; }
|
||||
:host([data-theme="dark"]) .time { color: #f0f0f0; }
|
||||
</style>
|
||||
<div class="time"></div>
|
||||
`;
|
||||
const el = root.querySelector('.time') as HTMLDivElement;
|
||||
|
||||
const render = () => {
|
||||
const cfg = config.get();
|
||||
el.textContent = new Date().toLocaleTimeString(undefined, {
|
||||
hour12: cfg.hour12,
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: cfg.showSeconds ? '2-digit' : undefined,
|
||||
});
|
||||
};
|
||||
|
||||
const timer = setInterval(render, 1000);
|
||||
render();
|
||||
lifecycle.onUnmount(() => clearInterval(timer));
|
||||
|
||||
config.onChange(render);
|
||||
system.onThemeChange(t => (host.element.dataset.theme = t));
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user