-
Notifications
You must be signed in to change notification settings - Fork 198
Docs/add example comments #1670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||
| import { useEffect, useState } from '@termuijs/jsx' | ||||||
| import { caps } from '@termuijs/core' | ||||||
| import { Text } from './Text' | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify where Text is actually defined/exported
fd -i 'Text.ts' packages/widgets/src
rg -n -C2 'export\s+\{\s*Text\s*\}\s+from' packages/widgets/src/index.tsRepository: Karanjot786/TermUI Length of output: 440 🏁 Script executed: cat -n packages/widgets/src/Spinner.ts | head -20Repository: Karanjot786/TermUI Length of output: 765 🏁 Script executed: # Double-check if Text.ts exists at the root of src
ls -la packages/widgets/src/Text.ts 2>&1Repository: Karanjot786/TermUI Length of output: 138 Fix broken import path for The import path Suggested fix-import { Text } from './Text'
+import { Text } from './display/Text.js'📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| export interface SpinnerProps { | ||||||
| speed?: number | ||||||
| label?: string | ||||||
| color?: string | ||||||
| } | ||||||
|
|
||||||
| const FRAMES_UNICODE = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'] | ||||||
| const FRAMES_ASCII = ['|', '/', '-', '\\'] | ||||||
|
|
||||||
| export function Spinner({ speed = 80, label = '', color = 'cyan' }: SpinnerProps) { | ||||||
| const [frame, setFrame] = useState(0) | ||||||
| const frames = caps.unicode ? FRAMES_UNICODE : FRAMES_ASCII | ||||||
|
|
||||||
| useEffect(() => { | ||||||
| if (caps.noMotion) return | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify caps API surface and motion helper usage
rg -n -C2 '\bcaps\.(noMotion|motion)\b|prefersReducedMotion\s*\(' packagesRepository: Karanjot786/TermUI Length of output: 14341 🏁 Script executed: #!/bin/bash
# Check if caps.noMotion is defined anywhere
rg -n '\bcaps\.noMotion\b' packages
# Check what's exported from core env-caps
rg -n '^export' packages/core/src/terminal/env-caps.ts
# Get exact content around line 19 of Spinner.ts
head -25 packages/widgets/src/Spinner.ts | tail -10Repository: Karanjot786/TermUI Length of output: 561 🏁 Script executed: #!/bin/bash
# Get the full definition of the caps object in env-caps.ts
sed -n '1,42p' packages/core/src/terminal/env-caps.ts
# Check what `@termuijs/core` exports (usually in index.ts or package.json exports)
find packages/core/src -name 'index.ts' -o -name 'index.js' | head -5
# Check if prefersReducedMotion is re-exported from the main entry point
rg -n 'prefersReducedMotion' packages/core/src/index.ts 2>/dev/null || echo "Not found in index.ts, checking package.json"Repository: Karanjot786/TermUI Length of output: 1653 Use
Use the documented Suggested fix-import { caps } from '`@termuijs/core`'
+import { prefersReducedMotion } from '`@termuijs/core`'
...
- if (caps.noMotion) return
+ if (prefersReducedMotion()) return📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| const interval = setInterval(() => { | ||||||
| setFrame((f) => (f + 1) % frames.length) | ||||||
| }, speed) | ||||||
|
|
||||||
| return () => clearInterval(interval) | ||||||
| }, [speed, frames.length]) | ||||||
|
|
||||||
| const spinnerChar = frames[frame] | ||||||
| const display = label ? `${spinnerChar} ${label}` : spinnerChar | ||||||
|
|
||||||
| return <Text color={color}>{display}</Text> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify .ts files containing JSX tags
rg -nP --type=ts '<[A-Z][A-Za-z0-9]*\b|</[A-Z][A-Za-z0-9]*>' -g '**/*.ts'Repository: Karanjot786/TermUI Length of output: 50374 🏁 Script executed: #!/bin/bash
# Check which Spinner file exists and its content
ls -la packages/widgets/src/ | grep -i spinner
echo "---"
# Check if .ts file exists with JSX
if [ -f "packages/widgets/src/Spinner.ts" ]; then
echo "=== Spinner.ts (first 35 lines) ==="
head -35 packages/widgets/src/Spinner.ts
fi
echo "---"
# Check if .tsx file exists
if [ -f "packages/widgets/src/Spinner.tsx" ]; then
echo "=== Spinner.tsx exists ==="
head -5 packages/widgets/src/Spinner.tsx
fiRepository: Karanjot786/TermUI Length of output: 1054 File should be renamed from The file contains JSX syntax ( Suggested fix- packages/widgets/src/Spinner.ts
+ packages/widgets/src/Spinner.tsx🧰 Tools🪛 Biome (2.5.0)[error] 31-31: expected (parse) [error] 31-31: Invalid assignment to (parse) [error] 31-31: unterminated regex literal (parse) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -310,3 +310,5 @@ export { UnorderedList } from './display/UnorderedList.js'; | |||||||||
| export type { UnorderedListOptions } from './display/UnorderedList.js'; | ||||||||||
| export { Rule } from './display/Rule.js'; | ||||||||||
| export type { RuleOrientation, RuleOptions } from './display/Rule.js'; | ||||||||||
| export { Spinner } from './Spinner' | ||||||||||
| export type { SpinnerProps } from './Spinner' | ||||||||||
|
Comment on lines
+313
to
+314
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify duplicate Spinner exports in this module
rg -n -C1 "export\s+\{\s*Spinner\b" packages/widgets/src/index.tsRepository: Karanjot786/TermUI Length of output: 455 🏁 Script executed: fd -t f "Spinner" packages/widgets/src/ | head -20Repository: Karanjot786/TermUI Length of output: 181 🏁 Script executed: cat packages/widgets/src/index.ts | sed -n '310,320p'Repository: Karanjot786/TermUI Length of output: 328 🏁 Script executed: find packages/widgets/src -name "*Spinner*" -type fRepository: Karanjot786/TermUI Length of output: 181 🏁 Script executed: head -30 packages/widgets/src/Spinner.tsRepository: Karanjot786/TermUI Length of output: 902 🏁 Script executed: head -30 packages/widgets/src/feedback/Spinner.tsRepository: Karanjot786/TermUI Length of output: 1257 Fix module specifier to match pattern used throughout the file.
Suggested fix-export { Spinner } from './Spinner'
-export type { SpinnerProps } from './Spinner'
+export { Spinner } from './Spinner.js'
+export type { SpinnerProps } from './Spinner.js'📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { describe, it, expect } from 'bun:test' | ||
| import { render } from '@termuijs/testing' | ||
| import { Spinner } from '../../packages/widgets/src/Spinner' | ||
|
|
||
| describe('Spinner', () => { | ||
| it('renders with label', () => { | ||
| const t = render(<Spinner label="Loading" />) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find test .ts files containing JSX
rg -nP --type=ts '<[A-Z][A-Za-z0-9]*\b|</[A-Z][A-Za-z0-9]*>' testsRepository: Karanjot786/TermUI Length of output: 144 Rename this test file to The file Suggested fix- tests/helpers/Spinner.test.ts
+ tests/helpers/Spinner.test.tsx🧰 Tools🪛 Biome (2.5.0)[error] 7-7: expected (parse) [error] 7-7: Invalid assignment to (parse) [error] 7-7: Expected an expression but instead found '>'. (parse) [error] 7-7: Expected an expression but instead found ')'. (parse) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
| expect(t.renderToString()).toContain('Loading') | ||
| t.unmount() | ||
| }) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 583
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 240
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 610
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 2278
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 84
The imperative widget example overrides the wrong render method.
For
Widget, examples should implement_renderSelf(screen)rather than overridingrender(...); overridingrenderbypasses core render pipeline behavior including visibility checks, clipping, error handling, performance tracking, border rendering, and child rendering as shown inWidget.render.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents