-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender-luminars.ts
103 lines (89 loc) Β· 2.1 KB
/
render-luminars.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import type { Luminars } from '../types'
import { kebabCase } from '../utils/convert-case'
const tableBreakpoints = {
'> 80': [
{
width: 'content-width',
paddingLeft: 2,
paddingRight: 8,
},
// Luminar alias to fill remaining line
{
width: 'auto',
},
],
'> 40': [
{
width: 'auto',
paddingLeft: 2,
paddingRight: 8,
// Remove alias padding on smaller screens
preprocess: (text: string) => text.trim(),
},
// Luminar description to be on own line
{
width: '100%',
paddingLeft: 2,
paddingBottom: 1,
},
],
'> 0': {
// Remove responsiveness
stdoutColumns: 1000,
columns: [
{
width: 'content-width',
paddingLeft: 2,
paddingRight: 8,
},
{
width: 'content-width',
},
],
},
}
export interface LuminarData {
name: string
luminar: Luminars[string]
luminarFormatted: string
aliasesEnabled: boolean
aliasFormatted: string | undefined
}
export function renderLuminars(luminars: Luminars) {
let aliasesEnabled = false
const luminarsData = Object.keys(luminars)
.sort((a, b) => a.localeCompare(b))
.map((name): LuminarData => {
const luminar = luminars[name]
const hasAlias = ('alias' in luminar)
if (hasAlias)
aliasesEnabled = true
return {
name,
luminar,
luminarFormatted: `--${kebabCase(name)}`,
aliasesEnabled,
aliasFormatted: hasAlias ? `-${luminar.alias}` : undefined,
}
})
const tableData = luminarsData.map((luminarData) => {
luminarData.aliasesEnabled = aliasesEnabled
return [
{
type: 'luminarName',
data: luminarData,
},
{
type: 'luminarDescription',
data: luminarData,
},
]
})
return {
type: 'table',
data: {
tableData,
tableBreakpoints,
},
}
}