-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.js
45 lines (33 loc) · 1.05 KB
/
index.js
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
const util = require("@mdi/util");
const meta = util.getMeta(true);
const find = /(\-\w)/g;
const convert = function (matches) {
return matches[1].toUpperCase();
};
const lines = meta.map((icon) => {
let name = icon.name.replace(find, convert);
name = `${name[0].toLowerCase()}${name.slice(1)}`;
if (["null", "switch", "sync", "factory"].includes(name)) {
name = `${name}Icon`;
}
return ` /// Icon for ${icon.name}.
static const ${name} = MdiIconData(0x${icon.codepoint});
`;
});
const output = `// Material Design Icons v${util.getVersion()}
library mdi;
import 'package:flutter/widgets.dart';
const _fontFamily = 'Material Design Icons';
const _packageName = 'mdi';
/// A const wrapper for [IconData].
class MdiIconData extends IconData {
const MdiIconData(int codePoint)
: super(codePoint, fontFamily: _fontFamily, fontPackage: _packageName);
}
/// Mdi is a collection of icons provided by
/// [Material Design Icons](https://materialdesignicons.com/).
class Mdi {
${lines.join("\n")}
}
`;
util.write("mdi/lib/mdi.dart", output);