File tree 9 files changed +54
-17
lines changed
9 files changed +54
-17
lines changed Original file line number Diff line number Diff line change 5
5
}
6
6
7
7
.ch-scrollycoding-content {
8
- width : 50% ;
9
8
box-sizing : border-box ;
10
9
padding-right : 16px ;
10
+ flex : 1 ;
11
11
}
12
12
13
13
.ch-scrollycoding-step-content {
39
39
align-self : start ;
40
40
flex-flow : column ;
41
41
justify-content : center ;
42
- width : 420px ;
42
+ width : var ( --ch-scrollycoding-sticker-width , 420px ) ;
43
43
// capitalized Min to avoid usint the sass min
44
44
// min-height: Min(100%, 80vh);
45
45
max-height : 80vh ;
66
66
.ch-codegroup {
67
67
width : 100% ;
68
68
min-width : 100% ;
69
- min-height : 200px ;
69
+ min-height : var (
70
+ --ch-scrollycoding-code-min-height ,
71
+ 200px
72
+ );
70
73
max-height : 80vh ;
71
74
margin-top : 0 ;
72
75
margin-bottom : 0 ;
Original file line number Diff line number Diff line change 15
15
16
16
& > * {
17
17
height : 100% ;
18
+ max-height : inherit ;
19
+ min-height : inherit ;
18
20
}
19
21
}
20
22
Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ type CodeHikeConfig = {
16
16
lineNumbers ?: boolean
17
17
}
18
18
19
- export function remarkCodeHike ( config : CodeHikeConfig ) {
19
+ export function remarkCodeHike (
20
+ unsafeConfig : CodeHikeConfig
21
+ ) {
20
22
return async ( tree : Node ) => {
21
23
// TODO add opt-in config
22
24
let hasCodeHikeImport = false
@@ -30,6 +32,8 @@ export function remarkCodeHike(config: CodeHikeConfig) {
30
32
}
31
33
} )
32
34
35
+ const config = addConfigDefaults ( unsafeConfig )
36
+
33
37
addConfig ( tree as Parent , config )
34
38
35
39
if ( ! hasCodeHikeImport ) {
@@ -52,6 +56,12 @@ export function remarkCodeHike(config: CodeHikeConfig) {
52
56
}
53
57
}
54
58
59
+ function addConfigDefaults (
60
+ config : Partial < CodeHikeConfig > | undefined
61
+ ) : CodeHikeConfig {
62
+ return { ...config , theme : config ?. theme || { } }
63
+ }
64
+
55
65
function addConfig ( tree : Parent , config : CodeHikeConfig ) {
56
66
tree . children . unshift ( {
57
67
type : "mdxjsEsm" ,
Original file line number Diff line number Diff line change @@ -57,8 +57,6 @@ export const EditorFrame = React.forwardRef<
57
57
} ,
58
58
ref
59
59
) {
60
- const c = useClasser ( "ch-editor" )
61
-
62
60
return (
63
61
< div
64
62
ref = { ref }
@@ -185,7 +183,7 @@ function TabsContainer({
185
183
} }
186
184
onClick = { onTabClick && ( ( ) => onTabClick ( title ) ) }
187
185
>
188
- < div > { title } </ div >
186
+ < TabTitle title = { title } / >
189
187
</ div >
190
188
) ) }
191
189
< div style = { { flex : 1 } } />
@@ -194,6 +192,23 @@ function TabsContainer({
194
192
)
195
193
}
196
194
195
+ function TabTitle ( { title } : { title : string } ) {
196
+ if ( ! title ) {
197
+ return < div />
198
+ }
199
+
200
+ const separatorIndex = title . lastIndexOf ( "/" ) + 1
201
+ const filename = title . substring ( separatorIndex )
202
+ const folder = title . substring ( 0 , separatorIndex )
203
+
204
+ return (
205
+ < div >
206
+ < span style = { { opacity : 0.5 } } > { folder } </ span >
207
+ { filename }
208
+ </ div >
209
+ )
210
+ }
211
+
197
212
type TabsSnapshot = Record <
198
213
string ,
199
214
{ left : number ; active : boolean ; width : number }
Original file line number Diff line number Diff line change 6
6
import { TerminalPanel } from "./terminal-panel"
7
7
import { useTransition , EditorStep } from "./editor-shift"
8
8
import { CodeConfig } from "@code-hike/smooth-code"
9
+ import { useLayoutEffect } from "@code-hike/utils"
9
10
10
11
export {
11
12
EditorTransition ,
@@ -14,11 +15,6 @@ export {
14
15
EditorTweenProps ,
15
16
}
16
17
17
- const useLayoutEffect =
18
- typeof window !== "undefined"
19
- ? React . useLayoutEffect
20
- : React . useEffect
21
-
22
18
type EditorTransitionProps = {
23
19
prev ?: EditorStep
24
20
next ?: EditorStep
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ div#__next > div {
10
10
flex-direction : column;
11
11
font-family : sans-serif;
12
12
background-color : # 444 ;
13
+ /* --ch-scrollycoding-code-min-height: 500px;
14
+ --ch-scrollycoding-sticker-width: 500px; */
13
15
}
14
16
15
17
nav {
Original file line number Diff line number Diff line change 3
3
FocusString ,
4
4
getFocusIndexes ,
5
5
Tween ,
6
+ useLayoutEffect ,
6
7
} from "@code-hike/utils"
7
8
8
9
type Dimensions = {
@@ -16,11 +17,6 @@ type Dimensions = {
16
17
lineNumberWidth : number
17
18
} | null
18
19
19
- const useLayoutEffect =
20
- typeof window !== "undefined"
21
- ? React . useLayoutEffect
22
- : React . useEffect
23
-
24
20
export { useDimensions , Dimensions }
25
21
26
22
const DEFAULT_WIDTH = 200
Original file line number Diff line number Diff line change
1
+ import React from "react"
2
+
3
+ export const useLayoutEffect =
4
+ typeof window !== "undefined"
5
+ ? React . useLayoutEffect
6
+ : React . useEffect
7
+
8
+ // for debugging:
9
+ // export const useLayoutEffect = (
10
+ // effect: any,
11
+ // deps?: any
12
+ // ) => {}
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ export * from "./tween"
2
2
export * from "./code"
3
3
export * from "./focus"
4
4
export * from "./theme"
5
+ export * from "./hooks"
You can’t perform that action at this time.
0 commit comments