From 4c016b95f8d219f7b0c25bf1757be28104c6a40a Mon Sep 17 00:00:00 2001 From: Jon Robson Date: Fri, 20 Sep 2024 17:06:46 -0700 Subject: [PATCH] Fixes skin creation tool. Only run for new versions of MediaWiki I don't have time to support both. --- package-lock.json | 15 +++++++++++++++ package.json | 6 +++--- src/constants.js | 1 + src/pages/Add.vue | 44 ++++++++++++-------------------------------- 4 files changed, 31 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9c4321e..6ab4e59 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@babel/cli": "^7.19.3", "@babel/node": "^7.18.10", + "@wikimedia/codex-design-tokens": "^1.13.0", "less": "4.1.0", "mediawiki-skins-cli": "0.5.6", "mediawiki-skins-cli-latest": "npm:mediawiki-skins-cli@1.43.0", @@ -3321,6 +3322,15 @@ "vue-template-compiler": "^2.x" } }, + "node_modules/@wikimedia/codex-design-tokens": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@wikimedia/codex-design-tokens/-/codex-design-tokens-1.13.0.tgz", + "integrity": "sha512-cg779hPs54x/L/+I6slEoDe5pYmSP0Ryj9NNmeqzehq95lERfYhenCxGBEZeQOqtP73SBy/7RpxyX1gFTBQP6g==", + "engines": { + "node": ">=18", + "npm": ">=7.21.0" + } + }, "node_modules/abab": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", @@ -22151,6 +22161,11 @@ "pretty": "^2.0.0" } }, + "@wikimedia/codex-design-tokens": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@wikimedia/codex-design-tokens/-/codex-design-tokens-1.13.0.tgz", + "integrity": "sha512-cg779hPs54x/L/+I6slEoDe5pYmSP0Ryj9NNmeqzehq95lERfYhenCxGBEZeQOqtP73SBy/7RpxyX1gFTBQP6g==" + }, "abab": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", diff --git a/package.json b/package.json index 73f2ede..b551cb7 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,10 @@ "vue-template-compiler": "2.6.12" }, "dependencies": { - "@babel/cli": "^7.19.3", - "@babel/node": "^7.18.10", + "@babel/cli": "7.19.3", + "@babel/node": "7.18.10", + "@wikimedia/codex-design-tokens": "1.13.0", "less": "4.1.0", - "mediawiki-skins-cli": "0.5.6", "mediawiki-skins-cli-latest": "npm:mediawiki-skins-cli@1.43.0", "mustache": "4.1.0", "node-fetch": "3.2.10", diff --git a/src/constants.js b/src/constants.js index f1f3bcf..0a0fb34 100644 --- a/src/constants.js +++ b/src/constants.js @@ -24,6 +24,7 @@ export const SKIN_KEY_SPECIAL_CASES = { // sync with resources/src/mediawiki.less/mediawiki.skin.defaults.less in mediawiki/core export const LESS_GLOBAL_VARS = { + 'z-index-stacking-1': '1', 'min-width-breakpoint-mobile': '320px', 'min-width-breakpoint-tablet': '720px', 'min-width-breakpoint-desktop': '1000px' diff --git a/src/pages/Add.vue b/src/pages/Add.vue index 35b26aa..53df242 100644 --- a/src/pages/Add.vue +++ b/src/pages/Add.vue @@ -16,13 +16,7 @@
- + 1.43
/* global less */ import { PARTIALS, getLessVarsCode, getLessVarsRaw, JQUERY, - buildSkin, getLESSFromTemplate, randomColor, + buildSkin, + getLESSFromTemplate, randomColor, buildDefaultAssets, getResourceLoaderSkinModuleStylesFromStylesheet, - SCRIPTS, messages } from 'mediawiki-skins-cli'; -import { buildSkin as buildSkinLatest } from 'mediawiki-skins-cli-latest'; + SCRIPTS, messages } from 'mediawiki-skins-cli-latest'; import api from '../api.js'; import { TEST_ARTICLES, HOST, LESS_RENDER_OPTIONS } from '../constants'; import { render } from 'mustache'; @@ -109,6 +103,8 @@ import Preview from '../components/Preview.vue'; import nameMe from '../nameMe'; import JsonViewer from 'vue-json-viewer'; import Page from './Page.vue'; +import fs from 'fs'; +const tokens = fs.readFileSync( './node_modules/@wikimedia/codex-design-tokens/theme-wikimedia-ui.less' ).toString(); const assets = buildDefaultAssets(); const DEFAULT_SKIN_MUSTACHE = assets.mustache; @@ -127,7 +123,6 @@ ${DEFAULT_SKIN_LESS} const DEFAULT_SKIN_PROPS = { html: DEFAULT_HTML, anon: true, - skinOutputVersion: '1.43', variables: getLessVarsRaw(), less: generateStylesheetLESS(), js: `/* scripts can go here */ @@ -195,9 +190,6 @@ export default { this.json = json; } ); }, - changeVersion( ev ) { - localStorage.setItem( 'add-skinOutputVersion', ev.target.value ); - }, changeAnon( isAnon ) { this.anon = isAnon; localStorage.setItem( 'add-anon', isAnon ); @@ -237,11 +229,7 @@ export default { localStorage.setItem( 'add-skinname', this.skinname ); }, download() { - let fn = buildSkin; - if ( parseFloat( this.skinOutputVersion ) >= 1.41 ) { - fn = buildSkinLatest; - } - fn( this.skinname, this.mustache, this.less, this.js, this.variables ); + buildSkin( this.skinname, this.mustache, this.less, this.js, this.variables ); }, changeArticle( title ) { this.title = title; @@ -296,20 +284,12 @@ export default { // eslint-disable-next-line no-useless-escape const js = '