forked from OpenKnots/terminal-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add TerminalMarker component for feed phase separators (#7) #18
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
Open
himax12
wants to merge
1
commit into
clawgreen:main
Choose a base branch
from
himax12:codex/atomic-7-terminal-marker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| 'use client' | ||
|
|
||
| export interface TerminalMarkerProps { | ||
| /** Label text displayed as the phase marker. */ | ||
| label: string | ||
| /** Optional timestamp to display after the label. */ | ||
| timestamp?: string | ||
| /** Visual style variant (default: 'neutral'). */ | ||
| variant?: 'info' | 'success' | 'warning' | 'error' | 'neutral' | ||
| /** Additional classes for layout tweaks. */ | ||
| className?: string | ||
| } | ||
|
|
||
| /** | ||
| * Per-variant Tailwind classes for border, background tint, label, and timestamp. | ||
| * Background tints use `color-mix` for consistent translucency across themes. | ||
| */ | ||
| const variantClasses: Record< | ||
| NonNullable<TerminalMarkerProps['variant']>, | ||
| { root: string; label: string; timestamp: string } | ||
| > = { | ||
| neutral: { | ||
| root: 'border-[var(--glass-border)] bg-[rgba(255,255,255,0.03)]', | ||
| label: 'text-[var(--term-fg)]', | ||
| timestamp: 'text-[var(--term-fg-dim)]', | ||
| }, | ||
| info: { | ||
| root: 'border-[var(--term-blue)]/40 bg-[color-mix(in_oklab,var(--term-blue)_8%,transparent)]', | ||
| label: 'text-[var(--term-blue)]', | ||
| timestamp: 'text-[var(--term-blue)]/60', | ||
| }, | ||
| success: { | ||
| root: 'border-[var(--term-green)]/40 bg-[color-mix(in_oklab,var(--term-green)_8%,transparent)]', | ||
| label: 'text-[var(--term-green)]', | ||
| timestamp: 'text-[var(--term-green)]/60', | ||
| }, | ||
| warning: { | ||
| root: 'border-[var(--term-yellow)]/40 bg-[color-mix(in_oklab,var(--term-yellow)_8%,transparent)]', | ||
| label: 'text-[var(--term-yellow)]', | ||
| timestamp: 'text-[var(--term-yellow)]/60', | ||
| }, | ||
| error: { | ||
| root: 'border-[var(--term-red)]/40 bg-[color-mix(in_oklab,var(--term-red)_8%,transparent)]', | ||
| label: 'text-[var(--term-red)]', | ||
| timestamp: 'text-[var(--term-red)]/60', | ||
| }, | ||
| } | ||
|
|
||
| /** | ||
| * Displays a terminal-style phase separator for visual boundaries in feeds. | ||
| * Used to mark different phases like "Build", "Test", "Deploy" in sequential outputs. | ||
| * | ||
| * Renders a left-bordered row with a semantic background tint, a bold phase label, | ||
| * and an optional timestamp. Fully theme-aware via CSS custom properties and | ||
| * naturally responsive at any width. | ||
| * | ||
| * @param label - Phase label text (e.g., "Build", "Test", "Deploy") | ||
| * @param timestamp - Optional timestamp to display after the label | ||
| * @param variant - Visual style for semantic coloring (default: 'neutral') | ||
| * @param className - Additional CSS classes for layout overrides | ||
| * | ||
| * @example | ||
| * ```tsx | ||
| * <TerminalMarker label="BUILD" timestamp="10:23:45" variant="info" /> | ||
| * <TerminalMarker label="TEST" timestamp="10:24:01" variant="success" /> | ||
| * <TerminalMarker label="DEPLOY" timestamp="10:24:30" variant="warning" /> | ||
| * <TerminalMarker label="DONE" timestamp="10:24:45" variant="success" /> | ||
| * ``` | ||
| */ | ||
| export function TerminalMarker({ | ||
| label, | ||
| timestamp, | ||
| variant = 'neutral', | ||
| className = '', | ||
| }: TerminalMarkerProps) { | ||
| const cls = variantClasses[variant] | ||
|
|
||
| return ( | ||
| <div | ||
| className={`flex min-w-0 items-center gap-3 border-l-2 pl-3 py-1.5 my-2 rounded-r ${cls.root} ${className}`.trim()} | ||
| > | ||
| <span | ||
| className={`shrink-0 font-mono text-xs font-semibold tracking-widest uppercase ${cls.label}`} | ||
| > | ||
| {label} | ||
| </span> | ||
| {timestamp && ( | ||
| <span className={`font-mono text-xs truncate ${cls.timestamp}`}>{timestamp}</span> | ||
| )} | ||
| </div> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
truncateon the timestamp span won’t reliably prevent overflow in a flex row unless the timestamp element is allowed to shrink (e.g.,min-w-0+ a flexible width such asflex-1or an explicit/max width). As written, the timestamp can still force the row wider on narrow viewports, undermining the responsive goal mentioned in the description.