MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / asTextStyle

Function asTextStyle

packages/core/src/renderer/styles.ts:25–50  ·  view source on GitHub ↗
(v: unknown, theme?: Theme)

Source from the content-addressed store, hash-verified

23 * Coerce unknown value to TextStyle if object-shaped.
24 */
25export function asTextStyle(v: unknown, theme?: Theme): TextStyle | undefined {
26 if (!isObject(v)) return undefined;
27 const style = v as TextStyle;
28 if (!theme) return style;
29
30 const resolvedFg = resolveStyleColor(theme, style.fg) as TextStyle["fg"];
31 const resolvedBg = resolveStyleColor(theme, style.bg) as TextStyle["bg"];
32 const resolvedUnderlineColor = resolveStyleColor(theme, style.underlineColor) as
33 | TextStyle["underlineColor"]
34 | undefined;
35
36 if (
37 resolvedFg === style.fg &&
38 resolvedBg === style.bg &&
39 resolvedUnderlineColor === style.underlineColor
40 ) {
41 return style;
42 }
43
44 return {
45 ...style,
46 ...(resolvedFg === undefined ? {} : { fg: resolvedFg }),
47 ...(resolvedBg === undefined ? {} : { bg: resolvedBg }),
48 ...(resolvedUnderlineColor === undefined ? {} : { underlineColor: resolvedUnderlineColor }),
49 };
50}
51
52/** Visual state for button/input styling. */
53export type ButtonVisualState = Readonly<{ focused: boolean; disabled: boolean }>;

Callers 14

renderVNodeSimpleFunction · 0.85
renderCollectionWidgetFunction · 0.85
renderTextWidgetsFunction · 0.85
renderFileWidgetsFunction · 0.85
renderFormWidgetsFunction · 0.85
renderOverlayWidgetFunction · 0.85
renderEditorWidgetFunction · 0.85
renderIndicatorWidgetsFunction · 0.85
readBorderSideStyleMapFunction · 0.85
renderContainerWidgetFunction · 0.85
renderChartWidgetsFunction · 0.85

Calls 2

resolveStyleColorFunction · 0.85
isObjectFunction · 0.70

Tested by

no test coverage detected