-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ff888a
commit 3ffebc8
Showing
10 changed files
with
31,242 additions
and
2 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
.github/figma-descriptions-transformer/figma-transformer.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Clone the mistica-icons repo to your computer and make sure you are on the production branch with the latest updates | ||
|
||
# Ensure that icons-keywords.json is up-to-date and contains the line with the icon's name | ||
|
||
# Open the Figma Bulk Meta plugin where the icons are located | ||
# Export the JSON and name it telefonica-original.json, save it in the repo under resources/figma-descriptions-transformer/originals | ||
# Choose brand to export changing the brand name on line 13 in this file | ||
# Run the script in the terminal "python3 figma-transformer.py" | ||
|
||
# Open the Figma Bulk Meta plugin | ||
# Go to the "Import" tab and select the telefonica.json file generated by the script | ||
|
||
# ————— CHANGE BRAND TO THE BRAND NAME ————— # | ||
# "vivo" or "telefonica" or "o2" | ||
brand = "telefonica" | ||
|
||
import json | ||
|
||
# Build the file path using the variable | ||
original_path = f'./.github/figma-descriptions-transformer/originals/{brand}-original.json' | ||
generated_path = f'./.github/figma-descriptions-transformer/generated/{brand}.json' | ||
|
||
# Read the original JSON from the file | ||
with open(original_path, 'r') as original_file: | ||
json_original = json.load(original_file) | ||
|
||
# Read the keyword mapping from the file | ||
# DO NOT TOUCH # | ||
with open('./icons/icons-keywords.json', 'r') as keywords_file: | ||
keywords = json.load(keywords_file) | ||
|
||
# Function to replace the description | ||
def replace_description(json, keywords): | ||
new_json = {} | ||
|
||
for key, item in json.items(): | ||
# Remove "light", "regular", and "filled" from the key | ||
key_without_variants = key.replace('-light', '').replace('-regular', '').replace('-filled', '') | ||
|
||
if key_without_variants in keywords: | ||
words = keywords[key_without_variants] | ||
new_description = ', '.join(words) | ||
else: | ||
new_description = item["description"] | ||
|
||
# Copy the original object and update the description | ||
new_item = item.copy() | ||
new_item['description'] = new_description | ||
new_json[key] = new_item | ||
|
||
return new_json | ||
|
||
# Call the function to get the updated JSON | ||
updated_json = replace_description(json_original, keywords) | ||
|
||
# Write the updated JSON to a new file | ||
with open(generated_path, 'w') as new_file: | ||
json.dump(updated_json, new_file, indent=2) |
Oops, something went wrong.