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

Commit42719d0

Browse files
authored
Merge pull requestcoderoad#102 from ShMcK/feature/notify
Icons, Fonts & Notifications
2 parentsbac9dc8 +be1e1db commit42719d0

34 files changed

+461
-156
lines changed

‎package-lock.json

Lines changed: 0 additions & 23 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"build":"rm -rf build && npm run build:ext && npm run build:web",
2121
"build:ext":"tsc -p ./",
2222
"build:web":"cd web-app && npm run build",
23-
"postbuild:web":"cp -R ./web-app/build/ ./build/",
23+
"postbuild:web":"cp -R ./web-app/build/ ./build/ && node scripts/fixFontPaths.js",
2424
"postinstall":"node ./node_modules/vscode/bin/install",
2525
"lint":"eslint src/**/*ts",
2626
"machine":"node ./out/state/index.js",
@@ -41,7 +41,6 @@
4141
"@types/assert":"^1.4.5",
4242
"@types/chokidar":"^2.1.3",
4343
"@types/dotenv":"^8.2.0",
44-
"@types/glob":"^7.1.1",
4544
"@types/jest":"^25.1.1",
4645
"@types/jsdom":"^12.2.4",
4746
"@types/node":"^13.5.3",

‎resources/public/favicon.ico

-3.78 KB
Binary file not shown.

‎resources/public/index.html

Lines changed: 0 additions & 40 deletions
This file was deleted.

‎resources/public/manifest.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

