Skip to content

Commit 93ca146

Browse files
fix: use CSS property type
this commit uses a CSSProperties type from feedback provided in #61 it also adds a tests to test the functionality. closes #61
1 parent 7b86d4b commit 93ca146

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

__tests__/index.spec.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,5 +305,20 @@ describe("Ansi", () => {
305305
'<code><span class="ansi-green-fg">this is a link: <a href="https://nteract.io/" target="_blank">https://nteract.io/</a></span></code>'
306306
);
307307
});
308+
309+
test("can add text decoration styles", () => {
310+
const el = shallow(
311+
React.createElement(
312+
Ansi,
313+
{},
314+
`hello ${GREEN_FG}${BOLD}world${RESET}!`
315+
)
316+
);
317+
expect(el).not.toBeNull();
318+
expect(el.text()).toBe("hello world!");
319+
expect(el.html()).toBe(
320+
'<code><span>hello </span><span style="color:rgb(0, 187, 0);font-weight:bold">world</span><span>!</span></code>'
321+
);
322+
});
308323
});
309324
});

src/index.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,15 @@ function createClass(bundle: AnserJsonEntry): string | null {
5151
return classNames;
5252
}
5353

54-
interface Colors {
55-
color?: string;
56-
backgroundColor?: string;
57-
}
58-
59-
interface Styles extends Colors {
60-
fontWeight?: string;
61-
opacity?: string;
62-
fontStyle?: string;
63-
visibility?: string;
64-
textDecoration?: string;
65-
}
66-
67-
6854
/**
6955
* Create the style attribute.
7056
* @name createStyle
7157
* @function
7258
* @param {AnserJsonEntry} bundle
7359
* @return {Object} returns the style object
7460
*/
75-
function createStyle(bundle: AnserJsonEntry): Colors {
76-
const style: Styles = {};
61+
function createStyle(bundle: AnserJsonEntry): React.CSSProperties {
62+
const style: React.CSSProperties = {};
7763
if (bundle.bg) {
7864
style.backgroundColor = `rgb(${bundle.bg})`;
7965
}

0 commit comments

Comments
 (0)