summaryrefslogtreecommitdiff
path: root/app/Console/CssCommand.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2019-07-25 11:16:21 -0700
committerFrédéric Guillot <fred@kanboard.net>2019-07-25 11:16:21 -0700
commit9ae185c18eb06e3ce7e2daea0c61e6f6478bdca9 (patch)
treeace22189e031f7f78639f743a872d86c3a65eda0 /app/Console/CssCommand.php
parent2bf0f99b519aec5b2068a689a8051d88154e3850 (diff)
Remove dependency on Sass
- Convert *.sass files to vanilla CSS - Start using CSS variables - Add PHP minifier
Diffstat (limited to 'app/Console/CssCommand.php')
-rw-r--r--app/Console/CssCommand.php126
1 files changed, 126 insertions, 0 deletions
diff --git a/app/Console/CssCommand.php b/app/Console/CssCommand.php
new file mode 100644
index 00000000..f141519e
--- /dev/null
+++ b/app/Console/CssCommand.php
@@ -0,0 +1,126 @@
+<?php
+
+namespace Kanboard\Console;
+
+use MatthiasMullie\Minify;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+$path = __DIR__ . '/../../libs';
+require_once $path . '/minify/src/Minify.php';
+require_once $path . '/minify/src/CSS.php';
+require_once $path . '/minify/src/JS.php';
+require_once $path . '/minify/src/Exception.php';
+require_once $path . '/minify/src/Exceptions/BasicException.php';
+require_once $path . '/minify/src/Exceptions/FileImportException.php';
+require_once $path . '/minify/src/Exceptions/IOException.php';
+require_once $path . '/path-converter/src/ConverterInterface.php';
+require_once $path . '/path-converter/src/Converter.php';
+
+/**
+ * Class CssCommand
+ *
+ * @package Kanboard\Console
+ * @author Frederic Guillot
+ */
+class CssCommand extends BaseCommand
+{
+ const CSS_SRC_PATH = 'assets/css/src/';
+ const CSS_VENDOR_PATH = 'assets/vendor/';
+ const CSS_DIST_PATH = 'assets/css/';
+
+ private $appFiles = [
+ 'variables.css',
+ 'base.css',
+ 'links.css',
+ 'titles.css',
+ 'table.css',
+ 'table_drag_and_drop.css',
+ 'table_list.css',
+ 'form.css',
+ 'input_addon.css',
+ 'icon.css',
+ 'alert.css',
+ 'button.css',
+ 'tooltip.css',
+ 'dropdown.css',
+ 'accordion.css',
+ 'select_dropdown.css',
+ 'suggest_menu.css',
+ 'modal.css',
+ 'pagination.css',
+ 'header.css',
+ 'logo.css',
+ 'page_header.css',
+ 'sidebar.css',
+ 'avatar.css',
+ 'file_upload.css',
+ 'thumbnails.css',
+ 'color_picker.css',
+ 'filter_box.css',
+ 'project.css',
+ 'views.css',
+ 'dashboard.css',
+ 'board.css',
+ 'task_board.css',
+ 'task_icons.css',
+ 'task_category.css',
+ 'task_date.css',
+ 'task_tags.css',
+ 'task_summary.css',
+ 'task_form.css',
+ 'comment.css',
+ 'subtasks.css',
+ 'task_links.css',
+ 'text_editor.css',
+ 'markdown.css',
+ 'panel.css',
+ 'activity_stream.css',
+ 'user_mention.css',
+ 'slideshow.css',
+ 'list_items.css',
+ 'bulk_change.css',
+ ];
+
+ private $printFiles = [
+ 'print.css',
+ ];
+
+ private $vendorFiles = [
+ 'jquery-ui/jquery-ui.min.css',
+ 'jqueryui-timepicker-addon/jquery-ui-timepicker-addon.min.css',
+ 'select2/css/select2.min.css',
+ 'font-awesome/css/font-awesome.min.css',
+ 'c3/c3.min.css',
+ ];
+
+ protected function configure()
+ {
+ $this
+ ->setName('css')
+ ->setDescription('Minify CSS')
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $this->minifyFiles(self::CSS_SRC_PATH, $this->appFiles, 'app.min.css');
+ $this->minifyFiles(self::CSS_SRC_PATH, $this->printFiles, 'print.min.css');
+ $this->minifyFiles(self::CSS_VENDOR_PATH, $this->vendorFiles, 'vendor.min.css');
+ }
+
+ private function minifyFiles($folder, array $files, $destination)
+ {
+ $minifier = new Minify\CSS();
+
+ foreach ($files as $file) {
+ $filename = $folder. $file;
+ if (! file_exists($filename)) {
+ die("$filename not found\n");
+ }
+ $minifier->add($filename);
+ }
+
+ $minifier->minify(self::CSS_DIST_PATH . $destination);
+ }
+}