Skip to content

Commit ba25a5f

Browse files
naivefunclaude
andcommitted
Convert to normal CSS with handtree- prefix for better user customization
BREAKING CHANGE: CSS modules replaced with prefixed CSS classes for easier user overrides - Rename TreeNode.module.scss → TreeNode.scss with handtree- prefixed classes - Update component to use string class names instead of CSS modules - Change tsup config from 'local-css' to 'css' loader - Update type declarations for regular CSS imports Benefits: - Users can easily override styles: .handtree-head { color: red; } - Better debugging - class names visible in DevTools - More standard approach for component libraries - No hashed class names in production 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e8dabfc commit ba25a5f

File tree

7 files changed

+41
-40
lines changed

7 files changed

+41
-40
lines changed

.claude/settings.local.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"Bash(pnpm publish:*)",
1313
"Bash(git init:*)",
1414
"Bash(git add:*)",
15-
"Bash(git commit:*)"
15+
"Bash(git commit:*)",
16+
"Bash(mv:*)"
1617
],
1718
"defaultMode": "acceptEdits"
1819
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "handtree",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "A React tree component for hand-crafted hierarchical interfaces",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
.root {
1+
.handtree-root {
22
/* Layout structure */
3-
.node {
3+
.handtree-node {
44
}
5-
.content {
5+
.handtree-content {
66
flex-grow: 1;
77
}
8-
.title {
8+
.handtree-title {
99
/* Title container - no specific styles needed */
1010
}
1111

1212
/* Head/chevron area with tree connecting lines */
13-
.head {
13+
.handtree-head {
1414
position: relative;
1515
display: flex;
1616
align-items: center;
@@ -20,7 +20,7 @@
2020
min-width: var(--head-width);
2121
max-width: var(--head-width);
2222

23-
&.headless {
23+
&.handtree-headless {
2424
width: 0px;
2525
&::before {
2626
content: none;
@@ -50,21 +50,21 @@
5050
background-color: var(--outline-color);
5151
}
5252

53-
&.lastNode {
53+
&.handtree-last-node {
5454
&::before {
5555
height: 50%;
5656
}
5757
}
5858

59-
&.expandable {
59+
&.handtree-expandable {
6060
&::after {
6161
width: calc(100% - 20px);
6262
}
6363
}
6464
}
6565

6666
/* Details section with continuation lines */
67-
.details {
67+
.handtree-details {
6868
position: relative;
6969
padding-left: var(--head-width);
7070

@@ -78,13 +78,13 @@
7878
background-color: var(--outline-color);
7979
}
8080

81-
&.lastNode {
81+
&.handtree-last-node {
8282
&::before {
8383
content: none;
8484
}
8585
}
8686

87-
&.expandable {
87+
&.handtree-expandable {
8888
padding-left: calc(var(--indent-width) + var(--head-width));
8989
&::after {
9090
content: '';
@@ -95,7 +95,7 @@
9595
height: 100%;
9696
background-color: var(--outline-color);
9797
}
98-
&.collpased {
98+
&.handtree-collapsed {
9999
padding-left: 28px;
100100
&::after {
101101
content: none;
@@ -105,7 +105,7 @@
105105
}
106106

107107
/* Indentation guides for tree structure */
108-
.indent {
108+
.handtree-indent {
109109
position: relative;
110110
width: var(--indent-width);
111111
min-width: var(--indent-width);
@@ -121,11 +121,11 @@
121121
background-color: var(--outline-color);
122122
}
123123

124-
&.ignore {
124+
&.handtree-ignore {
125125
&::before {
126126
width: 0;
127127
height: 0;
128128
}
129129
}
130130
}
131-
}
131+
}

src/TreeNode.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import range from 'lodash-es/range'
33
import { PropsWithChildren, ReactNode, useContext } from 'react'
44
import { VscChevronDown, VscChevronRight } from 'react-icons/vsc'
55
import { TreeContext } from './TreeContext'
6-
import styles from './TreeNode.module.scss'
6+
import './TreeNode.scss'
77

88
export interface TreeNodeProps {
99
level: number // start from 0
@@ -40,14 +40,14 @@ export default function TreeNode({
4040
}
4141
return (
4242
<div
43-
className={styles.root}
43+
className="handtree-root"
4444
// @ts-ignore
4545
style={{
4646
...cssVars,
4747
}}
4848
>
4949
<div
50-
className={styles.node}
50+
className="handtree-node"
5151
style={{
5252
display: 'flex',
5353
position: 'relative',
@@ -59,7 +59,7 @@ export default function TreeNode({
5959
return (
6060
<div
6161
key={i}
62-
className={clsx([styles.indent, ignoreIndentOutline && styles.ignore])}
62+
className={clsx(['handtree-indent', ignoreIndentOutline && 'handtree-ignore'])}
6363
style={{
6464
width: indent,
6565
}}
@@ -68,15 +68,15 @@ export default function TreeNode({
6868
})}
6969

7070
{/* content with title and main */}
71-
<div className={styles.content}>
72-
<div className={styles.title} style={{ display: 'flex' }}>
71+
<div className="handtree-content">
72+
<div className="handtree-title" style={{ display: 'flex' }}>
7373
{/* head */}
7474
<div
7575
className={clsx([
76-
styles.head,
77-
isRoot && styles.headless,
78-
lastNode && styles.lastNode,
79-
expandable && styles.expandable,
76+
'handtree-head',
77+
isRoot && 'handtree-headless',
78+
lastNode && 'handtree-last-node',
79+
expandable && 'handtree-expandable',
8080
options.classNames?.chevron,
8181
])}
8282
onClick={onToggleExpanded}
@@ -88,10 +88,10 @@ export default function TreeNode({
8888
{details && (
8989
<div
9090
className={clsx([
91-
styles.details,
92-
!!children && styles.expandable,
93-
lastNode && styles.lastNode,
94-
!expanded && styles.collpased,
91+
'handtree-details',
92+
!!children && 'handtree-expandable',
93+
lastNode && 'handtree-last-node',
94+
!expanded && 'handtree-collapsed',
9595
])}
9696
>
9797
<div>{details}</div>
@@ -112,7 +112,7 @@ export default function TreeNode({
112112
classNames: options.classNames,
113113
}}
114114
>
115-
<div className={styles.children}>{children}</div>
115+
<div className="handtree-children">{children}</div>
116116
</TreeContext.Provider>
117117
)}
118118
</div>

src/global.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
declare module '*.module.scss' {
2-
const classes: { [key: string]: string };
3-
export default classes;
1+
declare module '*.scss' {
2+
const content: any;
3+
export default content;
44
}
55

6-
declare module '*.module.css' {
7-
const classes: { [key: string]: string };
8-
export default classes;
6+
declare module '*.css' {
7+
const content: any;
8+
export default content;
99
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import './TreeNode.module.scss'
1+
import './TreeNode.scss'
22

33
export * from './TreeContext'
44
export { default as TreeNode, type TreeNodeProps } from './TreeNode'

tsup.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default defineConfig({
1212
esbuildOptions(options) {
1313
options.loader = {
1414
...options.loader,
15-
'.scss': 'local-css',
15+
'.scss': 'css',
1616
}
1717
},
1818
})

0 commit comments

Comments
 (0)