Created
August 31, 2022 10:02
-
-
Save garyanikin/7365f74d244c99eadeef92fa9e55deda to your computer and use it in GitHub Desktop.
Плагин для нахождение broken_icons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"12": [ | |
"add_12.svg", | |
"articles_12.svg", | |
"bomb_12.svg", | |
"cake_12.svg", | |
"chevron_12.svg", | |
"chevron_outline_12.svg", | |
"coins_12.svg", | |
"favorite_12.svg", | |
"gift_12.svg", | |
"hand_12.svg", | |
"headphones_12.svg", | |
"lock_12.svg", | |
"payment_card_outline_12.svg", | |
"smile_filled_12.svg", | |
"stars_12.svg", | |
"subtitles_12.svg", | |
"user_12.svg", | |
"users_12.svg" | |
], | |
"16": [ | |
"arrow_triangle_up_16.svg", | |
"cam_slash_16.svg", | |
"cloud_16.svg", | |
"cloud_lighting_16.svg", | |
"cloud_moon_16.svg", | |
"cloud_moon_lighting_16.svg", | |
"cloud_moon_rain_16.svg", | |
"cloud_moon_snow_16.svg", | |
"cloud_rain_16.svg", | |
"cloud_rain_snow_16.svg", | |
"cloud_sun_16.svg", | |
"cloud_sun_lighting_16.svg", | |
"cloud_sun_rain_16.svg", | |
"cloud_sun_snow_16.svg", | |
"comment_16.svg", | |
"crop_16.svg", | |
"dropdown_flipped_16.svg", | |
"dropdown_flipped_outline_16.svg", | |
"fog_16.svg", | |
"fog_moon_16.svg", | |
"fog_sun_16.svg", | |
"grid_of_four_16.svg", | |
"grid_of_three_16.svg", | |
"hand_16.svg", | |
"image_filter_16.svg", | |
"installment_outline_16.svg", | |
"link_outline_16.svg", | |
"linked_16.svg", | |
"microphone_16.svg", | |
"microphone_slash_16.svg", | |
"moon_16.svg", | |
"music_mic_16.svg", | |
"muted_16.svg", | |
"new_16.svg", | |
"pause_circle_16.svg", | |
"phone_outgoing_16.svg", | |
"pin_dot_16.svg", | |
"repost_outline_16.svg", | |
"snowflake_16.svg", | |
"stars_16.svg", | |
"sun_16.svg", | |
"tag_16.svg", | |
"text_16.svg", | |
"videocam_16.svg", | |
"warning_triangle_16.svg", | |
"wind_16.svg", | |
"wind_rain_16.svg", | |
"wind_rain_snow_16.svg", | |
"wind_snow_16.svg" | |
], | |
"24": [ | |
"16_circle_outline_24.svg", | |
"18_circle_outline_24.svg", | |
"3_square_outline_24.svg", | |
"add_awards_outline_24.svg", | |
"advertising_outline_24.svg", | |
"airplay_video_outline_24.svg", | |
"apple_outline_24.svg", | |
"archive_outline_24.svg", | |
"armchair_outline_24.svg", | |
"arrow_right_square_outline_24.svg", | |
"arrow_up_outline_24.svg", | |
"arrow_uturn_left_outline_24.svg", | |
"arrow_uturn_right_outline_24.svg", | |
"article_24.svg", | |
"article_outline_24.svg", | |
"ball_outline_24.svg", | |
"beauty_outline_24.svg", | |
"bidy_outline_24.svg", | |
"billhead_outline_24.svg", | |
"block_outline_24.svg", | |
"bomb_outline_24.svg", | |
"bowl_sticks_outline_24.svg", | |
"brain_outline_24.svg", | |
"brush_outline_24.svg", | |
"bug_outline_24.svg", | |
"cactus_outline_24.svg", | |
"car_outline_24.svg", | |
"chain_outline_24.svg", | |
"check_circle_outline_24.svg", | |
"check_shield_outline_24.svg", | |
"chevron_down_24.svg", | |
"chevron_up_24.svg", | |
"clock_outline_24.svg", | |
"computer_outline_24.svg", | |
"cross_shield_outline_24.svg", | |
"crown_outline_24.svg", | |
"delete_arrow_up_outline_24.svg", | |
"delete_outline_24.svg", | |
"dollar_circle_outline_24.svg", | |
"door_arrow_left_outline_24.svg", | |
"download_check_outline_24.svg", | |
"download_outline_24.svg", | |
"drill_outline_24.svg", | |
"education_outline_24.svg", | |
"employee_outline_24.svg", | |
"favorite_outline_24.svg", | |
"filter_24.svg", | |
"folder_outline_24.svg", | |
"fullscreen_24.svg", | |
"fullscreen_exit_24.svg", | |
"ghost_outline_24.svg", | |
"gift_outline_24.svg", | |
"gun_outline_24.svg", | |
"hammer_outline_24.svg", | |
"health_outline_24.svg", | |
"hide_outline_24.svg", | |
"history_backward_outline_24.svg", | |
"home_heart_outline_24.svg", | |
"home_outline_24.svg", | |
"horse_toy_outline_24.svg", | |
"image_filter_outline_24.svg", | |
"info_circle_outline_24.svg", | |
"key_outline_24.svg", | |
"knife_outline_24.svg", | |
"laptop_outline_24.svg", | |
"lifebuoy_outline_24.svg", | |
"live_disable_outline_24.svg", | |
"live_outline_24.svg", | |
"location_outline_24.svg", | |
"lock_open_outline_24.svg", | |
"lock_outline_24.svg", | |
"market_24.svg", | |
"message_forward_outline_24.svg", | |
"microphone_slash_24.svg", | |
"microphone_slash_outline_24.svg", | |
"money_request_outline_24.svg", | |
"money_send_outline_24.svg", | |
"money_transfer_outline_24.svg", | |
"mortar_outline_24.svg", | |
"motorcycle_outline_24.svg", | |
"mute_outline_24.svg", | |
"notification_outline_24.svg", | |
"notification_slash_outline_24.svg", | |
"paint_roller_outline_24.svg", | |
"palette_outline_24.svg", | |
"paw_outline_24.svg", | |
"payment_card_outline_24.svg", | |
"payment_card_vertical_outline_24.svg", | |
"pen_outline_24.svg", | |
"photos_stack_outline_24.svg", | |
"pin_slash_outline_24.svg", | |
"plane_outline_24.svg", | |
"recent_24.svg", | |
"report_outline_24.svg", | |
"robot_outline_24.svg", | |
"sad_face_outline_24.svg", | |
"shopping_cart_outline_24.svg", | |
"skull_outline_24.svg", | |
"smartphone_outline_24.svg", | |
"square_4_outline_24.svg", | |
"statistics_outline_24.svg", | |
"sticker_outline_24.svg", | |
"storefront_outline_24.svg", | |
"stud_outline_24.svg", | |
"text_outline_24.svg", | |
"thumbs_up_outline_24.svg", | |
"tshirt_outline_24.svg", | |
"unarchive_outline_24.svg", | |
"unblock_outline_24.svg", | |
"unfavorite_outline_24.svg", | |
"user_circle_outline_24.svg", | |
"user_square_outline_24.svg", | |
"users_outline_24.svg", | |
"video_outline_24.svg", | |
"view_outline_24.svg", | |
"vinyl_outline_24.svg", | |
"voice_24.svg", | |
"voice_outline_24.svg", | |
"volume_outline_24.svg", | |
"washer_outline_24.svg", | |
"wheel_outline_24.svg", | |
"work_outline_24.svg" | |
], | |
"28": [ | |
"add_award_outline_28.svg", | |
"arrow_down_outline_28.svg", | |
"arrow_right_circle_outline_28.svg", | |
"baby_bottle_outline_28.svg", | |
"building_outline_28.svg", | |
"cancel_shield_outline_28.svg", | |
"check_shield_outline_28.svg", | |
"delete_outline_28.svg", | |
"donate_outline_28.svg", | |
"door_arrow_right_outline_28.svg", | |
"download_cancel_outline_28.svg", | |
"download_check_outline_28.svg", | |
"gesture_outline_28.svg", | |
"grid_layout_outline_28.svg", | |
"heart_circle_outline_28.svg", | |
"lightbulb_outline_28.svg", | |
"lightbulb_star_outline_28.svg", | |
"like_lock_outline_28.svg", | |
"live_slash_outline_28.svg", | |
"lotus_outline_28.svg", | |
"masks_outline_28.svg", | |
"message_add_badge_outline_28.svg", | |
"message_check_outline_28.svg", | |
"microphone_slash_28.svg", | |
"microphone_slash_outline_28.svg", | |
"microphone_videocam_outline_28.svg", | |
"microphone_videocam_slash_outline_28.svg", | |
"money_wad_outline_28.svg", | |
"no_smoking_sign_outline_28.svg", | |
"notebook_add_badge_outline_28.svg", | |
"payment_card_vertical_outline_28.svg", | |
"pen_stack_lock_outline_28.svg", | |
"phone_wave_outline_28.svg", | |
"pill_outline_28.svg", | |
"pin_dot_outline_28.svg", | |
"pin_dot_slash_outline_28.svg", | |
"safari_outline_28.svg", | |
"shield_keyhole_outline_28.svg", | |
"shopping_cart_outline_28.svg", | |
"smartphone_stars_outline_28.svg", | |
"smile_28.svg", | |
"smiles_2_outline_28.svg", | |
"sneaker_outline_28.svg", | |
"sparkle_outline_28.svg", | |
"speedometer_middle_outline_28.svg", | |
"speedometer_start_outline_28.svg", | |
"stopwatch_outline_28.svg", | |
"storefront_outline_28.svg", | |
"tear_off_flyer_fill_blue_28.svg", | |
"ticket_outline_28.svg", | |
"user_microphone_badge_outline_28.svg", | |
"user_microphone_badge_slash_outline_28.svg", | |
"user_star_badge_outline_28.svg", | |
"user_star_badge_slash_outline_28.svg", | |
"videocam_add_outline_28.svg", | |
"videocam_arrow_up_outline_28.svg", | |
"videocam_arrow_up_slash_outline_28.svg", | |
"videocam_slash_outline_28.svg" | |
], | |
"32": [ | |
"cake_circle_fill_purple_32.svg", | |
"camera_outline_32.svg", | |
"check_circle_32.svg", | |
"document_outline_32.svg", | |
"error_circle_32.svg", | |
"folder_32.svg", | |
"gift_outline_32.svg", | |
"memory_card_32.svg", | |
"money_transfer_outline_32.svg", | |
"music_outline_32.svg", | |
"play_32.svg", | |
"play_rectangle_stack_outline_32.svg", | |
"privacy_circle_fill_purple_32.svg", | |
"search_outline_32.svg", | |
"stars_circle_fill_violet_32.svg" | |
], | |
"36": [ | |
"chevron_left_outline_36.svg", | |
"chevron_right_outline_36.svg", | |
"favorite_outline_36.svg", | |
"gift_outline_36.svg", | |
"hearts_2_outline_36.svg", | |
"lightbulb_outline_36.svg", | |
"replay_15_36.svg", | |
"tear_off_flyer_outline_36.svg" | |
], | |
"48": [ | |
"add_award_outline_48.svg", | |
"lock_circle_fill_green_48.svg", | |
"picture_outline_48.svg", | |
"stars_circle_fill_violet_48.svg" | |
], | |
"56": [ | |
"advertising_outline_56.svg", | |
"cake_circle_fill_purple_56.svg", | |
"check_shield_outline_56.svg", | |
"compass_circle_fill_purple_56.svg", | |
"data_stack_lock_outline_56.svg", | |
"delete_outline_56.svg", | |
"flip_album_outline_56.svg", | |
"flip_portrait_outline_56.svg", | |
"hearts_2_circle_fill_twilight_56.svg", | |
"money_circle_fill_blue_56.svg", | |
"money_circle_fill_gray_56.svg", | |
"narrative_outline_56.svg", | |
"note_pen_outline_56.svg", | |
"phone_circle_fill_green_56.svg", | |
"settings_outline_56.svg", | |
"shield_keyhole_outline_56.svg", | |
"story_outline_56.svg", | |
"view_outline_56.svg" | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// подключаю файл со списком | |
const data = require("./broken_icons.json"); | |
// получаю текущую страницу | |
const nodes = figma.currentPage; | |
// Получаю размер иконок из названия страницы | |
const pageSize = parseInt(nodes.name); | |
// выбираю из списка нужные иконки (по размеру) | |
let list = data[pageSize] || []; | |
list = list.map(getName); // убираем в списке расширения для файлов .svg | |
// создал пустой список для найденых иконок | |
const found: string[] = []; | |
// Прохожу по всем элементам на текущей странице | |
for (const node of nodes.children) { | |
// получаем имя элемента | |
const { name } = node; | |
// Если элемент в нашем списке | |
if (list.includes(name)) { | |
// сохроняем его в список найденых | |
found.push(name); | |
} else { | |
// Если элемент НЕ в нашем списке | |
// делаем прозрачность 0 | |
if ("opacity" in node) { | |
node.opacity = 0; | |
} | |
} | |
} | |
// Иконки которые не нашли на странице | |
const notFound = getDifference(list, found); | |
console.log("нашли", found); | |
console.log("не нашли", notFound); | |
// Make sure to close the plugin when you're done. Otherwise the plugin will | |
// keep running, which shows the cancel button at the bottom of the screen. | |
figma.closePlugin(); | |
/** | |
* Функция убирает из строчки с названием файла расширение .svg | |
* Было "any-file-name.svg" станет "any-file-name" | |
* @param filename название файла .svg | |
* @returns название без (.svg) | |
*/ | |
function getName(filename: string) { | |
return filename.replace(".svg", ""); | |
} | |
/** | |
* Получить разницу между двумя массивами | |
* @param a1 | |
* @param a2 | |
*/ | |
function getDifference(a1: string[], a2: string[]) { | |
return a1.filter((x) => !a2.includes(x)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment