Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0002042

Browse files
committed
load styles in webview
1 parentb38e406 commit0002042

File tree

5 files changed

+41
-30
lines changed

5 files changed

+41
-30
lines changed

‎src/editor/ReactWebView.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import*asvscodefrom'vscode'
2-
import*asCRfrom'typings'
31
import*aspathfrom'path'
2+
import*asCRfrom'typings'
3+
import*asvscodefrom'vscode'
44

55
/**
66
* Manages React webview panels
@@ -71,7 +71,7 @@ class ReactWebView {
7171
if(callback){
7272
// listen for when webview is loaded
7373
// unfortunately there is no easy way of doing this
74-
letwebPanelListener=setInterval(()=>{
74+
constwebPanelListener=setInterval(()=>{
7575
if(this.loaded){
7676
setTimeout(callback)
7777
clearInterval(webPanelListener)
@@ -80,6 +80,27 @@ class ReactWebView {
8080
}
8181
}
8282

83+
publicasyncpostMessage(action:CR.Action):Promise<void>{
84+
// Send a message to the webview webview.
85+
// You can send any JSON serializable data.
86+
constsuccess=awaitthis.panel.webview.postMessage(action)
87+
if(!success){
88+
thrownewError(`Message post failure:${JSON.stringify(action)}`)
89+
}
90+
}
91+
92+
publicdispose():void{
93+
// Clean up our resources
94+
this.panel.dispose()
95+
96+
while(this.disposables.length){
97+
constx=this.disposables.pop()
98+
if(x){
99+
x.dispose()
100+
}
101+
}
102+
}
103+
83104
privatecreateWebviewPanel(column:number):vscode.WebviewPanel{
84105
constviewType='CodeRoad'
85106
consttitle='CodeRoad'
@@ -103,27 +124,6 @@ class ReactWebView {
103124
returntext
104125
}
105126

106-
publicasyncpostMessage(action:CR.Action):Promise<void>{
107-
// Send a message to the webview webview.
108-
// You can send any JSON serializable data.
109-
constsuccess=awaitthis.panel.webview.postMessage(action)
110-
if(!success){
111-
thrownewError(`Message post failure:${JSON.stringify(action)}`)
112-
}
113-
}
114-
115-
publicdispose():void{
116-
// Clean up our resources
117-
this.panel.dispose()
118-
119-
while(this.disposables.length){
120-
constx=this.disposables.pop()
121-
if(x){
122-
x.dispose()
123-
}
124-
}
125-
}
126-
127127
privategetHtmlForWebview():string{
128128
// eslint-disable-next-line
129129
constmanifest=require(path.join(this.extensionPath,'build','asset-manifest.json'))
@@ -151,6 +151,8 @@ class ReactWebView {
151151
<meta name="theme-color" content="#000000">
152152
<title>React App</title>
153153
<link rel="manifest" href="./manifest.json" />
154+
<!-- TODO: load styles through package -->
155+
<link rel="stylesheet" href="https://unpkg.com/@alifd/next/dist/next.css" />
154156
<link rel="stylesheet" type="text/css" href="${styleUri}">
155157
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src vscode-resource: https:; script-src 'nonce-${n1}' 'nonce-${n2}' 'nonce-${n3}'; style-src vscode-resource: 'unsafe-inline' http: https: data:;">
156158
<base href="${vscode.Uri.file(path.join(this.extensionPath,'build')).with({

‎web-app/.storybook/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import'@alifd/next/dist/next.css'
1+
//import '@alifd/next/dist/next.css'
22
import{configure}from'@storybook/react'
33
import'../src/styles/index.css'
44

‎web-app/src/Routes.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
import*asReactfrom'react'
22

3-
importLoadingfrom'./components/Loading'
43
importCondfrom'./components/Cond'
5-
importNewPagefrom'./containers/New'
4+
importLoadingfrom'./components/Loading'
65
importContinuePagefrom'./containers/Continue'
6+
importNewPagefrom'./containers/New'
77
importTutorialPagefrom'./containers/Tutorial'
88

99
interfaceProps{
1010
state:any
1111
}
1212

13+
conststyles={
14+
page:{
15+
width:window.innerWidth,
16+
height:window.innerHeight,
17+
backgroundColor:'white',
18+
},
19+
}
20+
1321
constRoutes=({ state}:Props)=>{
1422
// TODO: refactor cond to user <Router><Route> and accept first route as if/else if
1523
return(
16-
<div>
24+
<divstyle={styles.page}>
1725
<Condstate={state}path="SelectTutorial.Startup">
1826
<Loading/>
1927
</Cond>

‎web-app/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
importReactDOMfrom'react-dom'
33
importAppfrom'./App'
44

5+
// base styles
56
import'./styles/index.css'
67

78
ReactDOM.render(<App/>,document.getElementById('root')asHTMLElement)

‎web-app/stories/Stage.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ function someExample(a) {
3838
`,
3939
},
4040
hints:[],
41-
status:{active:false,complete:true},
41+
status:{active:true,complete:false},
4242
},
4343
step3Id:{
4444
content:{
4545
title:'Divide',
4646
text:'Write a function `divide` that divides',
4747
},
4848
hints:[],
49-
status:{active:true,complete:false},
49+
status:{active:false,complete:false},
5050
},
5151
})}
5252
stage={object('stage',demo.data.stages.stage1Id)}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp