Skip to content

Commit

Permalink
Update to Font Awesome 4.5 (#21), update icons resolver to add new ic…
Browse files Browse the repository at this point in the history
…ons automatically, fix CSS scoping issue (#35)
  • Loading branch information
Mark-H committed Mar 7, 2016
1 parent 0c1ae74 commit 252fe95
Show file tree
Hide file tree
Showing 22 changed files with 447 additions and 78 deletions.
30 changes: 24 additions & 6 deletions _build/resolvers/resolve.icons.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

/** @var modX $modx */
// Used for bootstrapping
if (!isset($modx)) {
$modx =& $object->xpdo;
}

switch($options[xPDOTransport::PACKAGE_ACTION]) {
case xPDOTransport::ACTION_INSTALL:
case xPDOTransport::ACTION_UPGRADE:

$modelPath = $modx->getOption('quickstartbuttons.core_path', null, $modx->getOption('core_path').'components/quickstartbuttons/').'model/';
$modx->addPackage('quickstartbuttons', $modelPath);
Expand All @@ -16,14 +17,15 @@
$assetsPath = $modx->getOption('quickstartbuttons.assets_path', null, $modx->getOption('assets_path').'components/quickstartbuttons/');

$icons = array();
$iconsFile = $assetsPath.'fontawesome/icons.css';
$iconsFile = $assetsPath.'lib/font-awesome/css/font-awesome.css';
if(file_exists($iconsFile)) {

$cssIcons = file_get_contents($iconsFile);
preg_match_all('/(.[a-z0-9]*?\.?'.addcslashes('fa', '-').'.*?)\s?\{/', $cssIcons, $matches);
preg_match_all('/\.(fa\-[a-zA-Z0-9\-]*?):before \{/', $cssIcons, $matches);
$classes = $matches[1];

foreach($classes as $key => $class) {

$class = str_replace(array('i.', ':before', ':after'), '', $class);
$classes[$key] = $class;
}
Expand All @@ -36,21 +38,37 @@
$name = str_replace('fa-', '', $class);
$name = str_replace('-', ' ', $name);

$icons[] = $modx->newObject('qsbIcon', array(
$exists = $modx->getCount('qsbIcon', array(
'name' => ucwords($name),
'class' => $class,
'preset' => true,
));

if ($exists < 1) {
$icons[] = $modx->newObject('qsbIcon', array(
'name' => ucwords($name),
'class' => $class,
'preset' => true,
));
}
}
}

$icons[] = $modx->newObject('qsbIcon', array(
$exists = $modx->getCount('qsbIcon', array(
'name' => 'modmore',
'class' => 'icon-modmore',
'path' => '[[++assets_url]]components/quickstartbuttons/icons/modmore.png',
'preset' => true,
));

if ($exists < 1) {
$icons[] = $modx->newObject('qsbIcon', array(
'name' => 'modmore',
'class' => 'icon-modmore',
'path' => '[[++assets_url]]components/quickstartbuttons/icons/modmore.png',
'preset' => true,
));
}

// save all
foreach($icons as $icon) {
$icon->save();
Expand Down
2 changes: 1 addition & 1 deletion _build/templates/default/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"tests"
],
"dependencies": {
"font-awesome": "~4.3.0"
"font-awesome": "~4"
},
"exportsOverride": {
"font-awesome": {
Expand Down
2 changes: 1 addition & 1 deletion _build/templates/default/gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function(grunt) {
copy: { /* move files */
fontawesome: {
files:[
{src: ['<%= dirs.lib %>font-awesome/css/*', '<%= dirs.lib %>font-awesome/fonts/*', '!<%= dirs.lib %>font-awesome/css/*.css.map'],dest:'<%= dirs.theme %><%= dirs.assets %>fontawesome/',expand:true,flatten:true}
{src: ['<%= dirs.lib %>font-awesome/css/*','<%= dirs.lib %>font-awesome/fonts/*'],dest:'<%= dirs.theme %><%= dirs.assets %>'}
]
}
},
Expand Down
10 changes: 1 addition & 9 deletions _build/templates/default/scss/mgr.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import url('../fontawesome/fonts.css');
@import url('../lib/font-awesome/css/font-awesome.min.css');

/* Dashboard Widget */

Expand Down Expand Up @@ -114,14 +114,6 @@
/* Manager window */

i.fa.fa-larger { font-size: 1.2em; }
i.icon {
display: inline-block;
width: 16px;
height: 16px;
background-size: 100%;
background-repeat: no-repeat;
background-position: left center;
}

/* Vertical window tabs */
.window-vtabs .x-panel-ml {
Expand Down
11 changes: 1 addition & 10 deletions _build/templates/default/scss/mgr23.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import url('../fontawesome/fonts.css');
@import url('../lib/font-awesome/css/font-awesome.min.css');

/* Dashboard Widget */

Expand Down Expand Up @@ -114,16 +114,7 @@
}

/* Manager window */

i.fa.fa-larger { font-size: 1.2em; }
i.icon {
display: inline-block;
width: 16px;
height: 16px;
background-size: 100%;
background-repeat: no-repeat;
background-position: left center;
}

/* Vertical window tabs */
.window-vtabs .x-panel-ml {
Expand Down
11 changes: 1 addition & 10 deletions assets/components/quickstartbuttons/css/mgr.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import url("../fontawesome/font-awesome.min.css");
@import url("../lib/font-awesome/css/font-awesome.min.css");
/* Dashboard Widget */
#quickstartbuttons-widget {
width: auto;
Expand Down Expand Up @@ -132,15 +132,6 @@ i.fa.fa-larger {
font-size: 1.2em;
}

i.icon {
display: inline-block;
width: 16px;
height: 16px;
background-size: 100%;
background-repeat: no-repeat;
background-position: left center;
}

/* Vertical window tabs */
.window-vtabs .x-panel-ml {
padding: 0 !important;
Expand Down
11 changes: 1 addition & 10 deletions assets/components/quickstartbuttons/css/mgr23.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import url("../fontawesome/font-awesome.min.css");
@import url("../lib/font-awesome/css/font-awesome.min.css");
/* Dashboard Widget */
#quickstartbuttons-widget {
width: auto;
Expand Down Expand Up @@ -133,15 +133,6 @@ i.fa.fa-larger {
font-size: 1.2em;
}

i.icon {
display: inline-block;
width: 16px;
height: 16px;
background-size: 100%;
background-repeat: no-repeat;
background-position: left center;
}

/* Vertical window tabs */
.window-vtabs .x-panel-ml {
padding: 0 !important;
Expand Down
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 252fe95

Please sign in to comment.