File tree Expand file tree Collapse file tree 5 files changed +21
-7
lines changed
public/components/views/home/report
src/http-server/endpoints Expand file tree Collapse file tree 5 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,8 @@ const ui = {
135135 form : {
136136 title : "Report title" ,
137137 includesAllDeps : "Include all dependencies" ,
138+ dark_theme : "Dark theme" ,
139+ light_theme : "Light theme" ,
138140 submit : "Generate"
139141 }
140142 }
Original file line number Diff line number Diff line change @@ -135,6 +135,8 @@ const ui = {
135135 form : {
136136 title : "Titre du rapport" ,
137137 includesAllDeps : "Inclure toutes les dépendances" ,
138+ dark_theme : "Thème sombre" ,
139+ light_theme : "Thème clair" ,
138140 submit : "Générer"
139141 }
140142 }
Original file line number Diff line number Diff line change @@ -11,19 +11,24 @@ export class PopupReport {
1111 /** @type {HTMLElement } */
1212 const clone = templateElement . content . cloneNode ( true ) ;
1313 const form = clone . querySelector ( "form" ) ;
14+ const isLightPreference = window . matchMedia && window . matchMedia ( "(prefers-color-scheme: light)" ) . matches ;
15+ form . querySelector ( "#lightTheme" ) . checked = isLightPreference ;
16+ form . querySelector ( "#darkTheme" ) . checked = ! isLightPreference ;
1417 clone . querySelector ( "#title" ) . placeholder = `${ this . rootDependencyName } 's report` ;
1518 form . addEventListener ( "submit" , ( e ) => {
1619 e . preventDefault ( ) ;
1720
1821 form . querySelector ( ".spinner" ) . classList . remove ( "hidden" ) ;
1922 const title = form . querySelector ( "#title" ) . value ;
23+ const theme = form . querySelector ( "#lightTheme" ) . checked ? "light" : "dark" ;
2024 const includesAllDeps = form . querySelector ( "#includesAllDeps" ) . checked ;
2125
2226 fetch ( "/report" , {
2327 method : "POST" ,
2428 body : JSON . stringify ( {
2529 title,
26- includesAllDeps
30+ includesAllDeps,
31+ theme
2732 } ) ,
2833 headers : {
2934 "Content-Type" : "application/json"
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import { bodyParser } from "../bodyParser.js";
1111
1212// TODO: provide a non-file-based API on RC side ?
1313const kReportPayload = {
14- theme : "light" ,
1514 includeTransitiveInternal : false ,
1615 reporters : [
1716 "pdf"
@@ -47,8 +46,7 @@ const kReportPayload = {
4746
4847export async function post ( req , res ) {
4948 const body = await bodyParser ( req ) ;
50- const { title, includesAllDeps } = body ;
51-
49+ const { title, includesAllDeps, theme } = body ;
5250 const { dataFilePath } = context . getStore ( ) ;
5351 const scannerPayload = JSON . parse ( fs . readFileSync ( dataFilePath , "utf-8" ) ) ;
5452 const reportPayload = kReportPayload ;
@@ -59,7 +57,8 @@ export async function post(req, res) {
5957 npm : {
6058 organizationPrefix : repo === undefined ? null : organizationPrefixOrRepo ,
6159 packages : [ repo === undefined ? organizationPrefixOrRepo : repo ]
62- }
60+ } ,
61+ theme
6362 } ) ;
6463
6564 try {
Original file line number Diff line number Diff line change @@ -320,12 +320,18 @@ <h2><i class="icon-keyboard"></i>[[=z.token('settings.shortcuts.title')]]</h2>
320320 < form action ="">
321321 < label for ="title "> [[=z.token('popup.report.form.title')]]</ label >
322322 < input type ="text " id ="title " name ="title " required >
323-
324323 < div >
325324 < input type ="checkbox " id ="includesAllDeps " name ="includesAllDeps " checked >
326325 < label for ="includesAllDeps "> [[=z.token('popup.report.form.includesAllDeps')]]</ label >
327326 </ div >
328-
327+ < div >
328+ < input type ="radio " id ="darkTheme " name ="theme " value ="dark " />
329+ < label for ="darkTheme "> [[=z.token('popup.report.form.dark_theme')]]</ label >
330+ </ div >
331+ < div >
332+ < input type ="radio " id ="lightTheme " name ="theme " value ="light " />
333+ < label for ="dewey "> [[=z.token('popup.report.form.light_theme')]]</ label >
334+ </ div >
329335 < button type ="submit ">
330336 < span class ="spinner hidden "> </ span > [[=z.token('popup.report.form.submit')]]
331337 </ button >
You can’t perform that action at this time.
0 commit comments