util.styleText: support background colors with hex codes
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
What is the problem this feature will solve?
util.styleText() supports arbitrary foreground colors via hex codes (styleText('#ff5733', text), added in #61556), but there's no equivalent for background colors. Predefined colors already have both a foreground (red) and background (bgRed) variant, but hex colors only cover the foreground case (SGR 38;2;r;g;b).
What is the feature you are proposing to solve the problem?
Extend hex color detection in styleText to also accept a background variant, mirroring the existing bgRed/red naming convention by prefixing the hex code with bg:
styleText('bg#ff5733', 'Warning!');
This would emit the background TrueColor SGR sequence (48;2;r;g;b) instead of the foreground one (38;2;r;g;b), and composes with the existing array syntax to combine foreground + background:
styleText(['#ffffff', 'bg#ff5733'], 'Warning!');
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne am Einstiegspunkt util.styleText und lies die bestehende Behandlung von Hex-Farben für Vordergrund-SGR-Sequenzen. Erweitere das Verhalten für die Form mit dem Präfix bg und überprüfe, dass Vordergrund- und Hintergrundstile über die Array-Syntax kombiniert werden. Erledigt ist es, wenn bg#ff5733 die Sequenz 48;2;r;g;b erzeugt, während #ffffff plus bg#ff5733 beide Stile erzeugt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- cli
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 65/100