diff --git a/.gitignore b/.gitignore index 138828b..caf96cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ +.DS_Store node_modules npm-debug.log .tmp dist .grunt styleguide/index.html +icon_font/svgs diff --git a/Gruntfile.js b/Gruntfile.js index 1c69523..af9f633 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,6 +7,7 @@ module.exports = function (grunt) { clean: require('./tasks/clean'), sass: require('./tasks/sass'), cssmin: require('./tasks/cssmin'), + copy: require('./tasks/copy'), shell: require('./tasks/shell'), watch: require('./tasks/watch'), 'gh-pages': require('./tasks/gh-pages') @@ -14,22 +15,29 @@ module.exports = function (grunt) { var baseTasks = [ 'clean', + 'shell:generateFont', 'sass', 'concat', 'cssmin', + 'copy', 'shell' ]; + var generateFontTask = baseTasks.concat([ + 'shell:generateFont' + ]); + var devTasks = baseTasks.concat([ 'connect', 'watch:scss' ]); grunt.event.on('watch', function (action, filepath) { - grunt.task.run('shell'); + grunt.task.run('shell:style'); }); grunt.registerTask('dev', devTasks); + grunt.registerTask('generate-font', generateFontTask); grunt.registerTask('build', baseTasks); grunt.registerTask('default', baseTasks); grunt.registerTask('publish', ['build', 'gh-pages']); diff --git a/Gulpfile.js b/Gulpfile.js new file mode 100644 index 0000000..6870ea9 --- /dev/null +++ b/Gulpfile.js @@ -0,0 +1,21 @@ +var gulp = require('gulp'); +var iconfont = require('gulp-iconfont'); +var iconfontCss = require('gulp-iconfont-css'); + +gulp.task('default', function(){ + gulp.src(['./icon_font/svgs/*.svg']) + + .pipe(iconfontCss({ + fontName: 'cartoIcon', + path: './icon_font/template.jst.ejs', + targetPath: '../scss/icon-font.css.scss', + fontPath: '../../fonts/' + })) + + .pipe(iconfont({ + fontName: 'cartoIcon', + appendCodepoints: true + })) + + .pipe(gulp.dest('src/fonts/')); +}); diff --git a/README.md b/README.md index 67619a7..c365c83 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ > Share frontend assets between different CartoDB repositories - ### Installation As easy as: - ```npm install``` @@ -32,3 +31,32 @@ If you have these previous steps done: Just run this command: - ```grunt publish``` + +How to make changes in the CartoDB icon font +-------------------------------------------- + +If you want to edit, add or remove any icon in our CartoDB font, you should follow these steps: + +- Check you have [Sketch](http://bohemiancoding.com/sketch/) last version. +- Open [font.sketch](http://github.com/CartoDB/CartoAssets/blob/master/icon_font/font.sketch) file and make your changes. + +### Rules for the icons: +- Size should have at max 500px of width/height. +- Place the icon accordingly with the grid. +- Icons should be completely black. +- Group the icon if it has several parts. +- Make icons exportable to SVG. +- Name your icon (layer/group) according to the pattern `icon-font_xx_Name`, where xx is a unique integer (increase it for each new icon). + +### When you're done with changes + +- Select all the icons, and export them to `app/assets/fonts/icon_font/svgs` folder (option should be visible in the bottom corner in your Sketch app): + - ![screen shot 2015-01-16 at 11 40 36](https://cloud.githubusercontent.com/assets/978461/5774986/93dc90e8-9d74-11e4-8064-a478e55d392b.png) + - Take into account that ```svgs``` folder is ignored. +- Open your terminal app and go to the CartoDB root folder. +- Install your node dependencies: `npm install` +- Now we will generate the new icon fonts + stylesheet. Just run: `./node_modules/.bin/gulp` +- Check that your `icon-font.css.scss` and the `cartoIcon` fonts have been edited: + - ![screen shot 2015-01-16 at 11 02 53](https://cloud.githubusercontent.com/assets/978461/5775004/acf10faa-9d74-11e4-893c-790da626d894.png) + +All done! diff --git a/icon_font/README.md b/icon_font/README.md new file mode 100644 index 0000000..e69de29 diff --git a/icon_font/font.sketch b/icon_font/font.sketch new file mode 100644 index 0000000..4794cbd Binary files /dev/null and b/icon_font/font.sketch differ diff --git a/icon_font/template.jst.ejs b/icon_font/template.jst.ejs new file mode 100644 index 0000000..2f5cc75 --- /dev/null +++ b/icon_font/template.jst.ejs @@ -0,0 +1,37 @@ +@font-face { + font-family: 'CartoIcon'; + src: url('fonts/cartoIcon.eot'); + src: url('fonts/cartoIcon.eot?#iefix') format('embedded-opentype'), + url('fonts/cartoIcon.woff') format('woff'), + url('fonts/cartoIcon.ttf') format('truetype'), + url('fonts/cartoIcon.svg?ey3vsq#cartoIcon') format('svg'); + font-weight: normal; + font-style: normal; +} + +.IconFont { + display: inline-block; + font-family: 'CartoIcon'; + font-style: normal; + font-weight: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + line-height: 1; +} + +/* SG +# Icon font +``` +<% _.each(glyphs, function(glyph) { %> +

<%= glyph.fileName.split("_")[2] %>

+"> +<% }); %> +``` +*/ + +<% _.each(glyphs, function(glyph) { %> +.IconFont-<%= glyph.fileName.split("_")[2] %>::before { + content: '\<%= glyph.codePoint %>'; +} +<% }); %> + diff --git a/package.json b/package.json index 4e6c64b..19b581f 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,15 @@ "grunt-contrib-clean": "0.7.0", "grunt-contrib-concat": "0.5.1", "grunt-contrib-cssmin": "0.14.0", + "grunt-contrib-copy": "~0.5.0", "grunt-contrib-connect": "0.11.2", "grunt-contrib-watch": "0.6.1", "grunt-gh-pages": "1.0.0", + "gulp": "3.8.10", + "gulp-iconfont": "1.0.0", + "gulp-iconfont-css": "0.0.9", + "gulp-install": "0.2.0", + "gulp-sketch": "0.0.7", "grunt-shell": "1.1.2", "load-grunt-tasks": "*" }, diff --git a/src/fonts/cartoIcon.eot b/src/fonts/cartoIcon.eot new file mode 100644 index 0000000..69384a1 Binary files /dev/null and b/src/fonts/cartoIcon.eot differ diff --git a/src/fonts/cartoIcon.svg b/src/fonts/cartoIcon.svg new file mode 100644 index 0000000..dc79655 --- /dev/null +++ b/src/fonts/cartoIcon.svg @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/fonts/cartoIcon.ttf b/src/fonts/cartoIcon.ttf new file mode 100644 index 0000000..1bdb64d Binary files /dev/null and b/src/fonts/cartoIcon.ttf differ diff --git a/src/fonts/cartoIcon.woff b/src/fonts/cartoIcon.woff new file mode 100644 index 0000000..a6d1ec5 Binary files /dev/null and b/src/fonts/cartoIcon.woff differ diff --git a/src/scss/icon-font.css.scss b/src/scss/icon-font.css.scss new file mode 100644 index 0000000..c1bc793 --- /dev/null +++ b/src/scss/icon-font.css.scss @@ -0,0 +1,673 @@ +@font-face { + font-family: 'CartoIcon'; + src: url('fonts/cartoIcon.eot'); + src: url('fonts/cartoIcon.eot?#iefix') format('embedded-opentype'), + url('fonts/cartoIcon.woff') format('woff'), + url('fonts/cartoIcon.ttf') format('truetype'), + url('fonts/cartoIcon.svg?ey3vsq#cartoIcon') format('svg'); + font-weight: normal; + font-style: normal; +} + +.IconFont { + display: inline-block; + font-family: 'CartoIcon'; + font-style: normal; + font-weight: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + line-height: 1; +} + +/* SG +# Icon font +``` + +

Clock

+ + +

Stats

+ + +

Heart--empty

+ + +

Heart--fill

+ + +

Alert

+ + +

Rows

+ + +

Check

+ + +

Dribbble

+ + +

Twitter

+ + +

Wizard

+ + +

Info

+ + +

Fork

+ + +

Facebook

+ + +

Folder

+ + +

Dropbox

+ + +

Cloud

+ + +

Step

+ + +

AddDocument

+ + +

ArrowNext

+ + +

ArrowPrev

+ + +

Close

+ + +

CartoFante

+ + +

Lock

+ + +

CartoDB

+ + +

Lens

+ + +

CloseLimits

+ + +

DefaultUser

+ + +

Cockroach

+ + +

Floppy

+ + +

Trash

+ + +

Wifi

+ + +

Unlock

+ + +

Unlock--withEllipsis

+ + +

Gift

+ + +

People

+ + +

Play

+ + +

Add

+ + +

Map

+ + +

Anchor

+ + +

Key

+ + +

Calendar

+ + +

Document

+ + +

Eye

+ + +

Marker

+ + +

ProgressBar

+ + +

Book

+ + +

Notes

+ + +

Rectangles

+ + +

Mountain

+ + +

Points

+ + +

Snake

+ + +

Boss

+ + +

Rocket

+ + +

Barometer

+ + +

Dollar

+ + +

Email

+ + +

Label

+ + +

Outside

+ + +

Jigsaw

+ + +

Tools

+ + +

Question

+ + +

LayerStack

+ + +

Alarm

+ + +

CloudDownArrow

+ + +

Pencil

+ + +

FountainPen

+ + +

EmptyDoc

+ + +

MergeArrow

+ + +

MergeColumns

+ + +

MergeSpatial

+ + +

Globe

+ + +

ChevronDown

+ + +

Streets

+ + +

Keys

+ + +

FacebookSquare

+ + +

Fullscreen

+ + +

Rarrow

+ + +

Share

+ + +

Linkedin

+ + +

CalendarBlank

+ + +

CreativeCommons

+ + +

Bubble

+ + +

Bars

+ + +

ArrowMenu

+ + +

TieFighter

+ + +

Ray

+ + +

Markup

+ + +

Table

+ + +

Airlock

+ + +

Pin

+ + +

Attache

+ + +

Download

+ + +``` +*/ + + +.IconFont-Clock::before { + content: '\E001'; +} + +.IconFont-Stats::before { + content: '\E002'; +} + +.IconFont-Heart--empty::before { + content: '\E003'; +} + +.IconFont-Heart--fill::before { + content: '\E004'; +} + +.IconFont-Alert::before { + content: '\E005'; +} + +.IconFont-Rows::before { + content: '\E006'; +} + +.IconFont-Check::before { + content: '\E007'; +} + +.IconFont-Dribbble::before { + content: '\E008'; +} + +.IconFont-Twitter::before { + content: '\E009'; +} + +.IconFont-Wizard::before { + content: '\E00A'; +} + +.IconFont-Info::before { + content: '\E00B'; +} + +.IconFont-Fork::before { + content: '\E00C'; +} + +.IconFont-Facebook::before { + content: '\E00D'; +} + +.IconFont-Folder::before { + content: '\E00E'; +} + +.IconFont-Dropbox::before { + content: '\E00F'; +} + +.IconFont-Cloud::before { + content: '\E010'; +} + +.IconFont-Step::before { + content: '\E011'; +} + +.IconFont-AddDocument::before { + content: '\E012'; +} + +.IconFont-ArrowNext::before { + content: '\E013'; +} + +.IconFont-ArrowPrev::before { + content: '\E014'; +} + +.IconFont-Close::before { + content: '\E015'; +} + +.IconFont-CartoFante::before { + content: '\E016'; +} + +.IconFont-Lock::before { + content: '\E017'; +} + +.IconFont-CartoDB::before { + content: '\E018'; +} + +.IconFont-Lens::before { + content: '\E019'; +} + +.IconFont-CloseLimits::before { + content: '\E01A'; +} + +.IconFont-DefaultUser::before { + content: '\E01B'; +} + +.IconFont-Cockroach::before { + content: '\E01C'; +} + +.IconFont-Floppy::before { + content: '\E01D'; +} + +.IconFont-Trash::before { + content: '\E01E'; +} + +.IconFont-Wifi::before { + content: '\E01F'; +} + +.IconFont-Unlock::before { + content: '\E020'; +} + +.IconFont-Unlock--withEllipsis::before { + content: '\E021'; +} + +.IconFont-Gift::before { + content: '\E022'; +} + +.IconFont-People::before { + content: '\E023'; +} + +.IconFont-Play::before { + content: '\E024'; +} + +.IconFont-Add::before { + content: '\E025'; +} + +.IconFont-Map::before { + content: '\E026'; +} + +.IconFont-Anchor::before { + content: '\E027'; +} + +.IconFont-Key::before { + content: '\E028'; +} + +.IconFont-Calendar::before { + content: '\E029'; +} + +.IconFont-Document::before { + content: '\E02A'; +} + +.IconFont-Eye::before { + content: '\E02B'; +} + +.IconFont-Marker::before { + content: '\E02C'; +} + +.IconFont-ProgressBar::before { + content: '\E02D'; +} + +.IconFont-Book::before { + content: '\E02E'; +} + +.IconFont-Notes::before { + content: '\E02F'; +} + +.IconFont-Rectangles::before { + content: '\E030'; +} + +.IconFont-Mountain::before { + content: '\E031'; +} + +.IconFont-Points::before { + content: '\E032'; +} + +.IconFont-Snake::before { + content: '\E033'; +} + +.IconFont-Boss::before { + content: '\E034'; +} + +.IconFont-Rocket::before { + content: '\E035'; +} + +.IconFont-Barometer::before { + content: '\E036'; +} + +.IconFont-Dollar::before { + content: '\E037'; +} + +.IconFont-Email::before { + content: '\E038'; +} + +.IconFont-Label::before { + content: '\E039'; +} + +.IconFont-Outside::before { + content: '\E03A'; +} + +.IconFont-Jigsaw::before { + content: '\E03B'; +} + +.IconFont-Tools::before { + content: '\E03C'; +} + +.IconFont-Question::before { + content: '\E03D'; +} + +.IconFont-LayerStack::before { + content: '\E03E'; +} + +.IconFont-Alarm::before { + content: '\E03F'; +} + +.IconFont-CloudDownArrow::before { + content: '\E040'; +} + +.IconFont-Pencil::before { + content: '\E041'; +} + +.IconFont-FountainPen::before { + content: '\E042'; +} + +.IconFont-EmptyDoc::before { + content: '\E043'; +} + +.IconFont-MergeArrow::before { + content: '\E044'; +} + +.IconFont-MergeColumns::before { + content: '\E045'; +} + +.IconFont-MergeSpatial::before { + content: '\E046'; +} + +.IconFont-Globe::before { + content: '\E047'; +} + +.IconFont-ChevronDown::before { + content: '\E048'; +} + +.IconFont-Streets::before { + content: '\E049'; +} + +.IconFont-Keys::before { + content: '\E04A'; +} + +.IconFont-FacebookSquare::before { + content: '\E04B'; +} + +.IconFont-Fullscreen::before { + content: '\E04C'; +} + +.IconFont-Rarrow::before { + content: '\E04D'; +} + +.IconFont-Share::before { + content: '\E04E'; +} + +.IconFont-Linkedin::before { + content: '\E04F'; +} + +.IconFont-CalendarBlank::before { + content: '\E050'; +} + +.IconFont-CreativeCommons::before { + content: '\E051'; +} + +.IconFont-Bubble::before { + content: '\E052'; +} + +.IconFont-Bars::before { + content: '\E053'; +} + +.IconFont-ArrowMenu::before { + content: '\E054'; +} + +.IconFont-TieFighter::before { + content: '\E055'; +} + +.IconFont-Ray::before { + content: '\E056'; +} + +.IconFont-Markup::before { + content: '\E057'; +} + +.IconFont-Table::before { + content: '\E058'; +} + +.IconFont-Airlock::before { + content: '\E059'; +} + +.IconFont-Pin::before { + content: '\E05A'; +} + +.IconFont-Attache::before { + content: '\E05B'; +} + +.IconFont-Download::before { + content: '\E05C'; +} + diff --git a/tasks/copy.js b/tasks/copy.js new file mode 100644 index 0000000..fd09f93 --- /dev/null +++ b/tasks/copy.js @@ -0,0 +1,7 @@ +module.exports = { + main: { + files: [ + { expand: true, cwd: 'src/', src: 'fonts/**', dest: 'dist/' }, + ] + } +}; diff --git a/tasks/shell.js b/tasks/shell.js index 99da8aa..299a370 100644 --- a/tasks/shell.js +++ b/tasks/shell.js @@ -1,5 +1,8 @@ module.exports = { - dist: { + style: { command: 'styleguide' + }, + generateFont: { + command: 'gulp' } };