Code Monkey home page Code Monkey logo

icon2enum's Introduction

icon2enum

Automatically fetches Material Design Icons and creates an enum of unicode strings for the specified programming language.

Supported languages

  • Swift
  • Kotlin
  • Typescript
  • C++
  • Dart
  • JavaScript
  • Python
  • Ruby
  • Java

Feel free to send a pull request to add your favorite language to this list! Just create a template in the templates folder and make minor modifications in helpers/syntax.py like specifying the extension and enum style (camelcase or snakecase).

Usage

Install beautifulsoup4 using pip3

pip3 install beautifulsoup4

Run icon2enum using python3

python3 build.py

You will be presented with three options:

Select one or more options:
f. Download fonts
g. Generate language specific file
h. Output hex codepoints

Selecting any of the three will have the same set of questions:

Specify version of data set:
(Latest, master, 7.1.96, and etc.)
master 
# Only the master branch works for all options.
# Picking versions is only available for the "Download (F)onts" option.

Specify the language to be generated:
(swift, java, kotlin, c++, go, and etc.)
# Required. This is asked only when "(G)enerate language files" is selected.

Filter tags, separated by commas:
# Optional, examples: device, transportation, network
account # This will generate a file with icons tagged as 'account'

Filter authors, separated by commas:
# Optional, examples: google, templarian

You can find tags and authors to add to the filter on the Community Material Icons website:

Tags: https://pictogrammers.com/library/mdi/

Authors: https://pictogrammers.com/docs/contribute/contributors/

Output directory

The files are generated into the following folders:

build                                                   
├── fonts
│   ├─ mdi-7.1.96.ttf
│   ├─ mdi-master.ttf
├── hex
│   ├─ hex-master.json
├── lang
│   ├─ MDIcons+master.swift
├── source
    ├─ source.json

Using the MDIcons enum

After downloading the font and generating files with icon2enum, you can simply drag the files into your project and call them like so:

Swift

let headphoneIcon: String = MDIcons.headphones // variable is set to "\u{F02CB}"
let iconLabel: UILabel = UILabel()
iconLabel.font = UIFont("Material Design Icons", ...)
iconLabel.text = headphoneIcon

Kotlin

val headphoneIcon = MDIcons.valueOf("HEADPHONES")

C++

MDIcons icons;
std::string headphoneIcon = icons.headphones;

TypeScript

const headphoneIcon = MDIcons.Headphones

icon2enum's People

Contributors

fatihbalsoy avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.