File tree 7 files changed +43
-3
lines changed
app/components/code-capture
7 files changed +43
-3
lines changed Original file line number Diff line number Diff line change 3
3
import useStore from "@/lib/store/store" ;
4
4
import WindowContent from "./preview/window-content" ;
5
5
import WindowHeader from "./preview/window-header" ;
6
+ import { cn } from "@/lib/utils" ;
7
+ import CodeImageLoadingSkelton from "./preview/code-image-loading-skelton" ;
6
8
7
9
export default function CodeImagePreview ( ) {
8
10
const windowWidth = useStore ( ( state ) => state . windowWidth ) ;
11
+ const isEditorMounted = useStore ( ( state ) => state . isEditorMounted ) ;
9
12
10
13
return (
11
14
< div className = "preview items-center py-3 px-4 flex flex-col w-full rounded-md bg-[#191919]" >
12
15
< div className = "preview-box w-full mt-40" >
13
16
{ /* frame */ }
14
17
< div
15
- className = "frame mx-auto max-w-full bg-gradient-to-tr to-purple-600 from-blue-400 rounded-md px-4 py-4"
18
+ className = { cn (
19
+ "frame mx-auto max-w-full bg-gradient-to-tr to-purple-600 from-blue-400 rounded-md px-8 py-8" ,
20
+ ! isEditorMounted && "hidden"
21
+ ) }
16
22
style = { {
17
- width : windowWidth + 32 ,
23
+ width : windowWidth + 8 * 4 * 2 ,
18
24
} }
19
25
>
20
26
< div
@@ -28,6 +34,8 @@ export default function CodeImagePreview() {
28
34
< WindowContent />
29
35
</ div >
30
36
</ div >
37
+
38
+ { ! isEditorMounted && < CodeImageLoadingSkelton /> }
31
39
</ div >
32
40
</ div >
33
41
) ;
Original file line number Diff line number Diff line change
1
+ export default function CodeImageLoadingSkelton ( ) {
2
+ return (
3
+ < div
4
+ className = "frame mx-auto max-w-full rounded-md px-4 py-4"
5
+ style = { {
6
+ width : 400 + 32 ,
7
+ } }
8
+ >
9
+ < div
10
+ className = "window flex flex-col border rounded-md border-[#82738E] min-h-40"
11
+ style = { {
12
+ width : 400 ,
13
+ } }
14
+ > </ div >
15
+ </ div >
16
+ ) ;
17
+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export default function MonacoEditor() {
14
14
const changeWindowWidth = useStore ( ( state ) => state . changeWindowWidth ) ;
15
15
16
16
const editorTheme = useStore ( ( state ) => state . editorTheme ) ;
17
+ const changeEditorMounted = useStore ( ( state ) => state . changeEditorMounted ) ;
17
18
18
19
const editorLanguage = useStore ( ( state ) => state . editorLanguage ) ;
19
20
@@ -40,6 +41,7 @@ export default function MonacoEditor() {
40
41
}` }
41
42
theme = "vs-dark"
42
43
onMount = { ( editor ) => {
44
+ changeEditorMounted ( true ) ;
43
45
editorRef . current = editor ;
44
46
updateEditorWindowTheme ( editorTheme ) ;
45
47
} }
Original file line number Diff line number Diff line change
1
+ import CodeImageSlice from "@/lib/types/store/slices/code-image-slice" ;
2
+ import { SetState } from "@/lib/types/store/store" ;
3
+
4
+ export default function createCodeImageSlice ( set : SetState ) : CodeImageSlice {
5
+ return { } ;
6
+ }
Original file line number Diff line number Diff line change 1
1
import EditorSlice from "@/lib/types/store/slices/editor-slice" ;
2
2
import { SetState } from "@/lib/types/store/store" ;
3
3
4
- export default function createEditorSlice ( set : SetState ) : EditorSlice {
4
+ export default function createEditorSlice ( set : SetState ) : EditorSlice {
5
5
return {
6
6
editorTheme : "Night Owl" ,
7
7
changeEditorTheme : ( theme ) =>
@@ -22,5 +22,8 @@ export default function createEditorSlice(set : SetState): EditorSlice {
22
22
set ( ( ) => ( {
23
23
editorThemeColors : themeColors ,
24
24
} ) ) ,
25
+
26
+ isEditorMounted : false ,
27
+ changeEditorMounted : ( value ) => set ( ( ) => ( { isEditorMounted : value } ) ) ,
25
28
} ;
26
29
}
Original file line number Diff line number Diff line change
1
+ export default interface CodeImageSlice { }
Original file line number Diff line number Diff line change @@ -11,4 +11,7 @@ export default interface EditorSlice {
11
11
12
12
editorThemeColors : EditorThemeColors ;
13
13
changeEditorThemeColors : ( themeColors : EditorThemeColors ) => void ;
14
+
15
+ isEditorMounted : boolean ,
16
+ changeEditorMounted : ( value : boolean ) => void ,
14
17
}
You can’t perform that action at this time.
0 commit comments