From de7d04b74e62128ae2a6c8d249b41b6c834dc7e4 Mon Sep 17 00:00:00 2001 From: Marcin Lulek Date: Fri, 26 Aug 2016 16:16:32 +0200 Subject: [PATCH] components: reorganize build pipeline to have nice separation of html/js/css --- .hgignore | 1 + Gruntfile.js | 13 ++- rhodecode/public/css/polymer.less | 18 ----- .../js/src/components/rhodecode-toast.html | 79 ------------------- .../rhodecode-toast/rhodecode-toast.html | 23 ++++++ .../rhodecode-toast/rhodecode-toast.js | 29 +++++++ .../rhodecode-toast/rhodecode-toast.less | 39 +++++++++ .../src/components/rhodecode-unsafe-html.html | 22 ------ .../rhodecode-unsafe-html.html | 9 +++ .../rhodecode-unsafe-html.js | 12 +++ .../js/src/components/shared-components.html | 4 +- 11 files changed, 126 insertions(+), 123 deletions(-) delete mode 100644 rhodecode/public/js/src/components/rhodecode-toast.html create mode 100644 rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.html create mode 100644 rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.js create mode 100644 rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.less delete mode 100644 rhodecode/public/js/src/components/rhodecode-unsafe-html.html create mode 100644 rhodecode/public/js/src/components/rhodecode-unsafe-html/rhodecode-unsafe-html.html create mode 100644 rhodecode/public/js/src/components/rhodecode-unsafe-html/rhodecode-unsafe-html.js diff --git a/.hgignore b/.hgignore index 13e7bc0a..4eccaa6d 100644 --- a/.hgignore +++ b/.hgignore @@ -8,6 +8,7 @@ syntax: glob *.swp *.tox *.DS_Store* +rhodecode/public/js/src/components/**/*.css syntax: regexp diff --git a/Gruntfile.js b/Gruntfile.js index c22a58c7..75741a90 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -129,13 +129,22 @@ module.exports = function(grunt) { "<%= dirs.css %>/style.css": "<%= dirs.css %>/main.less", "<%= dirs.css %>/style-polymer.css": "<%= dirs.css %>/polymer.less" } + }, + components: { + files: [{ + cwd: '<%= dirs.js.src %>/components/', + dest: '<%= dirs.js.src %>/components/', + src: ['**/*.less'], + expand: true, + ext: '.css' + }] } }, watch: { less: { files: ["<%= dirs.css %>/*.less"], - tasks: ["less:development", 'concat:polymercss', "vulcanize"] + tasks: ["less:development", 'less:components', 'concat:polymercss', "vulcanize"] }, js: { files: ["<%= dirs.js.src %>/**/*.js", "<%= dirs.js.src %>/components/*.*"], @@ -174,5 +183,5 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-crisper'); grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.registerTask('default', ['less:production', 'concat:polymercss', 'copy','vulcanize', 'concat:dist']); + grunt.registerTask('default', ['less:production', 'less:components', 'concat:polymercss', 'copy','vulcanize', 'concat:dist']); }; diff --git a/rhodecode/public/css/polymer.less b/rhodecode/public/css/polymer.less index 795a2de9..c222a9b3 100644 --- a/rhodecode/public/css/polymer.less +++ b/rhodecode/public/css/polymer.less @@ -13,21 +13,3 @@ @import 'examples'; @import 'login'; @import 'comments'; - - -.toast-level { - display: inline-block; - min-width: 100px; - font-weight: bold; - text-transform: uppercase; - &.info, &.success { - color: #0ac878; - } - &.error, &.danger { - color: #e85e4d; - } - &.warning { - color: #ffc854; - } -} - diff --git a/rhodecode/public/js/src/components/rhodecode-toast.html b/rhodecode/public/js/src/components/rhodecode-toast.html deleted file mode 100644 index c0f42f54..00000000 --- a/rhodecode/public/js/src/components/rhodecode-toast.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - diff --git a/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.html b/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.html new file mode 100644 index 00000000..e6f2d982 --- /dev/null +++ b/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.html @@ -0,0 +1,23 @@ + + + + + + + diff --git a/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.js b/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.js new file mode 100644 index 00000000..7455ece0 --- /dev/null +++ b/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.js @@ -0,0 +1,29 @@ +Polymer({ + is: 'rhodecode-toast', + properties: { + toasts: { + type: Array, + value: function(){ + return [] + } + } + }, + observers: [ + '_changedToasts(toasts.splices)' + ], + ready: function(){ + + }, + + _changedToasts: function(newValue, oldValue){ + this.$['p-toast'].notifyResize(); + }, + dismissNotifications: function(){ + this.$['p-toast'].close(); + this.splice('toasts', 0); + }, + open: function(){ + this.$['p-toast'].open(); + }, + _gettext: _gettext +}); diff --git a/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.less b/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.less new file mode 100644 index 00000000..77348a45 --- /dev/null +++ b/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.less @@ -0,0 +1,39 @@ +paper-toast{ + width: 100%; + min-width: 400px; + --paper-toast-background-color: #ffffff; + --paper-toast-color: #000000; +} +paper-toast a{ + font-weight: bold +} + +.toast-message-holder { + width: ~'calc(100% - 150px)'; + display: inline-block; +} +.toast-close { + display: inline-block; + width: 145px; + text-align: right; + float: right; +} +.toast-notification { + padding: 10px 0 10px 0; +} + +.toast-level { + display: inline-block; + min-width: 100px; + font-weight: bold; + text-transform: uppercase; + &.info, &.success { + color: #0ac878; + } + &.error, &.danger { + color: #e85e4d; + } + &.warning { + color: #ffc854; + } +} diff --git a/rhodecode/public/js/src/components/rhodecode-unsafe-html.html b/rhodecode/public/js/src/components/rhodecode-unsafe-html.html deleted file mode 100644 index 825b3152..00000000 --- a/rhodecode/public/js/src/components/rhodecode-unsafe-html.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - diff --git a/rhodecode/public/js/src/components/rhodecode-unsafe-html/rhodecode-unsafe-html.html b/rhodecode/public/js/src/components/rhodecode-unsafe-html/rhodecode-unsafe-html.html new file mode 100644 index 00000000..5595f479 --- /dev/null +++ b/rhodecode/public/js/src/components/rhodecode-unsafe-html/rhodecode-unsafe-html.html @@ -0,0 +1,9 @@ + + + + + + diff --git a/rhodecode/public/js/src/components/rhodecode-unsafe-html/rhodecode-unsafe-html.js b/rhodecode/public/js/src/components/rhodecode-unsafe-html/rhodecode-unsafe-html.js new file mode 100644 index 00000000..c41bd9a2 --- /dev/null +++ b/rhodecode/public/js/src/components/rhodecode-unsafe-html/rhodecode-unsafe-html.js @@ -0,0 +1,12 @@ +Polymer({ + is: 'rhodecode-unsafe-html', + properties: { + text: { + type: String, + observer: '_handleText' + } + }, + _handleText: function(newVal, oldVal){ + this.innerHTML = this.text; + } +}) diff --git a/rhodecode/public/js/src/components/shared-components.html b/rhodecode/public/js/src/components/shared-components.html index dc2a87d7..d157e73f 100644 --- a/rhodecode/public/js/src/components/shared-components.html +++ b/rhodecode/public/js/src/components/shared-components.html @@ -5,5 +5,5 @@ - - + +