-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_props.js
More file actions
270 lines (223 loc) · 7.02 KB
/
gen_props.js
File metadata and controls
270 lines (223 loc) · 7.02 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
const props = {
text: {
type: String,
default: ''
},
boxShadow: {
type: String,
default: 'none'
},
backgroundColor: {
type: String,
default: '#0d1117'
},
borderRadius: {
type: [Number, String],
default: 0
},
codeFontSize: {
type: [Number, String],
default: 20
},
codeColor: {
type: String,
default: 'white'
},
appendText: {
type: String,
default: null
},
appendLocation: {
type: String,
default: 'top-right'
},
footerFontSize: {
type: Number,
default: 15
},
paddingTop: {
type: [Number, String],
default: 5
},
paddingBottom: {
type: [Number, String],
default: 5,
},
paddingLeft: {
type: Number,
default: 15
},
highlight: {},
headerText: {
type: String,
default: ''
},
highlightGroups: {
type: Array,
},
highlightRow: {
type: Boolean,
default: false
},
highlightRowBackgroundColor: {
type: String,
default: 'rgba(112,112,112,0.05)'
},
highlightLineNumColor: {
type: String,
},
highlightLineNumBackgroundColor: {
type: String,
default: 'rgba(112,112,112,0.05)'
},
highlightLineNumBorder: {
type: String,
default: '1px solid currentColor'
},
highlightLineNumWidth: {
type: String,
default: '0 0 0 0'
},
highlightLineNumOpacity: {
type: Number,
default: 1
},
headerBackgroundColor: {
type: [String, null],
default: null
},
headerColor: {
type: String,
default: 'white'
},
headerFontSize: {
type: Number,
default: 15
},
footerBackgroundColor: {
type: [String, null],
default: null
},
readOnly: {
type: Boolean,
default: false
},
maxLines: {
type: [Number, String],
default: -1
},
minLines: {
type: [Number, String],
default: null
},
lineNumberBorder: {
type: String,
default: '1px solid rgb(201, 209, 217, .3)'
},
lineNumberColor: {
type: String,
default: 'rgb(201, 209, 217)'
},
lineNumberOpacity: {
type: Number,
default: .3
},
showHeader: {
type: Boolean,
default: false
},
showFooter: {
type: Boolean,
default: false
},
showBorderTop: {
type: Boolean,
default: true
},
showLineNumber: {
type: Boolean,
default: true
},
tabSpaces: {
type: Number,
default: 2
},
prependInline: {
type: Boolean,
default: true
},
prependText: {
type: String,
default: ''
},
prependLocation: {
type: String,
default: "top-left"
}
};
const propsComments = {
'v-model': 'The Vue 3 two-way binding prop, use this with `ref`',
text: 'Prop for displaying text, if no v-model is provided a ref(text) will be created and binded to the input\'s v-model',
boxShadow: 'box-shadow applied to the most outer div',
backgroundColor: 'background-color applied to the main code section',
borderRadius: 'border-radius applied to the code section, header and footer.',
codeFontSize: 'font-size applied to the code section.',
codeColor: 'color applied to the code\'s text',
appendText: 'Text displayed on the right side of the component, even though via location you can override and display on the left.',
appendLocation: 'Location of the append Text',
footerFontSize: 'Font size of the footer',
showFooter: 'Display the footer',
footerBackgroundColor: 'Background color of the footer',
headerBackgroundColor: 'Background color of the header',
headerColor: 'Color of the header text',
headerText: 'Text of the text',
headerFontSize: 'Font size of the header\'s text',
showHeader: 'Display the header',
showBorderTop: 'Display the border-top of the code\'s section',
showLineNumber: 'Display line numbers on the left side of the code section',
prependInline: 'If true the component will be added a left calculated left padding, useful to display non-overlapping text on the left, for example the $ of $ npm install',
prependLocation: 'Location of the prepend text',
prependText: 'Text displayed on the left side of the code\'s section',
tabSpaces: 'Spaces per tab',
lineNumberBorder: 'Border applied to the line number section',
lineNumberColor: 'Color of the line number section\'s text',
lineNumberOpacity: 'Opacity of the number section\'s text, <.5 usually look nice.',
highlightLineNumBackgroundColor: 'Background color of the line number section when the row is highlighted, only applied to one row',
highlightLineNumBorder: 'Border applied to the line number section when the row is highlighted, only applied to one row',
highlightLineNumColor: 'Color applied to the line number section when the row is highlighted, only applied to one row',
highlightLineNumOpacity: 'Opacity applied to the line number section when the row is highlighted, only applied to one row',
highlightRow: 'If the rows should be highlighted, highlights only the current selected row by the cursor',
highlightLineNumWidth: 'Width of the border applied to the line number section when the row is highlighted, it is made of 4 components, top, left, bottom, right',
highlightRowBackgroundColor: 'Background color of the code\'s highlighted row',
highlight: 'Callback to apply transformations to the v-model',
highlightGroups: 'Highlights several rows, see THIS to see how it works.',
paddingLeft: 'Padding applied to the code\'s left side',
paddingRight: 'Padding applied to the code\'s right side',
paddingTop: 'Padding applied to the code\'s top side',
paddingBottom: 'Padding applied to the code\'s bottom side',
maxLines: 'Maximum amount of lines that can be displayed at the same time',
minLines: 'Minimum amount of lines that are displayed, if no maxLines is present, it will grow infinitely',
readOnly: 'If the component is read only, if so, it will be just a code block, otherwise it will be an editor'
};
const newProps = [];
for (const [key, value] of Object.entries(props)) {
const propName = key;
const types = [];
if (typeof value.type === 'object') {
for (const keyElement of value.type) {
if (keyElement) {
types.push(keyElement.name);
} else {
types.push(keyElement);
}
}
} else {
if (value.type){
types.push(value.type.name);
} else {
types.push(null);
}
}
newProps.push({name: propName, types: types, default: value.default, required: false, msg: propsComments[propName]});
}
console.log(newProps.sort((a, b) => a.name.localeCompare(b.name)));