File tree Expand file tree Collapse file tree 9 files changed +54
-17
lines changed Expand file tree Collapse file tree 9 files changed +54
-17
lines changed Original file line number Diff line number Diff line change 55}
66
77.ch-scrollycoding-content {
8- width : 50% ;
98 box-sizing : border-box ;
109 padding-right : 16px ;
10+ flex : 1 ;
1111}
1212
1313.ch-scrollycoding-step-content {
3939 align-self : start ;
4040 flex-flow : column ;
4141 justify-content : center ;
42- width : 420px ;
42+ width : var ( --ch-scrollycoding-sticker-width , 420px ) ;
4343 // capitalized Min to avoid usint the sass min
4444 // min-height: Min(100%, 80vh);
4545 max-height : 80vh ;
6666 .ch-codegroup {
6767 width : 100% ;
6868 min-width : 100% ;
69- min-height : 200px ;
69+ min-height : var (
70+ --ch-scrollycoding-code-min-height ,
71+ 200px
72+ );
7073 max-height : 80vh ;
7174 margin-top : 0 ;
7275 margin-bottom : 0 ;
Original file line number Diff line number Diff line change 1515
1616 & > * {
1717 height : 100% ;
18+ max-height : inherit ;
19+ min-height : inherit ;
1820 }
1921}
2022
Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ type CodeHikeConfig = {
1616 lineNumbers ?: boolean
1717}
1818
19- export function remarkCodeHike ( config : CodeHikeConfig ) {
19+ export function remarkCodeHike (
20+ unsafeConfig : CodeHikeConfig
21+ ) {
2022 return async ( tree : Node ) => {
2123 // TODO add opt-in config
2224 let hasCodeHikeImport = false
@@ -30,6 +32,8 @@ export function remarkCodeHike(config: CodeHikeConfig) {
3032 }
3133 } )
3234
35+ const config = addConfigDefaults ( unsafeConfig )
36+
3337 addConfig ( tree as Parent , config )
3438
3539 if ( ! hasCodeHikeImport ) {
@@ -52,6 +56,12 @@ export function remarkCodeHike(config: CodeHikeConfig) {
5256 }
5357}
5458
59+ function addConfigDefaults (
60+ config : Partial < CodeHikeConfig > | undefined
61+ ) : CodeHikeConfig {
62+ return { ...config , theme : config ?. theme || { } }
63+ }
64+
5565function addConfig ( tree : Parent , config : CodeHikeConfig ) {
5666 tree . children . unshift ( {
5767 type : "mdxjsEsm" ,
Original file line number Diff line number Diff line change @@ -57,8 +57,6 @@ export const EditorFrame = React.forwardRef<
5757 } ,
5858 ref
5959) {
60- const c = useClasser ( "ch-editor" )
61-
6260 return (
6361 < div
6462 ref = { ref }
@@ -185,7 +183,7 @@ function TabsContainer({
185183 } }
186184 onClick = { onTabClick && ( ( ) => onTabClick ( title ) ) }
187185 >
188- < div > { title } </ div >
186+ < TabTitle title = { title } / >
189187 </ div >
190188 ) ) }
191189 < div style = { { flex : 1 } } />
@@ -194,6 +192,23 @@ function TabsContainer({
194192 )
195193}
196194
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+
197212type TabsSnapshot = Record <
198213 string ,
199214 { left : number ; active : boolean ; width : number }
Original file line number Diff line number Diff line change 66import { TerminalPanel } from "./terminal-panel"
77import { useTransition , EditorStep } from "./editor-shift"
88import { CodeConfig } from "@code-hike/smooth-code"
9+ import { useLayoutEffect } from "@code-hike/utils"
910
1011export {
1112 EditorTransition ,
@@ -14,11 +15,6 @@ export {
1415 EditorTweenProps ,
1516}
1617
17- const useLayoutEffect =
18- typeof window !== "undefined"
19- ? React . useLayoutEffect
20- : React . useEffect
21-
2218type EditorTransitionProps = {
2319 prev ?: EditorStep
2420 next ?: EditorStep
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ div#__next > div {
1010 flex-direction : column;
1111 font-family : sans-serif;
1212 background-color : # 444 ;
13+ /* --ch-scrollycoding-code-min-height: 500px;
14+ --ch-scrollycoding-sticker-width: 500px; */
1315}
1416
1517nav {
Original file line number Diff line number Diff line change 33 FocusString ,
44 getFocusIndexes ,
55 Tween ,
6+ useLayoutEffect ,
67} from "@code-hike/utils"
78
89type Dimensions = {
@@ -16,11 +17,6 @@ type Dimensions = {
1617 lineNumberWidth : number
1718} | null
1819
19- const useLayoutEffect =
20- typeof window !== "undefined"
21- ? React . useLayoutEffect
22- : React . useEffect
23-
2420export { useDimensions , Dimensions }
2521
2622const 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"
22export * from "./code"
33export * from "./focus"
44export * from "./theme"
5+ export * from "./hooks"
You can’t perform that action at this time.
0 commit comments