Skip to content

Commit

Permalink
FIDEFE-4640 - Add MPL license and how to edit file header (mozilla#7)
Browse files Browse the repository at this point in the history
* FIDEFE-4640 - Add MPL license and how to edit file header

* Add custom file header function that deals with the MPL and how to edit
  • Loading branch information
TGiles authored Jan 30, 2024
1 parent fc44ab9 commit c599909
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
11 changes: 11 additions & 0 deletions toolkit/themes/shared/design-system/build/css/tokens-shared.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

/**
* Do not edit this file directly, instead modify design-tokens.json
* and run `npm run build` to see your changes.
*/

:root {
--text-color-deemphasized: color-mix(in srgb, currentColor 60%, transparent);
--color-white: #ffffff;
Expand Down
27 changes: 26 additions & 1 deletion toolkit/themes/shared/design-system/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,31 @@
const StyleDictionary = require("style-dictionary");
const { formattedVariables } = StyleDictionary.formatHelpers;

/**
* Adds the Mozilla Public License header in one comment and
* how to make changes in the generated output files via the
* design-tokens.json file in another comment.
*
* @return {String} Formatted comment header string
*/
let customFileHeader = () => {
let licenseString = [
"/**",
" * This Source Code Form is subject to the terms of the Mozilla Public",
" * License, v. 2.0. If a copy of the MPL was not distributed with this",
" * file, You can obtain one at http://mozilla.org/MPL/2.0/.",
" */"
].join("\n");

let commentString = [
"/**",
" * Do not edit this file directly, instead modify design-tokens.json",
" * and run `npm run build` to see your changes.",
" */"
].join("\n");
return [licenseString + "\n\n" + commentString + "\n\n"];
}

const MEDIA_QUERY_PROPERTY_MAP = {
"forced-colors": "forcedColors",
"prefers-contrast": "prefersContrast",
Expand All @@ -24,6 +49,7 @@ const MEDIA_QUERY_PROPERTY_MAP = {
*/
function hcmFormatter(args) {
return (
customFileHeader() +
formatTokens({ args }) +
formatTokens({ mediaQuery: "prefers-contrast", args }) +
formatTokens({ mediaQuery: "forced-colors", args })
Expand Down Expand Up @@ -142,7 +168,6 @@ module.exports = {
format: "css/variables/hcm",
options: {
outputReferences: true,
showFileHeader: false,
},
},
],
Expand Down

0 comments on commit c599909

Please sign in to comment.