Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FINNA-2636] Add lessToScss command line task, adjust styles #3064

Merged
merged 30 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
80d6832
Add ScssFixerCommand
EreMaijala Oct 17, 2024
21b6130
scssFixer fully functional
EreMaijala Oct 18, 2024
8130508
Add fixes, variable resolution.
EreMaijala Oct 22, 2024
28508f2
lessToSass partially functional
EreMaijala Oct 22, 2024
0c0d580
lessToSass functional
EreMaijala Oct 22, 2024
f9c3e8c
Fix issues, rename command.
EreMaijala Oct 23, 2024
7229aa7
Revert finna2/less/finna.less
EreMaijala Oct 23, 2024
cb2fd46
Update custom theme import order.
EreMaijala Oct 23, 2024
dc42531
Fix null as string
EreMaijala Oct 23, 2024
86b80b8
Fix code style.
EreMaijala Oct 23, 2024
54a3b7c
Handle nested extends.
EreMaijala Oct 23, 2024
34a79d3
lessToSass
EreMaijala Oct 23, 2024
47afe20
Tweaks.
EreMaijala Oct 23, 2024
e4fd455
Handle multiple imports
EreMaijala Oct 23, 2024
5de8efd
Use standard vertical gradient.
EreMaijala Oct 23, 2024
4a2e462
Avoid useless capture.
EreMaijala Oct 23, 2024
963f3d3
Include numbers in variables.
EreMaijala Oct 23, 2024
274c9a7
Revert bad change.
EreMaijala Oct 23, 2024
83dc055
Fix media queries and interpolation, improve debug
EreMaijala Oct 24, 2024
caa7784
Add glob support etc.
EreMaijala Oct 24, 2024
40a3f2c
Reset file list on start.
EreMaijala Oct 24, 2024
97f4b48
Fix indentation.
EreMaijala Oct 24, 2024
dc49aa5
Allow fnmatch patterns in exclude
EreMaijala Oct 24, 2024
03bd1fe
Drop ScssFixer
EreMaijala Oct 24, 2024
97eef78
Add --enable_scss
EreMaijala Oct 24, 2024
56d3697
Improve media query variable support
EreMaijala Oct 24, 2024
2d6f62f
Use !default for variables when appropriate
EreMaijala Oct 24, 2024
aa0ab46
Make configuration more future-proof.
EreMaijala Oct 24, 2024
571196c
Revert order change in finna.less.
EreMaijala Oct 24, 2024
570f932
Update finna.scss
EreMaijala Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 32 additions & 47 deletions Gruntfile.local.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = function(grunt) {
const fs = require("fs");
const path = require("path");
const os = require("node:os");
const fsPromises = require("node:fs/promises");

grunt.registerTask("finna:scss", function finnaScssFunc() {
const config = getFinnaSassConfig({
Expand Down Expand Up @@ -48,19 +49,38 @@ module.exports = function(grunt) {
ext: '.scss'
};

let themeDir = grunt.option('theme-dir');
if (themeDir) {
themeDir = path.resolve(themeDir);
}
const files = themeDir
? [
let files = [];
let viewsDir = grunt.option('views-dir');
let themeDirs = grunt.option('theme-dirs');
if (viewsDir) {
const isViewDir = function (dir) {
const stat = fs.lstatSync(dir);
return stat.isDirectory() && fs.existsSync(dir + '/themes/custom');
};
const entries = grunt.file.expand(
{
filter: isViewDir,
},
viewsDir + '/*/*'
);
for (const viewDir of entries) {
files.push({
...sharedFileOpts,
cwd: viewDir + '/themes/custom/less',
dest: viewDir + '/themes/custom/scss'
});
}
} else if (themeDirs) {
Object.entries(themeDirs.split(',')).forEach(([, themeDir]) => {
themeDir = path.resolve(themeDir);
files.push({
...sharedFileOpts,
cwd: themeDir + '/less',
dest: themeDir + '/scss'
}
]
: [
});
});
} else {
files = [
{
...sharedFileOpts,
cwd: 'themes/finna2/less',
Expand All @@ -72,6 +92,7 @@ module.exports = function(grunt) {
dest: 'themes/custom/scss'
},
];
}

const replacements = [
// Activate SCSS
Expand Down Expand Up @@ -188,49 +209,13 @@ module.exports = function(grunt) {
}
);
}
if (grunt.option('replace-vars')) {
const vars = {
'action-link-color': '#007c90',
'gray-lighter': '#d1d1d1',
'gray-ultralight': '#f7f7f7',
'gray-light': '#595959',
'gray-darker': '#000',
'gray-dark': '#121212',
'gray': '#2b2b2b',
'body-bg': '#fff',
'screen-xs': '480px',
'screen-xs-min': '480px',
'screen-xs-max': '767px',
'screen-sm': '768px',
'screen-sm-min': '768px',
'screen-md': '992px',
'screen-md-min': '992px',
'navbar-default-link-color': '#fff',
'content-font-size-base': '16px',
'content-headings-font-size-h1': '28px',
'content-headings-font-size-h2': '24px',
'content-headings-font-size-h3': '21px',
'content-headings-font-size-h4': '18px',
};
let order = 20;
// Change variables where used (but not where declared!):
Object.entries(vars).forEach(([src, dst]) => {
replacements.push(
{
pattern: new RegExp("(.+)\\$(" + src + ")\\b", "g"),
replacement: '$1' + dst + ' /* $2 */',
order: order
}
);
++order;
});
}

console.log(themeDir ? "Converting theme " + themeDir : "Converting Finna default themes");
console.log(themeDirs || viewsDir ? "Converting specified themes" : "Converting Finna default themes");
grunt.config.set('lessToSass', {
convert: {
files: files,
options: {
excludes: ['important'],
replacements: replacements
}
}
Expand Down
Loading
Loading