@@ -25,12 +25,18 @@ const defaultPrConfig = {
2525const defaultCommitMessage = 'chore: sync editor updates from @knighted/develop'
2626
2727const supportedRenderModes = new Set ( [ 'dom' , 'react' ] )
28+ const supportedStyleModes = new Set ( [ 'css' , 'module' , 'less' , 'sass' ] )
2829
2930const normalizeRenderMode = value => {
3031 const mode = toSafeText ( value ) . toLowerCase ( )
3132 return supportedRenderModes . has ( mode ) ? mode : 'dom'
3233}
3334
35+ const normalizeStyleMode = value => {
36+ const mode = toSafeText ( value ) . toLowerCase ( )
37+ return supportedStyleModes . has ( mode ) ? mode : 'css'
38+ }
39+
3440const getRepositoryPrConfigStorageKey = repositoryFullName =>
3541 `${ prConfigStoragePrefix } ${ repositoryFullName } `
3642
@@ -133,6 +139,7 @@ const getActiveRepositoryPrContext = repositoryFullName => {
133139 componentFilePath : componentFilePath . value ,
134140 stylesFilePath : stylesFilePath . value ,
135141 renderMode : normalizeRenderMode ( savedConfig . renderMode ) ,
142+ styleMode : normalizeStyleMode ( savedConfig . styleMode ) ,
136143 prTitle,
137144 prBody : typeof savedConfig . prBody === 'string' ? savedConfig . prBody : '' ,
138145 baseBranch,
@@ -395,13 +402,15 @@ export const createGitHubPrDrawer = ({
395402 getStylesSource,
396403 getTopLevelDeclarations,
397404 getRenderMode,
405+ getStyleMode,
398406 getDrawerSide,
399407 confirmBeforeSubmit,
400408 onPullRequestOpened,
401409 onPullRequestCommitPushed,
402410 onActivePrContextChange,
403411 onSyncActivePrEditorContent,
404412 onRestoreRenderMode,
413+ onRestoreStyleMode,
405414} ) => {
406415 if ( ! featureEnabled ) {
407416 toggleButton ?. setAttribute ( 'hidden' , '' )
@@ -548,6 +557,19 @@ export const createGitHubPrDrawer = ({
548557 onRestoreRenderMode ( mode )
549558 }
550559
560+ const emitStyleModeRestore = activeContext => {
561+ if ( typeof onRestoreStyleMode !== 'function' ) {
562+ return
563+ }
564+
565+ if ( ! activeContext ) {
566+ return
567+ }
568+
569+ const mode = normalizeStyleMode ( activeContext ?. styleMode )
570+ onRestoreStyleMode ( mode )
571+ }
572+
551573 const emitActivePrContextChange = ( ) => {
552574 if ( typeof onActivePrContextChange !== 'function' ) {
553575 return
@@ -556,6 +578,7 @@ export const createGitHubPrDrawer = ({
556578 const activeContext = getCurrentActivePrContext ( )
557579 onActivePrContextChange ( activeContext )
558580 emitRenderModeRestore ( activeContext )
581+ emitStyleModeRestore ( activeContext )
559582 }
560583
561584 const setStatus = ( text , level = 'neutral' ) => {
@@ -762,6 +785,7 @@ export const createGitHubPrDrawer = ({
762785 ...savedConfig ,
763786 isActivePr : true ,
764787 renderMode : normalizeRenderMode ( savedConfig . renderMode ) ,
788+ styleMode : normalizeStyleMode ( savedConfig . styleMode ) ,
765789 headBranch : nextHeadBranch ,
766790 baseBranch : nextBaseBranch ,
767791 pullRequestNumber : resolvedPullRequest . number ,
@@ -1061,6 +1085,7 @@ export const createGitHubPrDrawer = ({
10611085
10621086 const values = getFormValues ( )
10631087 const currentRenderMode = normalizeRenderMode ( getRenderMode ?. ( ) )
1088+ const currentStyleMode = normalizeStyleMode ( getStyleMode ?. ( ) )
10641089 const existingConfig = readRepositoryPrConfig ( repositoryFullName )
10651090 const isActivePr = existingConfig ?. isActivePr === true
10661091
@@ -1078,6 +1103,7 @@ export const createGitHubPrDrawer = ({
10781103 ? existingConfig . stylesFilePath
10791104 : values . stylesFilePath ,
10801105 renderMode : currentRenderMode ,
1106+ styleMode : currentStyleMode ,
10811107 isActivePr : true ,
10821108 pullRequestNumber : existingConfig ?. pullRequestNumber ,
10831109 pullRequestUrl : existingConfig ?. pullRequestUrl ,
@@ -1099,6 +1125,7 @@ export const createGitHubPrDrawer = ({
10991125 prTitle : values . prTitle ,
11001126 prBody : values . prBody ,
11011127 renderMode : currentRenderMode ,
1128+ styleMode : currentStyleMode ,
11021129 isActivePr : false ,
11031130 pullRequestNumber : existingConfig ?. pullRequestNumber ,
11041131 pullRequestUrl : existingConfig ?. pullRequestUrl ,
@@ -1199,6 +1226,7 @@ export const createGitHubPrDrawer = ({
11991226 : ''
12001227 : values . prBody
12011228 const currentRenderMode = normalizeRenderMode ( getRenderMode ?. ( ) )
1229+ const currentStyleMode = normalizeStyleMode ( getStyleMode ?. ( ) )
12021230 const targetComponentPathValue = isPushCommitMode
12031231 ? activeContext ?. componentFilePath
12041232 : values . componentFilePath
@@ -1348,6 +1376,7 @@ export const createGitHubPrDrawer = ({
13481376 componentFilePath : componentPathValidation . value ,
13491377 stylesFilePath : stylesPathValidation . value ,
13501378 renderMode : currentRenderMode ,
1379+ styleMode : currentStyleMode ,
13511380 baseBranch : targetBaseBranch ,
13521381 headBranch : targetHeadBranch ,
13531382 prTitle : targetPrTitle ,
0 commit comments