feat(clock): implement clock app redesign with web components#663
feat(clock): implement clock app redesign with web components#663nicomiguelino wants to merge 9 commits intomasterfrom
Conversation
Create foundational structure for the clock app redesign with the same settings as the existing clock app. The new app uses the edge-apps-library and follows the QR Code app pattern for simplicity. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ponents Apply necessary changes to enable the clock app redesign based on #616: edge-apps-library changes: - Add web components: auto-scaler, app-header, brand-logo, dev-tools - Add Screenly Design System styles (base, tokens) - Add core utilities and component registration - Add weather icon mapping utilities - Add screen orientation detection utilities - Update package.json exports to include components, core, and styles - Update vite.config.ts output format to IIFE clock-new changes: - Implement clock app with <auto-scaler> and <app-header> web components - Use library utilities (getMetadata, getTimeZone, getLocale, formatTime, etc.) - Add weather integration with OpenWeatherMap API - Include Kelly Slab font and background image - Add all weather condition icons - Import Screenly Design System styles - Implement responsive design for portrait and landscape Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
…CSS to separate file - Remove --sourcemap flag from edge-apps-scripts build command (keep it in build:dev) - Add cssCodeSplit: false to vite.config.ts to extract CSS into dist/css/style.css - This fixes deployment issues where index.html references dist/css/style.css but it wasn't being generated - CSS was being inlined into JS, causing asset loading issues on Anywhere screens Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Change description from "Screenly Clock New Edge App" to "Screenly Clock Edge App" - Update icon path from clock-new to clock to match the deployed icon location Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add weather icon imports and temperature display handling. Hide weather section when API key is unavailable or API calls fail.
Add production and QC app IDs matching the clock app structure.
Remove old Vue-based clock app and replace with redesigned implementation using edge-apps-library web components. The new implementation uses edge-apps-scripts build system and includes weather integration with locale-aware temperature units.
XSS Security Review for PR #663SummaryNo XSS vulnerabilities found. The code follows secure patterns throughout. Safe Patterns Used1.
|
| File | Line | Usage |
|---|---|---|
edge-apps/clock/src/main.ts |
115 |
temperatureEl.textContent = \${currentTemp}°`` |
edge-apps/clock/src/main.ts |
145 |
timeEl.textContent = \${hour}:${minute}`` |
edge-apps/clock/src/main.ts |
149 | periodEl.textContent = timeData.dayPeriod |
edge-apps/clock/src/main.ts |
156 | dateEl.textContent = formatLocalizedDate(...) |
edge-apps/clock/src/main.ts |
178 | locationEl.textContent = locationName |
edge-apps/edge-apps-library/src/components/app-header/app-header.ts |
196, 208 | Time/date display |
edge-apps/edge-apps-library/src/components/brand-logo/brand-logo.ts |
152 | nameEl.textContent = screenName |
2. Build-time SVG imports
Weather icons in edge-apps/clock/src/weather-icons.ts are imported at build time, not fetched from untrusted sources.
3. Shadow DOM isolation
Web components (auto-scaler, app-header, brand-logo) use Shadow DOM, limiting scope of any potential issues.
Areas Reviewed
img.src assignments
| File | Line | Source | Risk |
|---|---|---|---|
edge-apps/clock/src/main.ts |
128 | WEATHER_ICONS[iconKey] (build-time import) |
None |
edge-apps/edge-apps-library/src/components/brand-logo/brand-logo.ts |
130 | setupBrandingLogo() from Screenly settings |
Low |
innerHTML usage
| File | Line | Source | Risk |
|---|---|---|---|
edge-apps/edge-apps-library/src/components/app-header/app-header.ts |
222 | Hardcoded template literal | None |
edge-apps/edge-apps-library/src/components/brand-logo/brand-logo.ts |
165 | Hardcoded template literal | None |
CSS property injection
| File | Lines | Source | Risk |
|---|---|---|---|
edge-apps/edge-apps-library/src/utils/theme.ts |
73-89 | Screenly settings (color values) | Very Low |
Optional Hardening Recommendations
- Validate that
screenly.settings.screenly_logo_*URLs match HTTP/HTTPS patterns before use - Validate color values match hex color patterns (e.g.,
/^#[0-9A-Fa-f]{6}$/)
Verdict
The PR is safe from XSS attacks. All dynamic content is handled using secure APIs (textContent, build-time imports, Shadow DOM isolation).
There was a problem hiding this comment.
Pull request overview
This PR implements a clock app redesign by creating a new clock-new app and introducing a comprehensive web components library for Edge Apps. The redesign moves away from Vue/Pinia architecture to vanilla TypeScript with custom web components, improving maintainability and reusability across Edge Apps.
Changes:
- Created web components library with auto-scaling, headers, and dev tools
- Implemented redesigned clock app with weather integration
- Added Screenly Design System with CSS tokens and base styles
Reviewed changes
Copilot reviewed 56 out of 85 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| edge-apps/edge-apps-library/src/components/auto-scaler/auto-scaler.ts | Auto-scaling web component for responsive layouts |
| edge-apps/edge-apps-library/src/components/app-header/app-header.ts | Header component with time/date display |
| edge-apps/edge-apps-library/src/components/brand-logo/brand-logo.ts | Logo component with fallback support |
| edge-apps/edge-apps-library/src/components/dev-tools/dev-tools.ts | Development overlay for debugging |
| edge-apps/edge-apps-library/src/core/index.ts | Helper function to initialize edge apps |
| edge-apps/edge-apps-library/src/utils/weather.ts | Weather icon mapping utilities |
| edge-apps/edge-apps-library/src/utils/screen.ts | Screen orientation detection |
| edge-apps/edge-apps-library/src/styles/* | Design system tokens and base styles |
| edge-apps/clock/src/main.ts | Redesigned clock app implementation |
| edge-apps/clock/src/css/style.css | Clock app styles with responsive design |
| edge-apps/clock/index.html | Declarative web component usage |
| edge-apps/clock/package.json | Updated dependencies and build scripts |
| edge-apps/clock/screenly.yml | Added OpenWeatherMap API configuration |
Comments suppressed due to low confidence (5)
edge-apps/edge-apps-library/src/utils/weather.ts:1
- The hardcoded hour values (5 and 20) for night determination should be extracted as named constants to improve code readability and maintainability. Consider defining
NIGHT_END_HOUR = 5andNIGHT_START_HOUR = 20at the module level.
edge-apps/edge-apps-library/src/components/auto-scaler/auto-scaler.ts:1 - Consider applying multiple style properties in a single operation using
Object.assign(this.style, {...})orthis.style.cssTextfor better performance and readability.
edge-apps/edge-apps-library/src/components/dev-tools/dev-tools.ts:1 - The localhost hostname checks could be extracted to a constant array for easier maintenance and potential extension. Consider defining
LOCALHOST_HOSTNAMES = ['localhost', '127.0.0.1']and usingLOCALHOST_HOSTNAMES.includes(window.location.hostname).
edge-apps/edge-apps-library/src/core/index.ts:1 - The
safeZoneparameter is marked as deprecated but there's no@deprecatedJSDoc tag. Add proper JSDoc deprecation notice to help developers understand this parameter should not be used.
edge-apps/edge-apps-library/src/components/app-header/app-header.ts:1 - The expression
(this._timeFormat !== '24h' && undefined)is confusing. If the intent is to pass undefined when format is not '24h', this could be simplified tothis._timeFormat === '12h' ? true : this._timeFormat === '24h' ? false : undefinedfor better clarity.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Extract inline validation logic to isValidWeatherResponse() with proper typing and documentation explaining why both number and string types are checked for the cod field.
…mponent Add z-index design tokens to centralize layering values across Edge Apps. Enhance brand-logo component to display brand name alongside logo with proper vertical alignment and spacing. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
e248be9 to
9c99c17
Compare
fa1bf5b to
9c99c17
Compare
User description
Summary
Implements the clock app redesign by creating a new
clock-newapp and integrating web components from #616 into the edge-apps-library.Changes
edge-apps-library:
auto-scaler,app-header,brand-logo,dev-toolscomponents,core, andstylespathsclock-new:
<auto-scaler>and<app-header>web componentsPR Type
Enhancement, Tests, Documentation
Description
Add Edge Apps web components suite
Introduce
initEdgeAppauto-scaling helperAdd screen/weather utilities and tests
Implement redesigned
clock-newsample appDiagram Walkthrough
File Walkthrough
14 files
Implement clock UI updates and weatherAdd redesigned clock styles and layoutUse declarative `` and headerAdd scalable container web componentAdd header component with time/dateAdd branding logo component with fallbackAdd dev overlay reacting to scaleExport components and side-effect registrationCentralize component registration side-effectsAdd `initEdgeApp` to compose componentsAdd weather icon mapping helpersAdd orientation detection utilitiesLazy-load geocoding to reduce bundlingRe-export utils, core, components, types4 files
Add build/dev scripts and workspace dependencyAdd manifest and configurable app settingsExport `components`, `core`, and `styles`Switch library build output to IIFE1 files
Document app usage, settings, development1 files
Add unit tests for screen utilities16 files