[new ui] refactoring sprite generation

This commit is contained in:
maxkadushkin
2025-03-19 12:30:14 +03:00
parent 307e732fa2
commit 8c9c4fcfc2
3 changed files with 27 additions and 10 deletions

View File

@ -84,7 +84,7 @@ define([
source: 'static',
icons: {
basepath: './resources/img/v2',
cls: 'next-mod',
cls: 'mod2',
}
},
}

View File

@ -145,9 +145,11 @@
@import "thumbnails.less";
@import "sprites/iconssmall@1x";
@import "sprites/iconssmall@1x.v2";
@import "sprites/iconsbig@1x";
@import "sprites/iconshuge@1x";
@import "sprites/iconssmall@1x.mod2";
@import "sprites/iconsbig@1x.mod2";
@import "sprites/iconshuge@1x.mod2";
@import "sprites/iconssmall@2x";
@import "sprites/iconsbig@2x";
@import "sprites/iconssmall@1.25x";

View File

@ -44,7 +44,8 @@ module.exports = function (grunt, rootpathprefix) {
return options.fn({name:name});
},
half: num => {return num/2;},
scaled: (num, factor) => {return num / factor;}
scaled: (num, factor) => {return num / factor;},
spritepostfix: () => `${opts.extpath ? opts.extpath : 'small'}-${scaling_table[opts.scale]}`,
};
const _prefix = rootpathprefix || '../../';
@ -72,10 +73,11 @@ module.exports = function (grunt, rootpathprefix) {
_scaled_path = `${opts.scale}/${opts.extpath ? opts.extpath : '.'}`;
let hbhelpers = {...helpers};
hbhelpers.spritepostfix = () => `${opts.extpath ? opts.extpath : 'small'}-${scaling_table[opts.scale]}`;
hbhelpers.extracls = () => '.theme-icons-cls-mod2 ';
return {
src: [`${_editor_res_root}/img/toolbar/v2/${_scaled_path}/*.png`, `${_common_res_root}/img/toolbar/v2/${_scaled_path}/*.png`],
dest: `${_editor_res_root}/img/v2/${opts.scale != '1x' ? opts.spritename + '@' + opts.scale : opts.spritename}.png`,
destCss: `${_editor_res_root}/less/sprites/${opts.spritename}@${opts.scale}.less`,
destCss: `${_editor_res_root}/less/sprites/${opts.spritename}@${opts.scale}.mod2.less`,
cssTemplate: `${_common_res_root}/img/toolbar/${_scaled_path}/.css.handlebars`,
algorithm: 'top-down',
cssHandlebarsHelpers: hbhelpers
@ -89,11 +91,6 @@ module.exports = function (grunt, rootpathprefix) {
spritename: sprite_name,
scale: '1x'
}),
'word-v2-1x': configTemplateV2({
editor:'documenteditor',
spritename: sprite_name,
scale: '1x'
}),
'word-big-1x': configTemplate({
editor:'documenteditor',
spritename: sprite_name_big,
@ -106,6 +103,23 @@ module.exports = function (grunt, rootpathprefix) {
scale: '1x',
extpath: 'huge'
}),
'word-mod2-1x': configTemplateV2({
editor:'documenteditor',
spritename: sprite_name,
scale: '1x'
}),
'word-mod2-big-1x': configTemplateV2({
editor:'documenteditor',
spritename: sprite_name_big,
scale: '1x',
extpath: 'big'
}),
'word-mod2-huge-1x': configTemplateV2({
editor:'documenteditor',
spritename: sprite_name_huge,
scale: '1x',
extpath: 'huge'
}),
'word-2x': configTemplate({
editor:'documenteditor',
spritename: sprite_name,
@ -692,7 +706,8 @@ module.exports = function (grunt, rootpathprefix) {
grunt.loadNpmTasks('grunt-spritesmith');
grunt.loadNpmTasks('grunt-svg-sprite');
grunt.registerTask('word-icons', ['sprite:word-1x', 'sprite:word-v2-1x', 'sprite:word-big-1x', 'sprite:word-huge-1x', 'sprite:word-2x', 'sprite:word-big-2x', 'sprite:word-huge-2x',
grunt.registerTask('word-icons', ['sprite:word-1x', 'sprite:word-mod2-1x', 'sprite:word-big-1x','sprite:word-mod2-big-1x', 'sprite:word-huge-1x', 'sprite:word-mod2-huge-1x',
'sprite:word-2x', 'sprite:word-big-2x', 'sprite:word-huge-2x',
'sprite:word1.25x', 'sprite:word-big-1.25x', 'sprite:word-huge-1.25x',
'sprite:word1.5x', 'sprite:word-big-1.5x', 'sprite:word-huge-1.5x',
'sprite:word1.75x', 'sprite:word-big-1.75x', 'sprite:word-huge-1.75x']);