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

fix: replace "\n" to support Windows for tokens output #8352

Merged
merged 20 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
25e7f9b
fix(color context tokens): only apply when .calcite-mode-auto is appl…
alisonailea Dec 6, 2023
48ecd08
fix: git code scanning issue
alisonailea Dec 6, 2023
32cf21a
chore: add prettier types
alisonailea Dec 6, 2023
aa060a1
chore: handoff formatting to Prettier
alisonailea Dec 6, 2023
f704a89
fix: give modal access to core calcite-tokens
alisonailea Dec 7, 2023
ea45dbd
refactor(dropdown): remove obsolete logic (#8321)
jcfranco Dec 6, 2023
ae1eb85
build(deps): update dependency @types/jest-axe to v3.5.9 (#8346)
renovate[bot] Dec 6, 2023
3cb62c7
test(dropdown): fix dropdown E2E suite grouping (#8319)
jcfranco Dec 6, 2023
21c9ea7
refactor(input, input-number, input-text): avoid redundant `:host` (#…
jcfranco Dec 6, 2023
c997ba1
ci: remove workarounds no longer needed with Stencil v4 (#8325)
benelan Dec 6, 2023
70879ae
build(deps): update dependency @types/shell-quote to v1.7.5 (#8349)
renovate[bot] Dec 6, 2023
0fef7e3
ci: stop formatting components.d.ts (#8358)
benelan Dec 6, 2023
b50f853
build(deps): update dependency @types/semver to v7.5.6 (#8348)
renovate[bot] Dec 6, 2023
909b450
build(deps): update dependency @types/lodash-es to v4.17.12 (#8347)
renovate[bot] Dec 6, 2023
5953ada
build(deps): update dependency sortablejs to v1.15.1 (#8364)
renovate[bot] Dec 7, 2023
161502a
fix(shell-panel): adds border at the start when slotted in `panel-end…
anveshmekala Dec 7, 2023
033250b
fix(input-date-picker): no longer emits redundant change event (#8341)
anveshmekala Dec 7, 2023
b3105be
Merge branch 'main' into astump/8350-new-line
alisonailea Dec 7, 2023
0afd98a
fix: use EOL to get the correct output from prettier
alisonailea Dec 7, 2023
0598074
test: fix token snapshot tests
alisonailea Dec 7, 2023
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
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@types/jest-axe": "3.5.9",
"@types/lodash-es": "4.17.12",
"@types/node": "^18.0.0",
"@types/prettier": "2.7.2",
"@types/react": "^16.7.6",
"@types/react-dom": "^16.0.9",
"@types/semver": "7.5.6",
Expand Down
4 changes: 3 additions & 1 deletion packages/calcite-components/src/components/modal/modal.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "~@esri/calcite-design-tokens/dist/scss/core";

/**
* CSS Custom Properties
*
Expand All @@ -21,7 +23,7 @@
transition: visibility 0ms linear var(--calcite-internal-animation-timing-slow),
opacity var(--calcite-internal-animation-timing-slow) $easing-function;
// the modal should always use a dark scrim, regardless of light / dark mode - matches value in global.scss
--calcite-modal-scrim-background-internal: #{rgba($calcite-color-neutral-blk-240, 0.85)};
--calcite-modal-scrim-background-internal: #{rgba($calcite-color-neutral-blk-240, $calcite-opacity-85)};
}

.content-top[hidden],
Expand Down
1,001 changes: 505 additions & 496 deletions packages/calcite-design-tokens/support/tests/__snapshots__/index.spec.ts.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import sd, { Core as StyleDictionary } from "style-dictionary";
import * as prettier from "prettier";

import { formatTokens } from "./utils/formatTokens.js";
import { formatExtraOutput } from "./utils/formatExtraOutput.js";
import { CalledFormatterFunction, FormatterConfig } from "../../../types/styleDictionary/formatterArguments.js";
import { EOL } from "os";

export const formatCssPlatform: CalledFormatterFunction = (args) => {
const { file, dictionary } = args;
Expand All @@ -12,7 +14,7 @@ export const formatCssPlatform: CalledFormatterFunction = (args) => {
if (Object.keys(extraOutput).length > 0) {
formatExtraOutput(extraOutput, { ...args.options, header, buildPath: args.platform.buildPath });
}
return header + `:root {\n\t${tokens.join("\n\t")}\n}\n`;
return prettier.format(header + `:root {${tokens.join(EOL)}}`, { parser: "css" });
};

export const registerFormatterCss = (sd: StyleDictionary): void => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Core as StyleDictionary } from "style-dictionary";
import * as prettier from "prettier";

import { CalledFormatterFunction, FormatterConfig } from "../../../types/styleDictionary/formatterArguments";

export const formatDocsPlatform: CalledFormatterFunction = (args) => {
Expand All @@ -15,7 +17,7 @@ export const formatDocsPlatform: CalledFormatterFunction = (args) => {
output.tokens[token.type].push(token);
}

return JSON.stringify(output, null, 2);
return prettier.format(JSON.stringify(output, null, 2), { parser: "json" });
};

export const registerFormatterDocs = (sd: StyleDictionary): void => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import styleDictionary, { Core as StyleDictionary } from "style-dictionary";
import * as prettier from "prettier";

import { CalledFormatterFunction, FormatterConfig } from "../../../types/styleDictionary/formatterArguments";

export const formatJsPlatform: CalledFormatterFunction = (args) => {
return (
return prettier.format(
styleDictionary.formatHelpers.fileHeader({ file: args.file }) +
"export default " +
JSON.stringify(args.dictionary.properties, null, 2) +
";\n"
"export default " +
JSON.stringify(args.dictionary.properties, null, 2) +
";",
{ parser: "babel" }
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import sd, { Core as StyleDictionary } from "style-dictionary";

import { formatTokens } from "./utils/formatTokens.js";
import { formatExtraOutput } from "./utils/formatExtraOutput.js";
import * as prettier from "prettier";

import { CalledFormatterFunction, FormatterConfig } from "../../../types/styleDictionary/formatterArguments.js";
import { EOL } from "os";

export const formatScssPlatform: CalledFormatterFunction = (args) => {
const { file, dictionary } = args;
Expand All @@ -12,7 +15,7 @@ export const formatScssPlatform: CalledFormatterFunction = (args) => {
if (Object.keys(extraOutput).length > 0) {
formatExtraOutput(extraOutput, { ...args.options, header, buildPath: args.platform.buildPath });
}
return header + tokens.join("\n");
return prettier.format(header + tokens.join(EOL), { parser: "scss" });
};

export const registerFormatterScss = (sd: StyleDictionary): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ export const FormattingRules: Partial<Record<PlatformUnion | "default", Formatte
commentStyle: "long",
indentation: " ",
separator: ":",
join: "\n\t",
join: "",
suffix: ";",
},
sass: {
prefix: "$",
commentStyle: "short",
indentation: "",
separator: ":",
join: "\n",
join: "",
suffix: ";",
},
scss: {
prefix: "$",
commentStyle: "short",
indentation: "",
separator: ":",
join: "\n",
join: "",
suffix: ";",
},
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { writeFileSync } from "fs";
import { resolve } from "path";
import * as prettier from "prettier";

import { Platform } from "../../../../types/platform.js";
import { Options } from "../../../../types/styleDictionary/options.js";
import { DeepKeyTokenMap } from "../../../../types/tokenStudio/designTokenTypes.js";
Expand All @@ -14,6 +16,8 @@ export function formatExtraOutput(
const ensureIfArray = (x: any) => (Array.isArray(x) ? (x as any[]) : x);

if (index) {
let parser;
// Set output
switch (args.platform) {
case "css":
case "scss":
Expand All @@ -29,14 +33,14 @@ export function formatExtraOutput(
const classes = index.class
? index.class.map((cls) => {
const c = ensureIfArray(outputObject[`${cls[1]}.${args.platform}`]);
return cls && Array.isArray(c) ? `.${cls[0]} {\n\t${c.join("\n\t")}\n}` : "";
return cls && Array.isArray(c) ? `.${cls[0]} {${c.join("")}}` : "";
})
: [];
const mixins = index.mixin
? index.mixin.map(([mixinName, output]) => {
const m = ensureIfArray(outputObject[`${output}.${args.platform}`]);
return Array.isArray(m)
? `@mixin ${mixinName} {\n\t${m.map((o) => `${o}`.replaceAll("$", "--")).join("\n\t")}\n}`
? `@mixin ${mixinName} {${m.map((o) => `${o}`.replaceAll("$", "--")).join("")}}`
: "";
})
: [];
Expand All @@ -45,9 +49,8 @@ export function formatExtraOutput(
const m = ensureIfArray(outputObject[`${output}.${args.platform}`]);
const cssProps = m.map((o) => `${o}`.replaceAll("$", "--"));
return Array.isArray(m)
? `${
output === "light" ? `:root {\n\t${cssProps.join("\n\t")}\n}\n` : ""
}@media (${mediaSchemed}) {\n\t.calcite-mode-auto {\n\t\t${cssProps.join("\n\t\t")}\n\t}\n}`
? `${output === "light" ? `:root {${cssProps.join("")}}` : ""
}@media (${mediaSchemed}) {.calcite-mode-auto {${cssProps.join("")}}}`
: "";
})
: [];
Expand All @@ -72,32 +75,55 @@ export function formatExtraOutput(
break;
}

writeFileSync(resolve(args.buildPath, index.name), `${args.header}${outputFiles[index.name].join("\n\n")}\n`);
// Set Parser
switch (args.platform) {
case "css":
case "scss":
parser = args.platform;
break;
case "sass":
parser = "scss";
case "es6":
case "js":
parser = "babel";
break;
case "docs":
parser = "json";
default:
break;
}

writeFileSync(
resolve(args.buildPath, index.name),
prettier.format(`${args.header}${outputFiles[index.name].join(" ")}`, { parser })
);
}

Object.entries(outputObject).forEach(([fileName, outputList]) => {
const absoluteFilePath = resolve(args.buildPath, `${fileName}`);
switch (args.platform) {
case Platform.CSS:
if (typeof outputList[0] === "string" && outputList[0].slice(0, 2) === "--") {
writeFileSync(absoluteFilePath, `${args.header}:root{\n\t${outputList.join("\n\t")}\n}\n`);
writeFileSync(
absoluteFilePath,
prettier.format(`${args.header}:root{${outputList.join("")}}`, { parser: "css" })
);
} else {
writeFileSync(absoluteFilePath, `${args.header}${outputList.join("\n\n")}\n`);
writeFileSync(absoluteFilePath, prettier.format(`${args.header}${outputList.join("")}`, { parser: "css" }));
}
break;
case Platform.SCSS:
case Platform.SASS:
if (typeof outputList[0] === "string" && outputList[0][0] === "$") {
writeFileSync(absoluteFilePath, `${args.header}${outputList.join("\n")}\n`);
} else {
writeFileSync(absoluteFilePath, `${args.header}${outputList.join("\n\n")}\n`);
}
writeFileSync(absoluteFilePath, prettier.format(`${args.header}${outputList.join("")}`, { parser: "scss" }));
break;
case Platform.JS:
writeFileSync(absoluteFilePath, args.header + "export default " + outputList[0] + "\n");
writeFileSync(
absoluteFilePath,
prettier.format(args.header + "export default " + outputList[0] + "", { parser: "babel" })
);
break;
case Platform.DOCS:
writeFileSync(absoluteFilePath, outputList[0]);
writeFileSync(absoluteFilePath, prettier.format(outputList[0].join(""), { parser: "json" }));
break;
default:
break;
Expand Down
Loading