‎scripts/fixFontPaths.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* css url font paths do not match up from the web-app as it is moved inside of build
3+
* in order to load fonts and icons, these paths must be reconciled.
4+
*/
5+
constfs=require('fs')// eslint-disable-line
6+
7+
// find the generated main css file
8+
constgetMainCSSFile=()=>{
9+
constregex=/^main.[a-z0-9]+.chunk.css$/
10+
constmainCss=fs.readdirSync('build/static/css').filter(filename=>filename.match(regex))
11+
if(!mainCss.length){
12+
thrownewError('No main.css file found in build/static/css')
13+
}
14+
returnmainCss[0]
15+
}
16+
17+
// remap the font paths from the borken /fonts/ => ../../fonts/
18+
constremapFontPaths=()=>{
19+
constmainCSSFile=getMainCSSFile()
20+
constfile=fs.readFileSync(`build/static/css/${mainCSSFile}`,'utf8')
21+
constfontUrlRegex=/url\(\/fonts\//g
22+
constremappedFile=file.replace(fontUrlRegex,'url(../../fonts/')
23+
fs.writeFileSync(`build/static/css/${mainCSSFile}`,remappedFile)
24+
}
25+
26+
remapFontPaths()

‎src/editor/commands.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,11 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
5757
testRunner=createTestRunner(config,{
5858
onSuccess:(payload:Payload)=>{
5959
// send test pass message back to client
60-
notify({message:'PASS'})
6160
webview.send({type:'TEST_PASS', payload})
62-
// update local storage
6361
},
6462
onFail:(payload:Payload,message:string)=>{
65-
// send test fail message back to client
66-
notify({message:`FAIL${message}`})
67-
webview.send({type:'TEST_FAIL', payload})
63+
// send test fail message back to client with failure message
64+
webview.send({type:'TEST_FAIL',payload:{ ...payload, message}})
6865
},
6966
onError:(payload:Payload)=>{
7067
// send test error message back to client

‎tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
"allowJs":true,
2626
"removeComments":true
2727
},
28-
"exclude": ["node_modules",".vscode-test","build","resources","web-app","*.js","*.test.ts"]
28+
"exclude": ["node_modules",".vscode-test","build","resources","web-app","*.js","*.test.ts","scripts"]
2929
}

‎typings/index.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ export interface ErrorMessage {
4242
description?:string
4343
}
4444

45+
exportinterfaceTestStatus{
46+
type:'success'|'warning'|'error'|'loading'
47+
title:string
48+
content?:string
49+
}
50+
4551
exportinterfaceMachineContext{
4652
env:Environment
4753
error:ErrorMessage|null
4854
tutorial:G.Tutorial|null
4955
position:Position
5056
progress:Progress
5157
processes:ProcessEvent[]
58+
testStatus:TestStatus|null
5259
}
5360

5461
exportinterfaceMachineEvent{
@@ -83,7 +90,6 @@ export interface MachineStateSchema {
8390
TestRunning:{}
8491
TestPass:{}
8592
TestFail:{}
86-
TestError:{}
8793
StepNext:{}
8894
LevelComplete:{}
8995
}

‎web-app/config-overrides.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
2-
constpath=require('path')
3-
const{ addBabelPreset, addBabelPlugin, addWebpackModuleRule}=require('customize-cra')
2+
const{ addBabelPreset, addWebpackModuleRule, addBabelPlugin}=require('customize-cra')
43

54
module.exports=functionoverride(config){
65
addWebpackModuleRule({

‎web-app/src/Routes.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const Routes = () => {
2323
<Routepath={['Start.LoadTutorialSummary','Start.LoadTutorialData','Start.SetupNewTutorial']}>
2424
<LoadingPagetext="Loading Tutorial..."context={context}/>
2525
</Route>
26-
<Routepath={'Start.Error'}>
26+
<Routepath="Start.Error">
2727
<LoadingPagetext="Error"context={context}/>
2828
</Route>
2929
<Routepath="Start.SelectTutorial">
@@ -32,11 +32,11 @@ const Routes = () => {
3232
<Routepath="Start.Summary">
3333
<OverviewPagesend={send}context={context}/>
3434
</Route>
35-
<Routepath="SetupNewTutorial">
35+
<Routepath="Start.SetupNewTutorial">
3636
<LoadingPagetext="Configuring tutorial..."context={context}/>
3737
</Route>
3838
{/* Tutorial */}
39-
<Routepath="Tutorial.LoadNext">
39+
<Routepath={['Tutorial.LoadNext','Tutorial.Level.Load']}>
4040
<LoadingPagetext="Loading Level..."context={context}/>
4141
</Route>
4242
<Routepath="Tutorial.Level">

‎web-app/src/components/Button/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@ interface Props {
77
disabled?:boolean
88
type?:'primary'|'secondary'|'normal'
99
onClick?:()=>void
10+
size?:'small'|'medium'|'large'
11+
iconSize?:'xxs'|'xs'|'small'|'medium'|'large'|'xl'|'xxl'|'xxxl'
1012
}
1113

1214
constButton=(props:Props)=>(
13-
<AlifdButtononClick={props.onClick}type={props.type}disabled={props.disabled}style={props.style}>
15+
<AlifdButton
16+
onClick={props.onClick}
17+
type={props.type}
18+
disabled={props.disabled}
19+
style={props.style}
20+
size={props.size}
21+
iconSize={props.iconSize}
22+
>
1423
{props.children}
1524
</AlifdButton>
1625
)
Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
import*asReactfrom'react'
2-
import{css,jsx}from'@emotion/core'
3-
4-
conststyles={
5-
box:{
6-
display:'flex',
7-
alignItems:'center',
8-
justifyContent:'center',
9-
},
10-
input:{
11-
border:'1px solid black',
12-
},
13-
loading:{
14-
backgroundColor:'red',
15-
},
16-
}
2+
import{CheckboxasAlifdCheckbox}from'@alifd/next'
173

184
interfaceProps{
195
status:'COMPLETE'|'INCOMPLETE'|'ACTIVE'
@@ -26,13 +12,7 @@ const Checkbox = (props: Props) => {
2612

2713
constchecked=props.status==='COMPLETE'
2814

29-
return(
30-
<divcss={styles.box}>
31-
<label>
32-
<inputcss={styles.input}type="checkbox"checked={checked}onChange={onChange}/>
33-
</label>
34-
</div>
35-
)
15+
return<AlifdCheckboxchecked={checked}onChange={onChange}/>
3616
}
3717

3818
exportdefaultCheckbox

‎web-app/src/components/Message/index.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,35 @@ import { Message as AlifdMessage } from '@alifd/next'
22
import*asReactfrom'react'
33

44
interfaceProps{
5-
type:'error'
5+
type?:'success'|'warning'|'error'|'notice'|'help'|'loading'
6+
shape?:'inline'|'addon'|'toast'
7+
size?:'medium'|'large'
68
title:string
7-
description?:string
9+
content?:string
10+
closed?:boolean
11+
closeable?:boolean
12+
onClose?:()=>void
13+
handleClose?:()=>void
814
}
915

1016
constMessage=(props:Props)=>{
17+
const[visible,setVisible]=React.useState(true)
18+
functiononClose(){
19+
if(props.onClose){
20+
props.onClose()
21+
}
22+
setVisible(false)
23+
}
1124
return(
12-
<AlifdMessagetype={props.type}title={props.title}>
13-
{props.description}
25+
<AlifdMessage
26+
type={props.type}
27+
visible={props.closed ?!props.closed :visible}
28+
title={props.title}
29+
closeable={props.closeable}
30+
onClose={onClose}
31+
shape={props.shape}
32+
>
33+
{props.content}
1434
</AlifdMessage>
1535
)
1636
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
importMessagefrom'../Message'
2+
import*asReactfrom'react'
3+
import*asTfrom'typings'
4+
import{css,jsx}from'@emotion/core'
5+
6+
constdurations={
7+
success:1000,
8+
warning:4500,
9+
error:4500,
10+
loading:300000,
11+
}
12+
13+
constuseTimeout=({ duration, key}:{duration:number;key:string})=>{
14+
const[timeoutClose,setTimeoutClose]=React.useState(false)
15+
React.useEffect(()=>{
16+
setTimeoutClose(false)
17+
consttimeout=setTimeout(()=>{
18+
setTimeoutClose(true)
19+
},duration)
20+
return()=>{
21+
clearTimeout(timeout)
22+
}
23+
},[key])
24+
returntimeoutClose
25+
}
26+
27+
constTestMessage=(props:T.TestStatus)=>{
28+
constduration=durations[props.type]
29+
consttimeoutClose=useTimeout({ duration,key:props.title})
30+
return(
31+
<Message
32+
key={props.title}
33+
type={props.type}
34+
title={props.title}
35+
closed={timeoutClose}
36+
size="medium"
37+
closeable={props.type!=='loading'}
38+
content={props.content}
39+
/>
40+
)
41+
}
42+
43+
exportdefaultTestMessage

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp