Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
126 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
yarn.lock | ||
/dist.js | ||
build |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module "cfonts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from "react"; | ||
import { Text } from "ink"; | ||
import CFonts from "cfonts"; | ||
|
||
type BigTextProps = { text: string } & Partial<CFontProps>; | ||
|
||
type CFontProps = { | ||
font: | ||
| "block" | ||
| "slick" | ||
| "tiny" | ||
| "grid" | ||
| "pallet" | ||
| "shade" | ||
| "simple" | ||
| "simpleBlock" | ||
| "3d" | ||
| "simple3d" | ||
| "chrome" | ||
| "huge"; | ||
align: "left" | "center" | "right"; | ||
colors: string[]; | ||
backgroundColor: | ||
| "transparent" | ||
| "black" | ||
| "red" | ||
| "green" | ||
| "yellow" | ||
| "blue" | ||
| "magenta" | ||
| "cyan" | ||
| "white"; | ||
letterSpacing: number; | ||
lineHeight: number; | ||
space: boolean; | ||
maxLength: number; | ||
}; | ||
|
||
const defaultCFontProps: CFontProps = { | ||
font: "block", | ||
align: "left", | ||
colors: ["system"], | ||
backgroundColor: "transparent", | ||
letterSpacing: 1, | ||
lineHeight: 1, | ||
space: true, | ||
maxLength: 0 | ||
}; | ||
|
||
export const BigText: React.FC<BigTextProps> = ({ text, ...props }) => { | ||
const cFontProps = { ...defaultCFontProps, ...props }; | ||
return <Text>{CFonts.render(text, cFontProps).string}</Text>; | ||
}; | ||
|
||
export default BigText; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from "react"; | ||
import test from "ava"; | ||
import { render } from "ink-testing-library"; | ||
import clearModule from "clear-module"; | ||
import stripAnsi from "strip-ansi"; | ||
import { BigText } from "../src/index.js"; | ||
|
||
test("render", t => { | ||
// TODO: Find out why this doesn't work to prevent color | ||
process.env.FORCE_COLOR = "0"; | ||
clearModule.all(); | ||
// const BigText = require('.'); | ||
|
||
const { lastFrame } = render(<BigText text="unicorns" />); | ||
console.log(lastFrame()); | ||
t.snapshot(stripAnsi(lastFrame())); | ||
|
||
delete process.env.FORCE_COLOR; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "@sindresorhus/tsconfig", | ||
"compilerOptions": { | ||
"outDir": "build", | ||
"sourceMap": true, | ||
"jsx": "react" | ||
}, | ||
"include": ["src"], | ||
"ts-node": { | ||
"transpileOnly": true, | ||
"files": true | ||
} | ||
} |