Skip to content

Commit

Permalink
feat: make customizable
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Aug 21, 2024
1 parent e141828 commit 6fa62ef
Show file tree
Hide file tree
Showing 5 changed files with 527 additions and 129 deletions.
16 changes: 12 additions & 4 deletions examples/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {makeTable} from '../src/index.js'
const data = [
{
age: 20,
bigData: 'a'.repeat(98),
bigData: 'a'.repeat(200),
employed: ansis.bold('true'),
evenMoreBigData: 'a'.repeat(130),
id: terminalLink('36329', 'https://example.com/alice'),
Expand Down Expand Up @@ -35,12 +35,20 @@ makeTable(
data,
[
'id',
'name',
{align: 'center', key: 'name', name: 'First Name'},
'age',
'employed',
'bigData',
'moreBigData',
// 'moreBigData',
// 'evenMoreBigData',
],
{maxWidth: '50%'},
{
borderStyle: 'outline',
headerFormatter: 'capitalCase',
headerOptions: {
bold: true,
color: '#905de8',
},
overflow: 'wrap',
},
)
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dependencies": {
"@oclif/core": "^4",
"@types/react": "^18.3.3",
"change-case": "^5.4.4",
"ink": "^5.0.1",
"object-hash": "^3.0.0",
"react": "^18.3.1",
Expand Down
251 changes: 251 additions & 0 deletions src/skeletons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
export type BorderStyle =
| 'all'
| 'vertical'
| 'horizontal'
| 'none'
| 'outline'
| 'vertical-with-outline'
| 'horizontal-with-outline'

type Skeleton = {
cross: string
left: string
line: string
right: string
}

export const BORDER_SKELETONS: Record<
BorderStyle,
{
data: Skeleton
footer: Skeleton
header: Skeleton
heading: Skeleton
separator: Skeleton
}
> = {
all: {
data: {
cross: '│',
left: '│',
line: ' ',
right: '│',
},
footer: {
cross: '┴',
left: '└',
line: '─',
right: '┘',
},
header: {
cross: '┬',
left: '┌',
line: '─',
right: '┐',
},
heading: {
cross: '│',
left: '│',
line: ' ',
right: '│',
},
separator: {
cross: '┼',
left: '├',
line: '─',
right: '┤',
},
},
horizontal: {
data: {
cross: ' ',
left: ' ',
line: ' ',
right: ' ',
},
footer: {
cross: '─',
left: '─',
line: '─',
right: '─',
},
header: {
cross: ' ',
left: ' ',
line: ' ',
right: ' ',
},
heading: {
cross: ' ',
left: ' ',
line: ' ',
right: ' ',
},
separator: {
cross: '─',
left: '─',
line: '─',
right: '─',
},
},
'horizontal-with-outline': {
data: {
cross: ' ',
left: '│',
line: ' ',
right: '│',
},
footer: {
cross: '─',
left: '└',
line: '─',
right: '┘',
},
header: {
cross: '─',
left: '┌',
line: '─',
right: '┐',
},
heading: {
cross: ' ',
left: '│',
line: ' ',
right: '│',
},
separator: {
cross: '─',
left: '├',
line: '─',
right: '┤',
},
},
none: {
data: {
cross: ' ',
left: ' ',
line: ' ',
right: ' ',
},
footer: {
cross: ' ',
left: ' ',
line: ' ',
right: ' ',
},
header: {
cross: ' ',
left: ' ',
line: ' ',
right: ' ',
},
heading: {
cross: ' ',
left: ' ',
line: ' ',
right: ' ',
},
separator: {
cross: ' ',
left: ' ',
line: ' ',
right: ' ',
},
},
outline: {
data: {
cross: ' ',
left: '│',
line: ' ',
right: '│',
},
footer: {
cross: '─',
left: '└',
line: '─',
right: '┘',
},
header: {
cross: '─',
left: '┌',
line: '─',
right: '┐',
},
heading: {
cross: ' ',
left: '│',
line: ' ',
right: '│',
},
separator: {
cross: ' ',
left: '│',
line: ' ',
right: '│',
},
},
vertical: {
data: {
cross: '│',
left: '│',
line: ' ',
right: '│',
},
footer: {
cross: '│',
left: '│',
line: ' ',
right: '│',
},
header: {
cross: ' ',
left: ' ',
line: ' ',
right: ' ',
},
heading: {
cross: ' ',
left: ' ',
line: ' ',
right: ' ',
},
separator: {
cross: '│',
left: '│',
line: ' ',
right: '│',
},
},
'vertical-with-outline': {
data: {
cross: '│',
left: '│',
line: ' ',
right: '│',
},
footer: {
cross: '┴',
left: '└',
line: '─',
right: '┘',
},
header: {
cross: '┬',
left: '┌',
line: '─',
right: '┐',
},
heading: {
cross: '│',
left: '│',
line: ' ',
right: '│',
},
separator: {
cross: '│',
left: '│',
line: ' ',
right: '│',
},
},
}
Loading

0 comments on commit 6fa62ef

Please sign in to comment.