Skip to content

Commit 7b86d4b

Browse files
vmik7robertkowalski
authored andcommitted
fix: add decoration to style-attribute
1 parent deb6520 commit 7b86d4b

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

src/index.ts

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ interface Colors {
5656
backgroundColor?: string;
5757
}
5858

59+
interface Styles extends Colors {
60+
fontWeight?: string;
61+
opacity?: string;
62+
fontStyle?: string;
63+
visibility?: string;
64+
textDecoration?: string;
65+
}
66+
67+
5968
/**
6069
* Create the style attribute.
6170
* @name createStyle
@@ -64,14 +73,38 @@ interface Colors {
6473
* @return {Object} returns the style object
6574
*/
6675
function createStyle(bundle: AnserJsonEntry): Colors {
67-
const style: Colors = {};
76+
const style: Styles = {};
6877
if (bundle.bg) {
6978
style.backgroundColor = `rgb(${bundle.bg})`;
7079
}
7180
if (bundle.fg) {
7281
style.color = `rgb(${bundle.fg})`;
7382
}
74-
83+
switch (bundle.decoration) {
84+
case 'bold':
85+
style.fontWeight = 'bold';
86+
break;
87+
case 'dim':
88+
style.opacity = '0.5';
89+
break;
90+
case 'italic':
91+
style.fontStyle = 'italic';
92+
break;
93+
case 'hidden':
94+
style.visibility = 'hidden';
95+
break;
96+
case 'strikethrough':
97+
style.textDecoration = 'line-through';
98+
break;
99+
case 'underline':
100+
style.textDecoration = 'underline';
101+
break;
102+
case 'blink':
103+
style.textDecoration = 'blink';
104+
break;
105+
default:
106+
break;
107+
}
75108
return style;
76109
}
77110

0 commit comments

Comments
 (0)