@@ -60,6 +60,44 @@ interface LanguageData {
6060 percentage : number
6161}
6262
63+ // Default customization options
64+ const DEFAULT_CUSTOMIZATION_OPTIONS : TreeCustomizationOptions = {
65+ asciiStyle : "basic" ,
66+ useIcons : false ,
67+ showLineNumbers : false ,
68+ showRootDirectory : false ,
69+ showTrailingSlash : false ,
70+ }
71+
72+ // Load customization options from localStorage
73+ const loadCustomizationOptions = ( ) : TreeCustomizationOptions => {
74+ if ( typeof window === "undefined" ) return DEFAULT_CUSTOMIZATION_OPTIONS
75+
76+ try {
77+ const saved = localStorage . getItem ( "treeCustomizationOptions" )
78+ if ( saved ) {
79+ const parsed = JSON . parse ( saved )
80+ // Merge with defaults to ensure all properties exist
81+ return { ...DEFAULT_CUSTOMIZATION_OPTIONS , ...parsed }
82+ }
83+ } catch ( error ) {
84+ console . warn ( "Failed to load customization options from localStorage:" , error )
85+ }
86+
87+ return DEFAULT_CUSTOMIZATION_OPTIONS
88+ }
89+
90+ // Save customization options to localStorage
91+ const saveCustomizationOptions = ( options : TreeCustomizationOptions ) : void => {
92+ if ( typeof window === "undefined" ) return
93+
94+ try {
95+ localStorage . setItem ( "treeCustomizationOptions" , JSON . stringify ( options ) )
96+ } catch ( error ) {
97+ console . warn ( "Failed to save customization options to localStorage:" , error )
98+ }
99+ }
100+
63101export default function RepoProjectStructure ( ) {
64102 const [ repoUrl , setRepoUrl ] = useState ( "" )
65103 const [ repoType , setRepoType ] = useState < RepoType > ( "github" )
@@ -77,11 +115,7 @@ export default function RepoProjectStructure() {
77115 const inputRef = useRef < HTMLInputElement > ( null )
78116 const treeRef = useRef < HTMLDivElement > ( null )
79117
80- const [ customizationOptions , setCustomizationOptions ] = useState < TreeCustomizationOptions > ( {
81- asciiStyle : "basic" ,
82- useIcons : false ,
83- showLineNumbers : false ,
84- } )
118+ const [ customizationOptions , setCustomizationOptions ] = useState < TreeCustomizationOptions > ( loadCustomizationOptions ( ) )
85119
86120 const [ fileTypeData , setFileTypeData ] = useState < FileTypeData [ ] > ( [ ] )
87121 const [ languageData , setLanguageData ] = useState < LanguageData [ ] > ( [ ] )
@@ -271,10 +305,15 @@ export default function RepoProjectStructure() {
271305 } , [ downloadFormat , customizedStructure , filteredStructureMap ] )
272306
273307 const handleCustomizationChange = ( newOptions : Partial < TreeCustomizationOptions > ) => {
274- setCustomizationOptions ( ( prevOptions : TreeCustomizationOptions ) => ( {
275- ...prevOptions ,
276- ...newOptions ,
277- } ) )
308+ setCustomizationOptions ( ( prevOptions : TreeCustomizationOptions ) => {
309+ const updatedOptions = {
310+ ...prevOptions ,
311+ ...newOptions ,
312+ }
313+ // Save to localStorage whenever options change
314+ saveCustomizationOptions ( updatedOptions )
315+ return updatedOptions
316+ } )
278317 }
279318
280319 const noStructureMessage = `No structure generated yet. Enter a ${ repoType === "github" ? "GitHub" : "GitLab" } URL and click Generate.`
@@ -292,7 +331,7 @@ export default function RepoProjectStructure() {
292331 >
293332 < CardHeader >
294333 < CardTitle className = "text-2xl md:text-3xl lg:text-4xl font-semibold text-black dark:text-white flex items-center justify-center gap-2" >
295- Generate < span className = "text-blue -600" > Structure </ span >
334+ Generate ASCII < span className = "text-emerald -600" > Tree </ span >
296335 </ CardTitle >
297336 </ CardHeader >
298337 < CardContent >
@@ -306,7 +345,7 @@ export default function RepoProjectStructure() {
306345 < SelectValue placeholder = "Select repo type" />
307346 </ SelectTrigger >
308347 < SelectContent >
309- < SelectItem value = "github" > GitHub { hasPrivateToken && "(Private Access )" } </ SelectItem >
348+ < SelectItem value = "github" > GitHub { hasPrivateToken && "(Private)" } </ SelectItem >
310349 < SelectItem value = "gitlab" > GitLab</ SelectItem >
311350 </ SelectContent >
312351 </ Select >
0 commit comments