diff --git a/.dependabot/config.yml b/.dependabot/config.yml new file mode 100644 index 0000000..db50316 --- /dev/null +++ b/.dependabot/config.yml @@ -0,0 +1,16 @@ +version: 1 +update_configs: + - package_manager: "javascript" + update_schedule: "daily" + directory: "/" + ignored_updates: + - match: + dependency_name: "@babel/*" + - match: + dependency_name: "babel-jest" + - match: + dependency_name: "jest" + - match: + dependency_name: "lint-staged" + - match: + dependency_name: "husky" diff --git a/.gitignore b/.gitignore index 8ef672c..63f986b 100644 --- a/.gitignore +++ b/.gitignore @@ -129,6 +129,8 @@ typings/ .next ### Customize +fonts/ + package-lock.json yarn.lock diff --git a/.npmignore b/.npmignore index e70c947..445fa93 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,4 @@ -.editorconfig -.gitignore -.npmignore -generate-icon.js +.* + +script/ +test/ diff --git a/babel.config.js b/babel.config.js index c76a0d0..392abb6 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,12 +1,12 @@ module.exports = { presets: [ [ - '@babel/preset-env', + "@babel/preset-env", { targets: { - node: 'current' - } - } - ] - ] -} + node: "current", + }, + }, + ], + ], +}; diff --git a/fonts/Ionicons.ttf b/fonts/Ionicons.ttf deleted file mode 100644 index ffd7d6f..0000000 Binary files a/fonts/Ionicons.ttf and /dev/null differ diff --git a/generate.js b/generate.js deleted file mode 100755 index e8ad398..0000000 --- a/generate.js +++ /dev/null @@ -1,64 +0,0 @@ -#! /usr/bin/env node - -const fs = require('fs') -const path = require('path') - -/** - * @param {any} value - * @return {string} - */ -function stringify(value) { - return JSON.stringify(value, null, 2) -} - -/** - * @param {string} text - * @return {Object.} - */ -function parseGlyphs(text) { - const glyph = {} - const regex = /ion-([^:]+):before.+content:\s*"\\(\w+)"/gm - for (let result; (result = regex.exec(text)); ) { - glyph[result[1]] = parseInt(result[2], 16) - } - - return glyph -} - -function resolvePath(file) { - return `${__dirname}/node_modules/ionicons/dist/${file}` -} - -const FILES = (exports.FILES = { - GLYPH_MAP: 'glyph/map.json', - FONT_FILE: 'fonts/Ionicons.ttf' -}) - -function generate() { - const workflows = [ - { - file: FILES.GLYPH_MAP, - from: 'scss/ionicons-icons.scss', - steps: [String, parseGlyphs, stringify] - }, - { - file: FILES.FONT_FILE, - from: 'fonts/ionicons.ttf', - steps: [] - } - ].map(({ file, from, steps }) => - [resolvePath, fs.readFileSync, ...steps] - .reduce((prev, next) => prev.then(next), Promise.resolve(from)) - .then(it => fs.writeFileSync(path.resolve(__dirname, file), it)) - .then(() => console.log(` Generated ${file} ...`)) - ) - - Promise.all(workflows) - .then(() => console.log('All is done')) - .catch(e => console.log(e.message)) -} - -// only run as script -if (require.main === module) { - generate() -} diff --git a/glyph.js b/glyph.js new file mode 100644 index 0000000..2f51639 --- /dev/null +++ b/glyph.js @@ -0,0 +1,14 @@ +import map from "./fonts/Ionicons.json"; + +/** + * Try glyph + * + * @param {Array.} iconNames + * @return {string} + */ +export function tryGlyph(iconNames) { + const code = iconNames.reduce((prev, key) => prev || map[key], undefined); + return code ? String.fromCharCode(code) : UNKNOWN_ICON; +} + +export const UNKNOWN_ICON = ""; diff --git a/glyph/index.js b/glyph/index.js deleted file mode 100644 index 85e5ae4..0000000 --- a/glyph/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import glyphs from './map.json' - -export const UNKNOWN_ICON = '' - -/** - * Try glyph - * - * @param {Array.} iconNames - * @param {function(string): string} mapper - * @return {string} - */ -export function tryGlyph(iconNames, mapper) { - const code = iconNames.reduce((prev, name) => { - return prev || glyphs[name in glyphs ? name : mapper(name)] - }, undefined) - - return code ? String.fromCharCode(code) : UNKNOWN_ICON -} - -/** - * @typedef - */ diff --git a/glyph/map.json b/glyph/map.json deleted file mode 100644 index 255ffdf..0000000 --- a/glyph/map.json +++ /dev/null @@ -1,698 +0,0 @@ -{ - "ios-add": 61698, - "ios-add-circle": 61697, - "ios-add-circle-outline": 61696, - "ios-airplane": 61751, - "ios-alarm": 62408, - "ios-albums": 62410, - "ios-alert": 61700, - "ios-american-football": 61702, - "ios-analytics": 62414, - "ios-aperture": 61704, - "ios-apps": 61706, - "ios-appstore": 61708, - "ios-archive": 61710, - "ios-arrow-back": 62415, - "ios-arrow-down": 62416, - "ios-arrow-dropdown": 61712, - "ios-arrow-dropdown-circle": 61733, - "ios-arrow-dropleft": 61714, - "ios-arrow-dropleft-circle": 61737, - "ios-arrow-dropright": 61716, - "ios-arrow-dropright-circle": 61739, - "ios-arrow-dropup": 61718, - "ios-arrow-dropup-circle": 61741, - "ios-arrow-forward": 62417, - "ios-arrow-round-back": 61719, - "ios-arrow-round-down": 61720, - "ios-arrow-round-forward": 61721, - "ios-arrow-round-up": 61722, - "ios-arrow-up": 62424, - "ios-at": 62426, - "ios-attach": 61723, - "ios-backspace": 61725, - "ios-barcode": 62428, - "ios-baseball": 62430, - "ios-basket": 61727, - "ios-basketball": 62432, - "ios-battery-charging": 61728, - "ios-battery-dead": 61729, - "ios-battery-full": 61730, - "ios-beaker": 61732, - "ios-bed": 61753, - "ios-beer": 61734, - "ios-bicycle": 61735, - "ios-bluetooth": 61736, - "ios-boat": 61738, - "ios-body": 62436, - "ios-bonfire": 61740, - "ios-book": 62440, - "ios-bookmark": 61742, - "ios-bookmarks": 62442, - "ios-bowtie": 61744, - "ios-briefcase": 62446, - "ios-browsers": 62448, - "ios-brush": 61746, - "ios-bug": 61748, - "ios-build": 61750, - "ios-bulb": 61752, - "ios-bus": 61754, - "ios-business": 61859, - "ios-cafe": 61756, - "ios-calculator": 62450, - "ios-calendar": 62452, - "ios-call": 61758, - "ios-camera": 62454, - "ios-car": 61760, - "ios-card": 61762, - "ios-cart": 62456, - "ios-cash": 61764, - "ios-cellular": 61757, - "ios-chatboxes": 62458, - "ios-chatbubbles": 61766, - "ios-checkbox": 61768, - "ios-checkbox-outline": 61767, - "ios-checkmark": 62463, - "ios-checkmark-circle": 61770, - "ios-checkmark-circle-outline": 61769, - "ios-clipboard": 61772, - "ios-clock": 62467, - "ios-close": 62470, - "ios-close-circle": 61774, - "ios-close-circle-outline": 61773, - "ios-cloud": 62476, - "ios-cloud-circle": 61778, - "ios-cloud-done": 61780, - "ios-cloud-download": 62472, - "ios-cloud-outline": 62473, - "ios-cloud-upload": 62475, - "ios-cloudy": 62480, - "ios-cloudy-night": 62478, - "ios-code": 61783, - "ios-code-download": 61781, - "ios-code-working": 61782, - "ios-cog": 62482, - "ios-color-fill": 61785, - "ios-color-filter": 62484, - "ios-color-palette": 61787, - "ios-color-wand": 62486, - "ios-compass": 61789, - "ios-construct": 61791, - "ios-contact": 62490, - "ios-contacts": 61793, - "ios-contract": 61794, - "ios-contrast": 61795, - "ios-copy": 62492, - "ios-create": 61797, - "ios-crop": 62494, - "ios-cube": 61800, - "ios-cut": 61802, - "ios-desktop": 61804, - "ios-disc": 61806, - "ios-document": 61808, - "ios-done-all": 61809, - "ios-download": 62496, - "ios-easel": 61811, - "ios-egg": 61813, - "ios-exit": 61815, - "ios-expand": 61816, - "ios-eye": 62501, - "ios-eye-off": 61818, - "ios-fastforward": 62503, - "ios-female": 61819, - "ios-filing": 62505, - "ios-film": 62507, - "ios-finger-print": 61820, - "ios-fitness": 61867, - "ios-flag": 62509, - "ios-flame": 62511, - "ios-flash": 61822, - "ios-flash-off": 61743, - "ios-flashlight": 61761, - "ios-flask": 62513, - "ios-flower": 62515, - "ios-folder": 62517, - "ios-folder-open": 61824, - "ios-football": 62519, - "ios-funnel": 61826, - "ios-gift": 61841, - "ios-git-branch": 61827, - "ios-git-commit": 61828, - "ios-git-compare": 61829, - "ios-git-merge": 61830, - "ios-git-network": 61831, - "ios-git-pull-request": 61832, - "ios-glasses": 62527, - "ios-globe": 61834, - "ios-grid": 61836, - "ios-hammer": 61838, - "ios-hand": 61840, - "ios-happy": 61842, - "ios-headset": 61844, - "ios-heart": 62531, - "ios-heart-dislike": 61759, - "ios-heart-empty": 61851, - "ios-heart-half": 61853, - "ios-help": 62534, - "ios-help-buoy": 61846, - "ios-help-circle": 61848, - "ios-help-circle-outline": 61847, - "ios-home": 62536, - "ios-hourglass": 61699, - "ios-ice-cream": 61850, - "ios-image": 61852, - "ios-images": 61854, - "ios-infinite": 62538, - "ios-information": 62541, - "ios-information-circle": 61856, - "ios-information-circle-outline": 61855, - "ios-jet": 61861, - "ios-journal": 61833, - "ios-key": 61863, - "ios-keypad": 62544, - "ios-laptop": 61864, - "ios-leaf": 61866, - "ios-link": 61994, - "ios-list": 62548, - "ios-list-box": 61763, - "ios-locate": 61870, - "ios-lock": 61872, - "ios-log-in": 61873, - "ios-log-out": 61874, - "ios-magnet": 61876, - "ios-mail": 61880, - "ios-mail-open": 61878, - "ios-mail-unread": 61765, - "ios-male": 61881, - "ios-man": 61883, - "ios-map": 61885, - "ios-medal": 61887, - "ios-medical": 62556, - "ios-medkit": 62558, - "ios-megaphone": 61889, - "ios-menu": 61891, - "ios-mic": 62561, - "ios-mic-off": 62559, - "ios-microphone": 61894, - "ios-moon": 62568, - "ios-more": 61896, - "ios-move": 61899, - "ios-musical-note": 62571, - "ios-musical-notes": 62572, - "ios-navigate": 62574, - "ios-notifications": 61907, - "ios-notifications-off": 61905, - "ios-notifications-outline": 61747, - "ios-nuclear": 61909, - "ios-nutrition": 62576, - "ios-open": 61911, - "ios-options": 61913, - "ios-outlet": 61915, - "ios-paper": 62578, - "ios-paper-plane": 61917, - "ios-partly-sunny": 61919, - "ios-pause": 62584, - "ios-paw": 62586, - "ios-people": 62588, - "ios-person": 62590, - "ios-person-add": 61921, - "ios-phone-landscape": 61922, - "ios-phone-portrait": 61923, - "ios-photos": 62594, - "ios-pie": 62596, - "ios-pin": 61925, - "ios-pint": 62598, - "ios-pizza": 61927, - "ios-planet": 61931, - "ios-play": 62600, - "ios-play-circle": 61715, - "ios-podium": 61933, - "ios-power": 61935, - "ios-pricetag": 62605, - "ios-pricetags": 62607, - "ios-print": 61937, - "ios-pulse": 62611, - "ios-qr-scanner": 61939, - "ios-quote": 61941, - "ios-radio": 61945, - "ios-radio-button-off": 61942, - "ios-radio-button-on": 61943, - "ios-rainy": 62613, - "ios-recording": 62615, - "ios-redo": 62617, - "ios-refresh": 62620, - "ios-refresh-circle": 61749, - "ios-remove": 61948, - "ios-remove-circle": 61947, - "ios-remove-circle-outline": 61946, - "ios-reorder": 61949, - "ios-repeat": 61950, - "ios-resize": 61951, - "ios-restaurant": 61953, - "ios-return-left": 61954, - "ios-return-right": 61955, - "ios-reverse-camera": 62623, - "ios-rewind": 62625, - "ios-ribbon": 61957, - "ios-rocket": 61771, - "ios-rose": 62627, - "ios-sad": 61959, - "ios-save": 61862, - "ios-school": 61961, - "ios-search": 62629, - "ios-send": 61964, - "ios-settings": 62631, - "ios-share": 61969, - "ios-share-alt": 61967, - "ios-shirt": 61971, - "ios-shuffle": 62633, - "ios-skip-backward": 61973, - "ios-skip-forward": 61975, - "ios-snow": 61976, - "ios-speedometer": 62640, - "ios-square": 61978, - "ios-square-outline": 61788, - "ios-star": 62643, - "ios-star-half": 62641, - "ios-star-outline": 62642, - "ios-stats": 61980, - "ios-stopwatch": 62645, - "ios-subway": 61982, - "ios-sunny": 62647, - "ios-swap": 61983, - "ios-switch": 61985, - "ios-sync": 61986, - "ios-tablet-landscape": 61987, - "ios-tablet-portrait": 62030, - "ios-tennisball": 62651, - "ios-text": 62032, - "ios-thermometer": 62034, - "ios-thumbs-down": 62036, - "ios-thumbs-up": 62038, - "ios-thunderstorm": 62653, - "ios-time": 62655, - "ios-timer": 62657, - "ios-today": 61775, - "ios-train": 62040, - "ios-transgender": 62041, - "ios-trash": 62661, - "ios-trending-down": 62042, - "ios-trending-up": 62043, - "ios-trophy": 62045, - "ios-tv": 61717, - "ios-umbrella": 62047, - "ios-undo": 62663, - "ios-unlock": 62049, - "ios-videocam": 62669, - "ios-volume-high": 61724, - "ios-volume-low": 61726, - "ios-volume-mute": 62051, - "ios-volume-off": 62052, - "ios-walk": 62054, - "ios-wallet": 61835, - "ios-warning": 62056, - "ios-watch": 62057, - "ios-water": 62059, - "ios-wifi": 62061, - "ios-wine": 62063, - "ios-woman": 62065, - "logo-android": 61989, - "logo-angular": 61991, - "logo-apple": 61993, - "logo-bitbucket": 61843, - "logo-bitcoin": 61995, - "logo-buffer": 61997, - "logo-chrome": 61999, - "logo-closed-captioning": 61701, - "logo-codepen": 62000, - "logo-css3": 62001, - "logo-designernews": 62002, - "logo-dribbble": 62003, - "logo-dropbox": 62004, - "logo-euro": 62005, - "logo-facebook": 62006, - "logo-flickr": 61703, - "logo-foursquare": 62007, - "logo-freebsd-devil": 62008, - "logo-game-controller-a": 61755, - "logo-game-controller-b": 61825, - "logo-github": 62009, - "logo-google": 62010, - "logo-googleplus": 62011, - "logo-hackernews": 62012, - "logo-html5": 62013, - "logo-instagram": 62014, - "logo-ionic": 61776, - "logo-ionitron": 61777, - "logo-javascript": 62015, - "logo-linkedin": 62016, - "logo-markdown": 62017, - "logo-model-s": 61779, - "logo-no-smoking": 61705, - "logo-nodejs": 62018, - "logo-npm": 61845, - "logo-octocat": 62019, - "logo-pinterest": 62020, - "logo-playstation": 62021, - "logo-polymer": 61790, - "logo-python": 62022, - "logo-reddit": 62023, - "logo-rss": 62024, - "logo-sass": 62025, - "logo-skype": 62026, - "logo-slack": 61707, - "logo-snapchat": 62027, - "logo-steam": 62028, - "logo-tumblr": 62029, - "logo-tux": 62126, - "logo-twitch": 62127, - "logo-twitter": 62128, - "logo-usd": 62129, - "logo-vimeo": 62148, - "logo-vk": 61709, - "logo-whatsapp": 62149, - "logo-windows": 62255, - "logo-wordpress": 62256, - "logo-xbox": 62284, - "logo-xing": 61711, - "logo-yahoo": 62285, - "logo-yen": 62286, - "logo-youtube": 62287, - "md-add": 62067, - "md-add-circle": 62066, - "md-add-circle-outline": 61784, - "md-airplane": 61786, - "md-alarm": 62068, - "md-albums": 62069, - "md-alert": 62070, - "md-american-football": 62071, - "md-analytics": 62072, - "md-aperture": 62073, - "md-apps": 62074, - "md-appstore": 62075, - "md-archive": 62076, - "md-arrow-back": 62077, - "md-arrow-down": 62078, - "md-arrow-dropdown": 62080, - "md-arrow-dropdown-circle": 62079, - "md-arrow-dropleft": 62082, - "md-arrow-dropleft-circle": 62081, - "md-arrow-dropright": 62084, - "md-arrow-dropright-circle": 62083, - "md-arrow-dropup": 62086, - "md-arrow-dropup-circle": 62085, - "md-arrow-forward": 62087, - "md-arrow-round-back": 62088, - "md-arrow-round-down": 62089, - "md-arrow-round-forward": 62090, - "md-arrow-round-up": 62091, - "md-arrow-up": 62092, - "md-at": 62093, - "md-attach": 62094, - "md-backspace": 62095, - "md-barcode": 62096, - "md-baseball": 62097, - "md-basket": 62098, - "md-basketball": 62099, - "md-battery-charging": 62100, - "md-battery-dead": 62101, - "md-battery-full": 62102, - "md-beaker": 62103, - "md-bed": 61792, - "md-beer": 62104, - "md-bicycle": 62105, - "md-bluetooth": 62106, - "md-boat": 62107, - "md-body": 62108, - "md-bonfire": 62109, - "md-book": 62110, - "md-bookmark": 62111, - "md-bookmarks": 62112, - "md-bowtie": 62113, - "md-briefcase": 62114, - "md-browsers": 62115, - "md-brush": 62116, - "md-bug": 62117, - "md-build": 62118, - "md-bulb": 62119, - "md-bus": 62120, - "md-business": 61860, - "md-cafe": 62121, - "md-calculator": 62122, - "md-calendar": 62123, - "md-call": 62124, - "md-camera": 62125, - "md-car": 62130, - "md-card": 62131, - "md-cart": 62132, - "md-cash": 62133, - "md-cellular": 61796, - "md-chatboxes": 62134, - "md-chatbubbles": 62135, - "md-checkbox": 62137, - "md-checkbox-outline": 62136, - "md-checkmark": 62140, - "md-checkmark-circle": 62139, - "md-checkmark-circle-outline": 62138, - "md-clipboard": 62141, - "md-clock": 62142, - "md-close": 62144, - "md-close-circle": 62143, - "md-close-circle-outline": 61798, - "md-cloud": 62153, - "md-cloud-circle": 62146, - "md-cloud-done": 62147, - "md-cloud-download": 62150, - "md-cloud-outline": 62151, - "md-cloud-upload": 62152, - "md-cloudy": 62155, - "md-cloudy-night": 62154, - "md-code": 62158, - "md-code-download": 62156, - "md-code-working": 62157, - "md-cog": 62159, - "md-color-fill": 62160, - "md-color-filter": 62161, - "md-color-palette": 62162, - "md-color-wand": 62163, - "md-compass": 62164, - "md-construct": 62165, - "md-contact": 62166, - "md-contacts": 62167, - "md-contract": 62168, - "md-contrast": 62169, - "md-copy": 62170, - "md-create": 62171, - "md-crop": 62172, - "md-cube": 62173, - "md-cut": 62174, - "md-desktop": 62175, - "md-disc": 62176, - "md-document": 62177, - "md-done-all": 62178, - "md-download": 62179, - "md-easel": 62180, - "md-egg": 62181, - "md-exit": 62182, - "md-expand": 62183, - "md-eye": 62185, - "md-eye-off": 62184, - "md-fastforward": 62186, - "md-female": 62187, - "md-filing": 62188, - "md-film": 62189, - "md-finger-print": 62190, - "md-fitness": 61868, - "md-flag": 62191, - "md-flame": 62192, - "md-flash": 62193, - "md-flash-off": 61801, - "md-flashlight": 61803, - "md-flask": 62194, - "md-flower": 62195, - "md-folder": 62197, - "md-folder-open": 62196, - "md-football": 62198, - "md-funnel": 62199, - "md-gift": 61849, - "md-git-branch": 62202, - "md-git-commit": 62203, - "md-git-compare": 62204, - "md-git-merge": 62205, - "md-git-network": 62206, - "md-git-pull-request": 62207, - "md-glasses": 62208, - "md-globe": 62209, - "md-grid": 62210, - "md-hammer": 62211, - "md-hand": 62212, - "md-happy": 62213, - "md-headset": 62214, - "md-heart": 62216, - "md-heart-dislike": 61799, - "md-heart-empty": 61857, - "md-heart-half": 61858, - "md-help": 62219, - "md-help-buoy": 62217, - "md-help-circle": 62218, - "md-help-circle-outline": 61805, - "md-home": 62220, - "md-hourglass": 61713, - "md-ice-cream": 62221, - "md-image": 62222, - "md-images": 62223, - "md-infinite": 62224, - "md-information": 62226, - "md-information-circle": 62225, - "md-information-circle-outline": 61807, - "md-jet": 62229, - "md-journal": 61837, - "md-key": 62230, - "md-keypad": 62231, - "md-laptop": 62232, - "md-leaf": 62233, - "md-link": 61998, - "md-list": 62235, - "md-list-box": 62234, - "md-locate": 62236, - "md-lock": 62237, - "md-log-in": 62238, - "md-log-out": 62239, - "md-magnet": 62240, - "md-mail": 62242, - "md-mail-open": 62241, - "md-mail-unread": 61810, - "md-male": 62243, - "md-man": 62244, - "md-map": 62245, - "md-medal": 62246, - "md-medical": 62247, - "md-medkit": 62248, - "md-megaphone": 62249, - "md-menu": 62250, - "md-mic": 62252, - "md-mic-off": 62251, - "md-microphone": 62253, - "md-moon": 62254, - "md-more": 61897, - "md-move": 62257, - "md-musical-note": 62258, - "md-musical-notes": 62259, - "md-navigate": 62260, - "md-notifications": 62264, - "md-notifications-off": 62262, - "md-notifications-outline": 62263, - "md-nuclear": 62265, - "md-nutrition": 62266, - "md-open": 62267, - "md-options": 62268, - "md-outlet": 62269, - "md-paper": 62271, - "md-paper-plane": 62270, - "md-partly-sunny": 62272, - "md-pause": 62273, - "md-paw": 62274, - "md-people": 62275, - "md-person": 62277, - "md-person-add": 62276, - "md-phone-landscape": 62278, - "md-phone-portrait": 62279, - "md-photos": 62280, - "md-pie": 62281, - "md-pin": 62282, - "md-pint": 62283, - "md-pizza": 62292, - "md-planet": 62294, - "md-play": 62295, - "md-play-circle": 61812, - "md-podium": 62296, - "md-power": 62297, - "md-pricetag": 62298, - "md-pricetags": 62299, - "md-print": 62300, - "md-pulse": 62301, - "md-qr-scanner": 62302, - "md-quote": 62303, - "md-radio": 62306, - "md-radio-button-off": 62304, - "md-radio-button-on": 62305, - "md-rainy": 62307, - "md-recording": 62308, - "md-redo": 62309, - "md-refresh": 62310, - "md-refresh-circle": 61992, - "md-remove": 62312, - "md-remove-circle": 62311, - "md-remove-circle-outline": 61814, - "md-reorder": 62313, - "md-repeat": 62314, - "md-resize": 62315, - "md-restaurant": 62316, - "md-return-left": 62317, - "md-return-right": 62318, - "md-reverse-camera": 62319, - "md-rewind": 62320, - "md-ribbon": 62321, - "md-rocket": 61817, - "md-rose": 62322, - "md-sad": 62323, - "md-save": 61865, - "md-school": 62324, - "md-search": 62325, - "md-send": 62326, - "md-settings": 62327, - "md-share": 62329, - "md-share-alt": 62328, - "md-shirt": 62330, - "md-shuffle": 62331, - "md-skip-backward": 62332, - "md-skip-forward": 62333, - "md-snow": 62334, - "md-speedometer": 62335, - "md-square": 62337, - "md-square-outline": 62336, - "md-star": 62340, - "md-star-half": 62338, - "md-star-outline": 62339, - "md-stats": 62341, - "md-stopwatch": 62342, - "md-subway": 62343, - "md-sunny": 62344, - "md-swap": 62345, - "md-switch": 62346, - "md-sync": 62347, - "md-tablet-landscape": 62348, - "md-tablet-portrait": 62349, - "md-tennisball": 62350, - "md-text": 62351, - "md-thermometer": 62352, - "md-thumbs-down": 62353, - "md-thumbs-up": 62354, - "md-thunderstorm": 62355, - "md-time": 62356, - "md-timer": 62357, - "md-today": 61821, - "md-train": 62358, - "md-transgender": 62359, - "md-trash": 62360, - "md-trending-down": 62361, - "md-trending-up": 62362, - "md-trophy": 62363, - "md-tv": 61823, - "md-umbrella": 62364, - "md-undo": 62365, - "md-unlock": 62366, - "md-videocam": 62367, - "md-volume-high": 61731, - "md-volume-low": 61745, - "md-volume-mute": 62369, - "md-volume-off": 62370, - "md-walk": 62372, - "md-wallet": 61839, - "md-warning": 62373, - "md-watch": 62374, - "md-water": 62375, - "md-wifi": 62376, - "md-wine": 62377, - "md-woman": 62378 -} diff --git a/index.d.ts b/index.d.ts index 4566505..710e9eb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,16 +1,1248 @@ -declare module 'react-native-ionicons' { - import React from 'react' - import { TextProps } from 'react-native' +/** + * This was generated by script/prepareType + * Please DO NOT change it manually. + */ - export type IconProps = TextProps & { - name?: string - android?: string - ios?: string - color?: string - size?: number - } +declare module "react-native-ionicons" { + import * as React from "react"; + import { TextProps } from "react-native"; + + export default class Icon extends React.PureComponent {} - class Icon extends React.PureComponent {} + export interface IconProps extends TextProps { + name?: IconName; + ios?: IconName; + android?: IconName; + color?: string; + size?: number; + } - export default Icon + export type IconName = + | "add" + | "add-circle" + | "add-circle-outline" + | "add-circle-sharp" + | "add-outline" + | "add-sharp" + | "airplane" + | "airplane-outline" + | "airplane-sharp" + | "alarm" + | "alarm-outline" + | "alarm-sharp" + | "albums" + | "albums-outline" + | "albums-sharp" + | "alert" + | "alert-circle" + | "alert-circle-outline" + | "alert-circle-sharp" + | "alert-outline" + | "alert-sharp" + | "american-football" + | "american-football-outline" + | "american-football-sharp" + | "analytics" + | "analytics-outline" + | "analytics-sharp" + | "aperture" + | "aperture-outline" + | "aperture-sharp" + | "apps" + | "apps-outline" + | "apps-sharp" + | "archive" + | "archive-outline" + | "archive-sharp" + | "arrow-back" + | "arrow-back-circle" + | "arrow-back-circle-outline" + | "arrow-back-circle-sharp" + | "arrow-back-outline" + | "arrow-back-sharp" + | "arrow-down" + | "arrow-down-circle" + | "arrow-down-circle-outline" + | "arrow-down-circle-sharp" + | "arrow-down-outline" + | "arrow-down-sharp" + | "arrow-forward" + | "arrow-forward-circle" + | "arrow-forward-circle-outline" + | "arrow-forward-circle-sharp" + | "arrow-forward-outline" + | "arrow-forward-sharp" + | "arrow-redo" + | "arrow-redo-circle" + | "arrow-redo-circle-outline" + | "arrow-redo-circle-sharp" + | "arrow-redo-outline" + | "arrow-redo-sharp" + | "arrow-undo" + | "arrow-undo-circle" + | "arrow-undo-circle-outline" + | "arrow-undo-circle-sharp" + | "arrow-undo-outline" + | "arrow-undo-sharp" + | "arrow-up" + | "arrow-up-circle" + | "arrow-up-circle-outline" + | "arrow-up-circle-sharp" + | "arrow-up-outline" + | "arrow-up-sharp" + | "at" + | "at-circle" + | "at-circle-outline" + | "at-circle-sharp" + | "at-outline" + | "at-sharp" + | "attach" + | "attach-outline" + | "attach-sharp" + | "backspace" + | "backspace-outline" + | "backspace-sharp" + | "bandage" + | "bandage-outline" + | "bandage-sharp" + | "bar-chart" + | "bar-chart-outline" + | "bar-chart-sharp" + | "barbell" + | "barbell-outline" + | "barbell-sharp" + | "barcode" + | "barcode-outline" + | "barcode-sharp" + | "baseball" + | "baseball-outline" + | "baseball-sharp" + | "basket" + | "basket-outline" + | "basket-sharp" + | "basketball" + | "basketball-outline" + | "basketball-sharp" + | "battery-charging" + | "battery-charging-outline" + | "battery-charging-sharp" + | "battery-dead" + | "battery-dead-outline" + | "battery-dead-sharp" + | "battery-full" + | "battery-full-outline" + | "battery-full-sharp" + | "battery-half" + | "battery-half-outline" + | "battery-half-sharp" + | "beaker" + | "beaker-outline" + | "beaker-sharp" + | "bed" + | "bed-outline" + | "bed-sharp" + | "beer" + | "beer-outline" + | "beer-sharp" + | "bicycle" + | "bicycle-outline" + | "bicycle-sharp" + | "bluetooth" + | "bluetooth-outline" + | "bluetooth-sharp" + | "boat" + | "boat-outline" + | "boat-sharp" + | "body" + | "body-outline" + | "body-sharp" + | "bonfire" + | "bonfire-outline" + | "bonfire-sharp" + | "book" + | "book-outline" + | "book-sharp" + | "bookmark" + | "bookmark-outline" + | "bookmark-sharp" + | "bookmarks" + | "bookmarks-outline" + | "bookmarks-sharp" + | "briefcase" + | "briefcase-outline" + | "briefcase-sharp" + | "browsers" + | "browsers-outline" + | "browsers-sharp" + | "brush" + | "brush-outline" + | "brush-sharp" + | "bug" + | "bug-outline" + | "bug-sharp" + | "build" + | "build-outline" + | "build-sharp" + | "bulb" + | "bulb-outline" + | "bulb-sharp" + | "bus" + | "bus-outline" + | "bus-sharp" + | "business" + | "business-outline" + | "business-sharp" + | "cafe" + | "cafe-outline" + | "cafe-sharp" + | "calculator" + | "calculator-outline" + | "calculator-sharp" + | "calendar" + | "calendar-outline" + | "calendar-sharp" + | "call" + | "call-outline" + | "call-sharp" + | "camera" + | "camera-outline" + | "camera-reverse" + | "camera-reverse-outline" + | "camera-reverse-sharp" + | "camera-sharp" + | "car" + | "car-outline" + | "car-sharp" + | "car-sport" + | "car-sport-outline" + | "car-sport-sharp" + | "card" + | "card-outline" + | "card-sharp" + | "caret-back" + | "caret-back-circle" + | "caret-back-circle-outline" + | "caret-back-circle-sharp" + | "caret-back-outline" + | "caret-back-sharp" + | "caret-down" + | "caret-down-circle" + | "caret-down-circle-outline" + | "caret-down-circle-sharp" + | "caret-down-outline" + | "caret-down-sharp" + | "caret-forward" + | "caret-forward-circle" + | "caret-forward-circle-outline" + | "caret-forward-circle-sharp" + | "caret-forward-outline" + | "caret-forward-sharp" + | "caret-up" + | "caret-up-circle" + | "caret-up-circle-outline" + | "caret-up-circle-sharp" + | "caret-up-outline" + | "caret-up-sharp" + | "cart" + | "cart-outline" + | "cart-sharp" + | "cash" + | "cash-outline" + | "cash-sharp" + | "cellular" + | "cellular-outline" + | "cellular-sharp" + | "chatbox" + | "chatbox-ellipses" + | "chatbox-ellipses-outline" + | "chatbox-ellipses-sharp" + | "chatbox-outline" + | "chatbox-sharp" + | "chatbubble" + | "chatbubble-ellipses" + | "chatbubble-ellipses-outline" + | "chatbubble-ellipses-sharp" + | "chatbubble-outline" + | "chatbubble-sharp" + | "chatbubbles" + | "chatbubbles-outline" + | "chatbubbles-sharp" + | "checkbox" + | "checkbox-outline" + | "checkbox-sharp" + | "checkmark" + | "checkmark-circle" + | "checkmark-circle-outline" + | "checkmark-circle-sharp" + | "checkmark-done" + | "checkmark-done-circle" + | "checkmark-done-circle-outline" + | "checkmark-done-circle-sharp" + | "checkmark-done-outline" + | "checkmark-done-sharp" + | "checkmark-outline" + | "checkmark-sharp" + | "chevron-back" + | "chevron-back-circle" + | "chevron-back-circle-outline" + | "chevron-back-circle-sharp" + | "chevron-back-outline" + | "chevron-back-sharp" + | "chevron-down" + | "chevron-down-circle" + | "chevron-down-circle-outline" + | "chevron-down-circle-sharp" + | "chevron-down-outline" + | "chevron-down-sharp" + | "chevron-forward" + | "chevron-forward-circle" + | "chevron-forward-circle-outline" + | "chevron-forward-circle-sharp" + | "chevron-forward-outline" + | "chevron-forward-sharp" + | "chevron-up" + | "chevron-up-circle" + | "chevron-up-circle-outline" + | "chevron-up-circle-sharp" + | "chevron-up-outline" + | "chevron-up-sharp" + | "clipboard" + | "clipboard-outline" + | "clipboard-sharp" + | "close" + | "close-circle" + | "close-circle-outline" + | "close-circle-sharp" + | "close-outline" + | "close-sharp" + | "cloud" + | "cloud-circle" + | "cloud-circle-outline" + | "cloud-circle-sharp" + | "cloud-done" + | "cloud-done-outline" + | "cloud-done-sharp" + | "cloud-download" + | "cloud-download-outline" + | "cloud-download-sharp" + | "cloud-offline" + | "cloud-offline-outline" + | "cloud-offline-sharp" + | "cloud-outline" + | "cloud-sharp" + | "cloud-upload" + | "cloud-upload-outline" + | "cloud-upload-sharp" + | "cloudy" + | "cloudy-night" + | "cloudy-night-outline" + | "cloudy-night-sharp" + | "cloudy-outline" + | "cloudy-sharp" + | "code" + | "code-download" + | "code-download-outline" + | "code-download-sharp" + | "code-outline" + | "code-sharp" + | "code-slash" + | "code-slash-outline" + | "code-slash-sharp" + | "code-working" + | "code-working-outline" + | "code-working-sharp" + | "cog" + | "cog-outline" + | "cog-sharp" + | "color-fill" + | "color-fill-outline" + | "color-fill-sharp" + | "color-filter" + | "color-filter-outline" + | "color-filter-sharp" + | "color-palette" + | "color-palette-outline" + | "color-palette-sharp" + | "color-wand" + | "color-wand-outline" + | "color-wand-sharp" + | "compass" + | "compass-outline" + | "compass-sharp" + | "construct" + | "construct-outline" + | "construct-sharp" + | "contract" + | "contract-outline" + | "contract-sharp" + | "contrast" + | "contrast-outline" + | "contrast-sharp" + | "copy" + | "copy-outline" + | "copy-sharp" + | "create" + | "create-outline" + | "create-sharp" + | "crop" + | "crop-outline" + | "crop-sharp" + | "cube" + | "cube-outline" + | "cube-sharp" + | "cut" + | "cut-outline" + | "cut-sharp" + | "desktop" + | "desktop-outline" + | "desktop-sharp" + | "disc" + | "disc-outline" + | "disc-sharp" + | "document" + | "document-attach" + | "document-attach-outline" + | "document-attach-sharp" + | "document-outline" + | "document-sharp" + | "document-text" + | "document-text-outline" + | "document-text-sharp" + | "documents" + | "documents-outline" + | "documents-sharp" + | "download" + | "download-outline" + | "download-sharp" + | "duplicate" + | "duplicate-outline" + | "duplicate-sharp" + | "ear" + | "ear-outline" + | "ear-sharp" + | "earth" + | "earth-outline" + | "earth-sharp" + | "easel" + | "easel-outline" + | "easel-sharp" + | "egg" + | "egg-outline" + | "egg-sharp" + | "ellipse" + | "ellipse-outline" + | "ellipse-sharp" + | "ellipsis-horizontal" + | "ellipsis-horizontal-circle" + | "ellipsis-horizontal-circle-outline" + | "ellipsis-horizontal-circle-sharp" + | "ellipsis-horizontal-outline" + | "ellipsis-horizontal-sharp" + | "ellipsis-vertical" + | "ellipsis-vertical-circle" + | "ellipsis-vertical-circle-outline" + | "ellipsis-vertical-circle-sharp" + | "ellipsis-vertical-outline" + | "ellipsis-vertical-sharp" + | "enter" + | "enter-outline" + | "enter-sharp" + | "exit" + | "exit-outline" + | "exit-sharp" + | "expand" + | "expand-outline" + | "expand-sharp" + | "eye" + | "eye-off" + | "eye-off-outline" + | "eye-off-sharp" + | "eye-outline" + | "eye-sharp" + | "eyedrop" + | "eyedrop-outline" + | "eyedrop-sharp" + | "fast-food" + | "fast-food-outline" + | "fast-food-sharp" + | "female" + | "female-outline" + | "female-sharp" + | "file-tray" + | "file-tray-full" + | "file-tray-full-outline" + | "file-tray-full-sharp" + | "file-tray-outline" + | "file-tray-sharp" + | "file-tray-stacked" + | "file-tray-stacked-outline" + | "file-tray-stacked-sharp" + | "film" + | "film-outline" + | "film-sharp" + | "filter" + | "filter-outline" + | "filter-sharp" + | "finger-print" + | "finger-print-outline" + | "finger-print-sharp" + | "fitness" + | "fitness-outline" + | "fitness-sharp" + | "flag" + | "flag-outline" + | "flag-sharp" + | "flame" + | "flame-outline" + | "flame-sharp" + | "flash" + | "flash-off" + | "flash-off-outline" + | "flash-off-sharp" + | "flash-outline" + | "flash-sharp" + | "flashlight" + | "flashlight-outline" + | "flashlight-sharp" + | "flask" + | "flask-outline" + | "flask-sharp" + | "flower" + | "flower-outline" + | "flower-sharp" + | "folder" + | "folder-open" + | "folder-open-outline" + | "folder-open-sharp" + | "folder-outline" + | "folder-sharp" + | "football" + | "football-outline" + | "football-sharp" + | "funnel" + | "funnel-outline" + | "funnel-sharp" + | "game-controller" + | "game-controller-outline" + | "game-controller-sharp" + | "gift" + | "gift-outline" + | "gift-sharp" + | "git-branch" + | "git-branch-outline" + | "git-branch-sharp" + | "git-commit" + | "git-commit-outline" + | "git-commit-sharp" + | "git-compare" + | "git-compare-outline" + | "git-compare-sharp" + | "git-merge" + | "git-merge-outline" + | "git-merge-sharp" + | "git-network" + | "git-network-outline" + | "git-network-sharp" + | "git-pull-request" + | "git-pull-request-outline" + | "git-pull-request-sharp" + | "glasses" + | "glasses-outline" + | "glasses-sharp" + | "globe" + | "globe-outline" + | "globe-sharp" + | "golf" + | "golf-outline" + | "golf-sharp" + | "grid" + | "grid-outline" + | "grid-sharp" + | "hammer" + | "hammer-outline" + | "hammer-sharp" + | "hand-left" + | "hand-left-outline" + | "hand-left-sharp" + | "hand-right" + | "hand-right-outline" + | "hand-right-sharp" + | "happy" + | "happy-outline" + | "happy-sharp" + | "hardware-chip" + | "hardware-chip-outline" + | "hardware-chip-sharp" + | "headset" + | "headset-outline" + | "headset-sharp" + | "heart" + | "heart-circle" + | "heart-circle-outline" + | "heart-circle-sharp" + | "heart-dislike" + | "heart-dislike-circle" + | "heart-dislike-circle-outline" + | "heart-dislike-circle-sharp" + | "heart-dislike-outline" + | "heart-dislike-sharp" + | "heart-half" + | "heart-half-outline" + | "heart-half-sharp" + | "heart-outline" + | "heart-sharp" + | "help" + | "help-buoy" + | "help-buoy-outline" + | "help-buoy-sharp" + | "help-circle" + | "help-circle-outline" + | "help-circle-sharp" + | "help-outline" + | "help-sharp" + | "home" + | "home-outline" + | "home-sharp" + | "hourglass" + | "hourglass-outline" + | "hourglass-sharp" + | "ice-cream" + | "ice-cream-outline" + | "ice-cream-sharp" + | "image" + | "image-outline" + | "image-sharp" + | "images" + | "images-outline" + | "images-sharp" + | "infinite" + | "infinite-outline" + | "infinite-sharp" + | "information" + | "information-circle" + | "information-circle-outline" + | "information-circle-sharp" + | "information-outline" + | "information-sharp" + | "journal" + | "journal-outline" + | "journal-sharp" + | "key" + | "key-outline" + | "key-sharp" + | "keypad" + | "keypad-outline" + | "keypad-sharp" + | "language" + | "language-outline" + | "language-sharp" + | "laptop" + | "laptop-outline" + | "laptop-sharp" + | "layers" + | "layers-outline" + | "layers-sharp" + | "leaf" + | "leaf-outline" + | "leaf-sharp" + | "library" + | "library-outline" + | "library-sharp" + | "link" + | "link-outline" + | "link-sharp" + | "list" + | "list-circle" + | "list-circle-outline" + | "list-circle-sharp" + | "list-outline" + | "list-sharp" + | "locate" + | "locate-outline" + | "locate-sharp" + | "location" + | "location-outline" + | "location-sharp" + | "lock-closed" + | "lock-closed-outline" + | "lock-closed-sharp" + | "lock-open" + | "lock-open-outline" + | "lock-open-sharp" + | "log-in" + | "log-in-outline" + | "log-in-sharp" + | "log-out" + | "log-out-outline" + | "log-out-sharp" + | "logo-amazon" + | "logo-amplify" + | "logo-android" + | "logo-angular" + | "logo-apple" + | "logo-apple-appstore" + | "logo-bitbucket" + | "logo-bitcoin" + | "logo-buffer" + | "logo-capacitor" + | "logo-chrome" + | "logo-closed-captioning" + | "logo-codepen" + | "logo-css3" + | "logo-designernews" + | "logo-dribbble" + | "logo-dropbox" + | "logo-edge" + | "logo-electron" + | "logo-euro" + | "logo-facebook" + | "logo-firebase" + | "logo-firefox" + | "logo-flickr" + | "logo-foursquare" + | "logo-github" + | "logo-google" + | "logo-google-playstore" + | "logo-hackernews" + | "logo-html5" + | "logo-instagram" + | "logo-ionic" + | "logo-ionitron" + | "logo-javascript" + | "logo-laravel" + | "logo-linkedin" + | "logo-markdown" + | "logo-no-smoking" + | "logo-nodejs" + | "logo-npm" + | "logo-octocat" + | "logo-pinterest" + | "logo-playstation" + | "logo-pwa" + | "logo-python" + | "logo-react" + | "logo-reddit" + | "logo-rss" + | "logo-sass" + | "logo-skype" + | "logo-slack" + | "logo-snapchat" + | "logo-stackoverflow" + | "logo-steam" + | "logo-stencil" + | "logo-tumblr" + | "logo-tux" + | "logo-twitch" + | "logo-twitter" + | "logo-usd" + | "logo-vimeo" + | "logo-vk" + | "logo-vue" + | "logo-web-component" + | "logo-whatsapp" + | "logo-windows" + | "logo-wordpress" + | "logo-xbox" + | "logo-xing" + | "logo-yahoo" + | "logo-yen" + | "logo-youtube" + | "magnet" + | "magnet-outline" + | "magnet-sharp" + | "mail" + | "mail-open" + | "mail-open-outline" + | "mail-open-sharp" + | "mail-outline" + | "mail-sharp" + | "mail-unread" + | "mail-unread-outline" + | "mail-unread-sharp" + | "male" + | "male-female" + | "male-female-outline" + | "male-female-sharp" + | "male-outline" + | "male-sharp" + | "man" + | "man-outline" + | "man-sharp" + | "map" + | "map-outline" + | "map-sharp" + | "medal" + | "medal-outline" + | "medal-sharp" + | "medical" + | "medical-outline" + | "medical-sharp" + | "medkit" + | "medkit-outline" + | "medkit-sharp" + | "megaphone" + | "megaphone-outline" + | "megaphone-sharp" + | "menu" + | "menu-outline" + | "menu-sharp" + | "mic" + | "mic-circle" + | "mic-circle-outline" + | "mic-circle-sharp" + | "mic-off" + | "mic-off-circle" + | "mic-off-circle-outline" + | "mic-off-circle-sharp" + | "mic-off-outline" + | "mic-off-sharp" + | "mic-outline" + | "mic-sharp" + | "moon" + | "moon-outline" + | "moon-sharp" + | "move" + | "move-outline" + | "move-sharp" + | "musical-note" + | "musical-note-outline" + | "musical-note-sharp" + | "musical-notes" + | "musical-notes-outline" + | "musical-notes-sharp" + | "navigate" + | "navigate-circle" + | "navigate-circle-outline" + | "navigate-circle-sharp" + | "navigate-outline" + | "navigate-sharp" + | "newspaper" + | "newspaper-outline" + | "newspaper-sharp" + | "notifications" + | "notifications-circle" + | "notifications-circle-outline" + | "notifications-circle-sharp" + | "notifications-off" + | "notifications-off-circle" + | "notifications-off-circle-outline" + | "notifications-off-circle-sharp" + | "notifications-off-outline" + | "notifications-off-sharp" + | "notifications-outline" + | "notifications-sharp" + | "nuclear" + | "nuclear-outline" + | "nuclear-sharp" + | "nutrition" + | "nutrition-outline" + | "nutrition-sharp" + | "open" + | "open-outline" + | "open-sharp" + | "options" + | "options-outline" + | "options-sharp" + | "paper-plane" + | "paper-plane-outline" + | "paper-plane-sharp" + | "partly-sunny" + | "partly-sunny-outline" + | "partly-sunny-sharp" + | "pause" + | "pause-circle" + | "pause-circle-outline" + | "pause-circle-sharp" + | "pause-outline" + | "pause-sharp" + | "paw" + | "paw-outline" + | "paw-sharp" + | "pencil" + | "pencil-outline" + | "pencil-sharp" + | "people" + | "people-circle" + | "people-circle-outline" + | "people-circle-sharp" + | "people-outline" + | "people-sharp" + | "person" + | "person-add" + | "person-add-outline" + | "person-add-sharp" + | "person-circle" + | "person-circle-outline" + | "person-circle-sharp" + | "person-outline" + | "person-remove" + | "person-remove-outline" + | "person-remove-sharp" + | "person-sharp" + | "phone-landscape" + | "phone-landscape-outline" + | "phone-landscape-sharp" + | "phone-portrait" + | "phone-portrait-outline" + | "phone-portrait-sharp" + | "pie-chart" + | "pie-chart-outline" + | "pie-chart-sharp" + | "pin" + | "pin-outline" + | "pin-sharp" + | "pint" + | "pint-outline" + | "pint-sharp" + | "pizza" + | "pizza-outline" + | "pizza-sharp" + | "planet" + | "planet-outline" + | "planet-sharp" + | "play" + | "play-back" + | "play-back-circle" + | "play-back-circle-outline" + | "play-back-circle-sharp" + | "play-back-outline" + | "play-back-sharp" + | "play-circle" + | "play-circle-outline" + | "play-circle-sharp" + | "play-forward" + | "play-forward-circle" + | "play-forward-circle-outline" + | "play-forward-circle-sharp" + | "play-forward-outline" + | "play-forward-sharp" + | "play-outline" + | "play-sharp" + | "play-skip-back" + | "play-skip-back-circle" + | "play-skip-back-circle-outline" + | "play-skip-back-circle-sharp" + | "play-skip-back-outline" + | "play-skip-back-sharp" + | "play-skip-forward" + | "play-skip-forward-circle" + | "play-skip-forward-circle-outline" + | "play-skip-forward-circle-sharp" + | "play-skip-forward-outline" + | "play-skip-forward-sharp" + | "podium" + | "podium-outline" + | "podium-sharp" + | "power" + | "power-outline" + | "power-sharp" + | "pricetag" + | "pricetag-outline" + | "pricetag-sharp" + | "pricetags" + | "pricetags-outline" + | "pricetags-sharp" + | "print" + | "print-outline" + | "print-sharp" + | "pulse" + | "pulse-outline" + | "pulse-sharp" + | "push" + | "push-outline" + | "push-sharp" + | "qr-code" + | "qr-code-outline" + | "qr-code-sharp" + | "radio" + | "radio-button-off" + | "radio-button-off-outline" + | "radio-button-off-sharp" + | "radio-button-on" + | "radio-button-on-outline" + | "radio-button-on-sharp" + | "radio-outline" + | "radio-sharp" + | "rainy" + | "rainy-outline" + | "rainy-sharp" + | "reader" + | "reader-outline" + | "reader-sharp" + | "receipt" + | "receipt-outline" + | "receipt-sharp" + | "recording" + | "recording-outline" + | "recording-sharp" + | "refresh" + | "refresh-circle" + | "refresh-circle-outline" + | "refresh-circle-sharp" + | "refresh-outline" + | "refresh-sharp" + | "reload" + | "reload-circle" + | "reload-circle-outline" + | "reload-circle-sharp" + | "reload-outline" + | "reload-sharp" + | "remove" + | "remove-circle" + | "remove-circle-outline" + | "remove-circle-sharp" + | "remove-outline" + | "remove-sharp" + | "reorder-four" + | "reorder-four-outline" + | "reorder-four-sharp" + | "reorder-three" + | "reorder-three-outline" + | "reorder-three-sharp" + | "reorder-two" + | "reorder-two-outline" + | "reorder-two-sharp" + | "repeat" + | "repeat-outline" + | "repeat-sharp" + | "resize" + | "resize-outline" + | "resize-sharp" + | "restaurant" + | "restaurant-outline" + | "restaurant-sharp" + | "return-down-back" + | "return-down-back-outline" + | "return-down-back-sharp" + | "return-down-forward" + | "return-down-forward-outline" + | "return-down-forward-sharp" + | "return-up-back" + | "return-up-back-outline" + | "return-up-back-sharp" + | "return-up-forward" + | "return-up-forward-outline" + | "return-up-forward-sharp" + | "ribbon" + | "ribbon-outline" + | "ribbon-sharp" + | "rocket" + | "rocket-outline" + | "rocket-sharp" + | "rose" + | "rose-outline" + | "rose-sharp" + | "sad" + | "sad-outline" + | "sad-sharp" + | "save" + | "save-outline" + | "save-sharp" + | "scan" + | "scan-circle" + | "scan-circle-outline" + | "scan-circle-sharp" + | "scan-outline" + | "scan-sharp" + | "school" + | "school-outline" + | "school-sharp" + | "search" + | "search-circle" + | "search-circle-outline" + | "search-circle-sharp" + | "search-outline" + | "search-sharp" + | "send" + | "send-outline" + | "send-sharp" + | "server" + | "server-outline" + | "server-sharp" + | "settings" + | "settings-outline" + | "settings-sharp" + | "shapes" + | "shapes-outline" + | "shapes-sharp" + | "share" + | "share-outline" + | "share-sharp" + | "share-social" + | "share-social-outline" + | "share-social-sharp" + | "shield" + | "shield-checkmark" + | "shield-checkmark-outline" + | "shield-checkmark-sharp" + | "shield-outline" + | "shield-sharp" + | "shirt" + | "shirt-outline" + | "shirt-sharp" + | "shuffle" + | "shuffle-outline" + | "shuffle-sharp" + | "skull" + | "skull-outline" + | "skull-sharp" + | "snow" + | "snow-outline" + | "snow-sharp" + | "speedometer" + | "speedometer-outline" + | "speedometer-sharp" + | "square" + | "square-outline" + | "square-sharp" + | "star" + | "star-half" + | "star-half-outline" + | "star-half-sharp" + | "star-outline" + | "star-sharp" + | "stats-chart" + | "stats-chart-outline" + | "stats-chart-sharp" + | "stop" + | "stop-circle" + | "stop-circle-outline" + | "stop-circle-sharp" + | "stop-outline" + | "stop-sharp" + | "stopwatch" + | "stopwatch-outline" + | "stopwatch-sharp" + | "subway" + | "subway-outline" + | "subway-sharp" + | "sunny" + | "sunny-outline" + | "sunny-sharp" + | "swap-horizontal" + | "swap-horizontal-outline" + | "swap-horizontal-sharp" + | "swap-vertical" + | "swap-vertical-outline" + | "swap-vertical-sharp" + | "sync" + | "sync-circle" + | "sync-circle-outline" + | "sync-circle-sharp" + | "sync-outline" + | "sync-sharp" + | "tablet-landscape" + | "tablet-landscape-outline" + | "tablet-landscape-sharp" + | "tablet-portrait" + | "tablet-portrait-outline" + | "tablet-portrait-sharp" + | "tennisball" + | "tennisball-outline" + | "tennisball-sharp" + | "terminal" + | "terminal-outline" + | "terminal-sharp" + | "text" + | "text-outline" + | "text-sharp" + | "thermometer" + | "thermometer-outline" + | "thermometer-sharp" + | "thumbs-down" + | "thumbs-down-outline" + | "thumbs-down-sharp" + | "thumbs-up" + | "thumbs-up-outline" + | "thumbs-up-sharp" + | "thunderstorm" + | "thunderstorm-outline" + | "thunderstorm-sharp" + | "time" + | "time-outline" + | "time-sharp" + | "timer" + | "timer-outline" + | "timer-sharp" + | "today" + | "today-outline" + | "today-sharp" + | "toggle" + | "toggle-outline" + | "toggle-sharp" + | "trail-sign" + | "trail-sign-outline" + | "trail-sign-sharp" + | "train" + | "train-outline" + | "train-sharp" + | "transgender" + | "transgender-outline" + | "transgender-sharp" + | "trash" + | "trash-bin" + | "trash-bin-outline" + | "trash-bin-sharp" + | "trash-outline" + | "trash-sharp" + | "trending-down" + | "trending-down-outline" + | "trending-down-sharp" + | "trending-up" + | "trending-up-outline" + | "trending-up-sharp" + | "triangle" + | "triangle-outline" + | "triangle-sharp" + | "trophy" + | "trophy-outline" + | "trophy-sharp" + | "tv" + | "tv-outline" + | "tv-sharp" + | "umbrella" + | "umbrella-outline" + | "umbrella-sharp" + | "videocam" + | "videocam-outline" + | "videocam-sharp" + | "volume-high" + | "volume-high-outline" + | "volume-high-sharp" + | "volume-low" + | "volume-low-outline" + | "volume-low-sharp" + | "volume-medium" + | "volume-medium-outline" + | "volume-medium-sharp" + | "volume-mute" + | "volume-mute-outline" + | "volume-mute-sharp" + | "volume-off" + | "volume-off-outline" + | "volume-off-sharp" + | "walk" + | "walk-outline" + | "walk-sharp" + | "wallet" + | "wallet-outline" + | "wallet-sharp" + | "warning" + | "warning-outline" + | "warning-sharp" + | "watch" + | "watch-outline" + | "watch-sharp" + | "water" + | "water-outline" + | "water-sharp" + | "wifi" + | "wifi-outline" + | "wifi-sharp" + | "wine" + | "wine-outline" + | "wine-sharp" + | "woman" + | "woman-outline" + | "woman-sharp"; } diff --git a/index.js b/index.js index 8e1a2ac..61f782a 100644 --- a/index.js +++ b/index.js @@ -1,35 +1,31 @@ -import * as React from 'react' -import { StyleSheet, Text, Platform } from 'react-native' -import { tryGlyph } from './glyph' - -/** - * @typedef {(string|undefined)} IconName - */ +import * as React from "react"; +import { StyleSheet, Text, Platform } from "react-native"; +import { tryGlyph } from "./glyph"; /** * @function - * @param {IconName} android - * @param {IconName} ios - * @param {IconName} name + * @param {string} android + * @param {string} ios + * @param {string} name * @return {string} */ const getGlyph = Platform.select({ - ios: (_android, ios, name) => tryGlyph([ios, name], x => `ios-${x}`), - default: (android, _ios, name) => tryGlyph([android, name], x => `md-${x}`) -}) + ios: (_android, ios, name) => tryGlyph([ios, name]), + default: (android, _ios, name) => tryGlyph([android, name]), +}); class Icon extends React.PureComponent { constructor(props) { - super(props) + super(props); - this._setRef = ref => { - this._text = ref - } + this._setRef = (ref) => { + this._text = ref; + }; } setNativeProps(props) { if (this._text) { - this._text.setNativeProps(props) + this._text.setNativeProps(props); } } @@ -43,12 +39,12 @@ class Icon extends React.PureComponent { style, children, ...textProps - } = this.props + } = this.props; const fontStyle = { fontSize: size, - color - } + color, + }; return ( - ) + ); } } Icon.defaultProps = { allowFontScaling: false, - size: 30 -} + size: 30, +}; -export default Icon +export default Icon; const styles = StyleSheet.create({ icon: { - fontFamily: 'Ionicons', - fontWeight: 'normal', - fontStyle: 'normal' - } -}) + fontFamily: "Ionicons", + fontWeight: "normal", + fontStyle: "normal", + }, +}); diff --git a/package.json b/package.json index 36a67f3..7f092fc 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,14 @@ { "name": "react-native-ionicons", - "version": "4.6.4", "description": "Ionic icons for React Native", + "version": "5.0.0-rc", "main": "index.js", "typings": "index.d.ts", "scripts": { "prepublishOnly": "npm test", - "generate": "node generate", + "generate": "node script/generate.js", "prettier": "prettier --write '**/*.{js,json,ts,md}'", - "pretest": "npm run generate; npm run prettier", - "test": "jest" + "test": "npm run generate && npm run prettier && jest" }, "husky": { "hooks": { @@ -19,14 +18,9 @@ }, "lint-staged": { "*.{js,json,ts,md}": [ - "prettier --write", - "git add" + "prettier --write" ] }, - "prettier": { - "semi": false, - "singleQuote": true - }, "repository": { "type": "git", "url": "git+https://github.com/arniu/react-native-ionicons.git" @@ -48,14 +42,18 @@ "react-native": "*" }, "devDependencies": { - "@babel/core": "^7.7.7", - "@babel/preset-env": "^7.7.7", - "babel-jest": "^24.9.0", - "husky": "^3.0.9", - "ionicons": "^4.6.3", - "jest": "^24.9.0", - "lint-staged": "^9.4.2", - "prettier": "^1.18.2" + "@babel/core": "^7.8.6", + "@babel/preset-env": "^7.8.6", + "babel-jest": "^25.1.0", + "decamelize": "^4.0.0", + "fs-extra": "^9.0.0", + "husky": "^4.2.3", + "ionicons": "^5.0.1", + "jest": "^25.1.0", + "lint-staged": "^10.0.8", + "prettier": "^2.0.2", + "svg2ttf": "^4.3.0", + "svgicons2svgfont": "^9.1.1" }, "rnpm": { "assets": [ diff --git a/react-native.config.js b/react-native.config.js index 36ba021..273a39e 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -1,5 +1,5 @@ module.exports = { dependency: { - assets: ['fonts'] - } -} + assets: ["fonts"], + }, +}; diff --git a/script/generate.js b/script/generate.js new file mode 100755 index 0000000..d118341 --- /dev/null +++ b/script/generate.js @@ -0,0 +1,104 @@ +#! /usr/bin/env node + +async function main() { + const list = prepareData(); + const path = preparePath(); + + await Promise.all([ + createJson(list, path.json), + createType(list, path.type), + createFont(list, path.font), + ]); +} + +function preparePath() { + const path = require("path"); + const manifest = require("./manifest"); + const root = path.resolve(__dirname, ".."); + + return { + json: path.resolve(root, `fonts/${manifest.name}.json`), + font: path.resolve(root, `fonts/${manifest.name}.ttf`), + type: path.resolve(root, `index.d.ts`), + }; +} + +/** + * @typedef IconData + * @property {string} icon + * @property {string} name + * @property {number} code + * + * + * @returns {IconData[]} + */ +function prepareData() { + const manifest = require("./manifest"); + const decamelize = require("decamelize"); + const icons = require("ionicons/icons"); + const regex = /[a-z]\w+/; + + const list = []; + let code = manifest.startAt; + for (const name in icons) { + if (regex.test(name)) { + list.push({ + icon: icons[name], + name: decamelize(name, "-"), + code: code++, + }); + } + } + + return list; +} + +/** + * Create glyph map + * + * @param {IconData[]} list + * @param {string} path + */ +async function createJson(list, path) { + const fs = require("fs-extra"); + const json = list.reduce((map, it) => { + map[it.name] = it.code; + return map; + }, {}); + + await fs.outputJSON(path, json, { spaces: 2 }); +} + +/** + * Create font file + * + * @param {IconData[]} list + * @param {string} path + */ +async function createFont(list, path) { + const fs = require("fs-extra"); + const svg2ttf = require("svg2ttf"); + const prepareSVG = require("./prepareSVG"); + const svg = await prepareSVG(list); + const ttf = svg2ttf(svg); + + await fs.outputFile(path, ttf.buffer); +} + +/** + * Create iconName.d.ts file + * + * @param {IconData[]} list + * @param {string} path + */ +async function createType(list, path) { + const fs = require("fs-extra"); + const prepareType = require("./prepareType"); + const content = prepareType(list); + + await fs.outputFile(path, content); +} + +if (require.main === module) { + main(); +} diff --git a/script/manifest.js b/script/manifest.js new file mode 100644 index 0000000..56d3414 --- /dev/null +++ b/script/manifest.js @@ -0,0 +1,14 @@ +const pkg = require("ionicons/package.json"); + +module.exports = { + name: "Ionicons", + version: pkg.version, + license: pkg.license, + + /** + * According to the [manifest][manifest] of Ionicons v4, the codepoint starts from `0xf100`. + * + * [manifest]: https://github.com/ionic-team/ionicons/blob/4.x/scripts/manifest.json + */ + startAt: 0xf100, +}; diff --git a/script/prepareSVG.js b/script/prepareSVG.js new file mode 100644 index 0000000..97cfe00 --- /dev/null +++ b/script/prepareSVG.js @@ -0,0 +1,43 @@ +const { Readable } = require("stream"); +const FontStream = require("svgicons2svgfont"); +const manifest = require("./manifest"); + +/** + * @typedef IconData + * @property {string} icon + * @property {string} name + * @property {number} code + * + * @param {IconData[]} list + * @returns {string} + */ +module.exports = function prepareSVG(list) { + return new Promise((resolve, reject) => { + const chunks = []; + const stream = new FontStream({ + fontName: manifest.name, + }); + + stream + .on("error", (err) => reject(err)) + .on("finish", () => resolve(Buffer.concat(chunks).toString())) + .on("data", (chunk) => chunks.push(chunk)); + + list.forEach((it) => { + const pair = it.icon.split(","); + if (pair.length !== 2) { + throw new Error(`Invalid icon ${it.name}`); + } + + const readable = Readable.from(pair[1]); + readable.metadata = { + unicode: [String.fromCodePoint(it.code)], + name: it.name, + }; + + stream.write(readable); + }); + + stream.end(); + }); +}; diff --git a/script/prepareType.js b/script/prepareType.js new file mode 100644 index 0000000..3895cb4 --- /dev/null +++ b/script/prepareType.js @@ -0,0 +1,37 @@ +const makeType = (names) => `/** + * This was generated by script/prepareType + * Please DO NOT change it manually. + */ + +declare module "react-native-ionicons" { + import * as React from "react"; + import { TextProps } from "react-native"; + + export default class Icon extends React.PureComponent {} + + export interface IconProps extends TextProps { + name?: IconName; + ios?: IconName; + android?: IconName; + color?: string; + size?: number; + } + + export type IconName = ${names.join("\n | ")}; +} +`; + +const quoteName = ({ name }) => `"${name}"`; + +/** + * @typedef IconData + * @property {string} name + * @property {string} path + * @property {number} code + * + * @param {IconData[]} list + * @returns {string} + */ +module.exports = function prepareType(list) { + return makeType(list.map(quoteName)); +}; diff --git a/test/generate.spec.js b/test/generate.spec.js deleted file mode 100644 index 19bbd71..0000000 --- a/test/generate.spec.js +++ /dev/null @@ -1,13 +0,0 @@ -import fs from 'fs' -import { resolve } from 'path' -import { FILES } from '../generate' - -it(`should exist: ${FILES.FONT_FILE}`, () => { - const path = resolve(__dirname, '..', FILES.FONT_FILE) - expect(fs.existsSync(path)).toBeTruthy() -}) - -it(`should exist: ${FILES.GLYPH_MAP}`, () => { - const path = resolve(__dirname, '..', FILES.GLYPH_MAP) - expect(fs.existsSync(path)).toBeTruthy() -}) diff --git a/test/glyph.spec.js b/test/glyph.spec.js index a1c6927..82c316f 100644 --- a/test/glyph.spec.js +++ b/test/glyph.spec.js @@ -1,19 +1,8 @@ -import { UNKNOWN_ICON, tryGlyph } from '../glyph' - -describe('should work on ios devices', () => { - const mapper = x => `ios-${x}` - - it('should have `add` icon', () => { - const icon = tryGlyph(['add', null], mapper) - expect(icon).not.toBe(UNKNOWN_ICON) - }) -}) - -describe('should work on android devices', () => { - const mapper = x => `md-${x}` - - it('should have `add` icon', () => { - const icon = tryGlyph(['add', null], mapper) - expect(icon).not.toBe(UNKNOWN_ICON) - }) -}) +import { UNKNOWN_ICON, tryGlyph } from "../glyph"; + +describe("tryGlyph", () => { + it("should have `add` icon", () => { + const icon = tryGlyph(["add", null]); + expect(icon).not.toBe(UNKNOWN_ICON); + }); +});