-
Notifications
You must be signed in to change notification settings - Fork 72
UI: New text-strings preview mode #1051
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: master
Are you sure you want to change the base?
Conversation
if (!props.content) return ""; | ||
if (props.mode === "raw") { | ||
if (props.content instanceof ArrayBuffer) | ||
return new TextDecoder().decode(props.content); | ||
else return props.content; | ||
} else if (props.mode === "text") { |
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.
Currently, there are too many if-logic blocks here. I suggest creating separate utility functions for each mode — 'raw', 'text', and 'hex' to handle the value for each of them individually.
else buffer = new TextEncoder().encode(props.content); | ||
|
||
const MIN_LENGTH = 4; | ||
let result: string[] = []; |
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.
let result: string[] = []; | |
const result: string[] = []; |
const selectedStyle = { | ||
fontWeight: selected ? "bold" : "normal", | ||
pointerEvents: (selected ? "none" : "auto") as | ||
| "none" | ||
| "auto", | ||
}; |
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.
const selectedStyle = { | |
fontWeight: selected ? "bold" : "normal", | |
pointerEvents: (selected ? "none" : "auto") as | |
| "none" | |
| "auto", | |
}; | |
const styles = { fontWeight: selected ? "bold" : "normal" }; |
}; | ||
|
||
return ( | ||
<span className="nav-item" style={selectedStyle} key={mode}> |
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.
<span className="nav-item" style={selectedStyle} key={mode}> | |
<span className="nav-item" style={styles} key={mode}> |
Your checklist for this pull request
What is the current behaviour?
Only raw and hex mode in sample preview.
What is the new behaviour?
HexView
toObjectPreview
Test plan
Go to sample preview and change mode on some files.
Screencast.from.2025-07-23.12-07-29.webm