Skip to content

Commit f7b650e

Browse files
authored
Merge pull request #53 from lumpinif/main
[feat](styles): implement modular CSS architecture for upcoming feature
2 parents 757166d + 9702bc1 commit f7b650e

11 files changed

Lines changed: 64 additions & 40 deletions

File tree

extensions/changelog.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
# Changelog of the extensions
44

5+
## feat: CSS Architecture - 12/1/2024 - @lumpinif
6+
7+
### Modular CSS Architecture Implementation
8+
9+
- Established new modular CSS architecture for better feature isolation
10+
- Introduced feature-specific CSS modules starting with thinking-block
11+
- Set up base styles directory for shared Tailwind utilities
12+
- Improved organization and maintainability of styles
13+
- Added support for future feature-specific styling needs
14+
15+
### Build System Updates
16+
17+
- Enhanced webpack configuration for CSS handling
18+
- Integrated MiniCssExtractPlugin for optimized CSS delivery
19+
- Updated manifest.json to reflect new CSS structure
20+
- Removed legacy styles.css in favor of modular approach
21+
522
## ci: - 11/30/2024 - @lumpinif
623

724
### Chrome Extension CI Improvements

extensions/chrome/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "thinking-claude",
3-
"version": "3.1.4",
3+
"version": "3.1.5",
44
"description": "Chrome extension for letting Claude think like a real human",
55
"type": "module",
66
"scripts": {

extensions/chrome/public/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "Thinking Claude",
4-
"version": "3.1.4",
4+
"version": "3.1.5",
55
"description": "Chrome extension for letting Claude think like a real human",
66
"background": {
77
"service_worker": "background.js"
@@ -10,7 +10,7 @@
1010
{
1111
"matches": ["https://*.claude.ai/*"],
1212
"js": ["content.js"],
13-
"css": ["styles.css"]
13+
"css": ["content.css"]
1414
}
1515
],
1616
"icons": {

extensions/chrome/src/content/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import "@/styles/globals.css"
1+
import "@/styles/index.css"
22

33
import { ExtensionManager } from "./v3/managers/extension-manager"
44

extensions/chrome/src/content/v3/features/thinking-block/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class TCThinkingBlock extends BaseFeature {
1818
/**
1919
* Initialize the thinking block feature
2020
* Sets up mutation observer to watch for new thinking blocks
21-
* @returns Cleanup function to unsubscribe from mutation observer
21+
* @returns Cleanup function to unsubscribe from mutation observer and remove custom attributes
2222
*/
2323
initialize(): void | (() => void) {
2424
this.mutationObserver.initialize()
@@ -28,6 +28,14 @@ export class TCThinkingBlock extends BaseFeature {
2828
return () => {
2929
// Unsubscribe from mutation observer
3030
unsubscribe()
31+
32+
// Clean up all feature-specific attributes
33+
document
34+
.querySelectorAll("[data-tc-processed]")
35+
.forEach((el) => el.removeAttribute("data-tc-processed"))
36+
document
37+
.querySelectorAll("[data-tc-thinking-block-state]")
38+
.forEach((el) => el.removeAttribute("data-tc-thinking-block-state"))
3139
}
3240
}
3341
}

extensions/chrome/src/content/v3/features/thinking-block/process-thinking-block.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function processControl(control: Element) {
2020
?.querySelector(".code-block__code")
2121
if (!thinkingBlock) return
2222

23-
if (!resContainer.hasAttribute("data-thinking-block-state")) {
24-
resContainer.setAttribute("data-thinking-block-state", "expanded")
23+
if (!resContainer.hasAttribute("data-tc-thinking-block-state")) {
24+
resContainer.setAttribute("data-tc-thinking-block-state", "expanded")
2525
}
2626

2727
setupControls(control as HTMLElement, thinkingBlock, resContainer)

extensions/chrome/src/content/v3/features/thinking-block/setup-controls.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ export function setupControls(
44
resContainer: Element
55
) {
66
const copyButton = control.querySelector("button")
7-
87
if (!copyButton) return
8+
99
copyButton.classList.add("tc-select-none")
10+
1011
copyButton.addEventListener(
1112
"click",
1213
async (e) => {
@@ -17,11 +18,13 @@ export function setupControls(
1718
)
1819

1920
control.addEventListener("click", () => {
20-
const currentState = resContainer.getAttribute("data-thinking-block-state")
21+
const currentState = resContainer.getAttribute(
22+
"data-tc-thinking-block-state"
23+
)
2124

2225
// Update the collapse state of thinking block in the response container
2326
const newState = currentState === "expanded" ? "collapsed" : "expanded"
24-
resContainer.setAttribute("data-thinking-block-state", newState)
27+
resContainer.setAttribute("data-tc-thinking-block-state", newState)
2528

2629
// Toggle the collapse state of the thinking block as fallback
2730
thinkingBlock.classList.toggle("collapsed")
@@ -48,7 +51,8 @@ function updateCopyButtonUI(copyButton: Element) {
4851
const originalText = textSpan.textContent
4952
const originalSvgPath = svg.innerHTML
5053

51-
textSpan.textContent = "Copied"
54+
// textSpan.textContent = "Copied"
55+
5256
svg.innerHTML =
5357
'<path d="M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"></path>'
5458

extensions/chrome/public/styles.css renamed to extensions/chrome/src/content/v3/features/thinking-block/styles.css

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ div[data-is-streaming] pre:first-child .code-block__code {
1717
transition: all 0.3s ease-out !important;
1818
}
1919

20-
/* collapsed states */
21-
22-
/* Collapsed state */
20+
/* Collapsed states */
2321
div[data-is-streaming] pre:first-child .code-block__code.collapsed {
2422
height: 0 !important;
2523
padding: 0 !important;
@@ -28,7 +26,7 @@ div[data-is-streaming] pre:first-child .code-block__code.collapsed {
2826
}
2927

3028
/* Collapsed state */
31-
[data-thinking-block-state="collapsed"]
29+
[data-tc-thinking-block-state="collapsed"]
3230
div[data-is-streaming]
3331
pre:first-child
3432
.code-block__code {
@@ -39,7 +37,7 @@ div[data-is-streaming] pre:first-child .code-block__code.collapsed {
3937
}
4038

4139
/* Expanded state */
42-
/* [data-thinking-block-state="expanded"] div[data-is-streaming] pre:first-child .code-block__code {
40+
/* [data-tc-thinking-block-state="expanded"] div[data-is-streaming] pre:first-child .code-block__code {
4341
height: 50vh !important;
4442
padding: 1em !important;
4543
visibility: visible !important;
@@ -105,7 +103,7 @@ div[data-is-streaming]
105103

106104
/* Update the text of the header */
107105

108-
div[data-thinking-block-state="collapsed"]
106+
div[data-tc-thinking-block-state="collapsed"]
109107
pre:first-child
110108
.text-text-300.absolute.pl-3.pt-2\.5.text-xs:not(:empty)::after {
111109
content: "View Claude's thinking" !important;
@@ -127,7 +125,7 @@ div[data-is-streaming]
127125

128126
/* Hover state */
129127
/* This implementation is limited. We can consider to disable this hover state. */
130-
[data-thinking-block-state="expanded"]
128+
[data-tc-thinking-block-state="expanded"]
131129
pre:first-child
132130
.text-text-300.absolute.pl-3.pt-2\.5.text-xs:not(:empty):hover::after {
133131
color: hsl(var(--text-100));
@@ -175,6 +173,13 @@ pre:first-child
175173
transition: transform 0.25s ease-out;
176174
}
177175

176+
/* Chevron animation */
177+
[data-tc-thinking-block-state="collapsed"]
178+
pre:first-child
179+
.text-text-300.absolute.pl-3.pt-2\.5.text-xs:not(:empty)::before {
180+
transform: rotate(180deg) !important;
181+
}
182+
178183
/* --------------------------------- */
179184

180185
/* Shimmer animation for streaming state */
@@ -188,11 +193,3 @@ pre:first-child
188193
}
189194

190195
/* --------------------------------- */
191-
192-
/* Chevron animation */
193-
194-
[data-thinking-block-state="collapsed"]
195-
pre:first-child
196-
.text-text-300.absolute.pl-3.pt-2\.5.text-xs:not(:empty)::before {
197-
transform: rotate(180deg);
198-
}

extensions/chrome/src/content/v3/managers/feature-manager.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ export class FeatureManager {
3636
* Clean up all features
3737
*/
3838
cleanup(): void {
39-
// Remove data-tc-processed attributes from thinking block controls
40-
document.querySelectorAll("[data-tc-processed]").forEach((element) => {
41-
element.removeAttribute("data-tc-processed")
42-
})
43-
4439
this.cleanupFunctions.forEach((cleanup, id) => {
4540
try {
4641
cleanup()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@import "./globals.css";
2+
3+
/* Import feature styles after Tailwind layers to ensure they have highest specificity */
4+
@import "@/content/v3/features/thinking-block/styles.css";

0 commit comments

Comments
 (0)