@heliux-org/ui-style 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +111 -0
- package/dist/_functions.scss +8 -0
- package/dist/_mixins.scss +3 -0
- package/dist/colors.json +696 -0
- package/dist/functions/_camelize.scss +25 -0
- package/dist/functions/_capitalize.scss +11 -0
- package/dist/functions/_contain.scss +8 -0
- package/dist/functions/_extract-rgb.scss +8 -0
- package/dist/functions/_map-collect.scss +17 -0
- package/dist/functions/functions/_camelize.scss +25 -0
- package/dist/functions/functions/_capitalize.scss +11 -0
- package/dist/functions/functions/_contain.scss +8 -0
- package/dist/functions/functions/_extract-rgb.scss +8 -0
- package/dist/functions/functions/_map-collect.scss +17 -0
- package/dist/index.css +1289 -0
- package/dist/index.css.map +1 -0
- package/dist/index.min.css +1 -0
- package/dist/mixins/_common.scss +67 -0
- package/dist/mixins/_states.scss +48 -0
- package/dist/mixins/_typography.scss +24 -0
- package/dist/mixins/mixins/_common.scss +67 -0
- package/dist/mixins/mixins/_states.scss +48 -0
- package/dist/mixins/mixins/_typography.scss +24 -0
- package/package.json +67 -0
- package/src/Icons/API.svg +3 -0
- package/src/Icons/Academy.svg +3 -0
- package/src/Icons/Activity.svg +3 -0
- package/src/Icons/Add.svg +4 -0
- package/src/Icons/AddNewDoc.svg +13 -0
- package/src/Icons/AddSmall.svg +4 -0
- package/src/Icons/AddToTeam.svg +6 -0
- package/src/Icons/AddUpdate.svg +4 -0
- package/src/Icons/Alert.svg +3 -0
- package/src/Icons/Announcement.svg +3 -0
- package/src/Icons/Apps.svg +3 -0
- package/src/Icons/Archive.svg +3 -0
- package/src/Icons/Attach.svg +3 -0
- package/src/Icons/Basic.svg +5 -0
- package/src/Icons/Battery.svg +3 -0
- package/src/Icons/BlockQuote.svg +8 -0
- package/src/Icons/Board.svg +3 -0
- package/src/Icons/BoardPrivate.svg +5 -0
- package/src/Icons/BoardShareable.svg +5 -0
- package/src/Icons/BoardTemplate.svg +5 -0
- package/src/Icons/Bold.svg +11 -0
- package/src/Icons/Bolt.svg +3 -0
- package/src/Icons/Bookmark.svg +3 -0
- package/src/Icons/Broadcast.svg +3 -0
- package/src/Icons/Broom.svg +5 -0
- package/src/Icons/Bug.svg +3 -0
- package/src/Icons/Bullet.svg +3 -0
- package/src/Icons/Bullets.svg +15 -0
- package/src/Icons/Bulllet.svg +3 -0
- package/src/Icons/Calendar.svg +3 -0
- package/src/Icons/Chart.svg +3 -0
- package/src/Icons/Check.svg +4 -0
- package/src/Icons/CheckList.svg +7 -0
- package/src/Icons/Checkbox.svg +6 -0
- package/src/Icons/Clear.svg +3 -0
- package/src/Icons/Close.svg +3 -0
- package/src/Icons/CloseRound.svg +3 -0
- package/src/Icons/CloseSmall.svg +4 -0
- package/src/Icons/Code.svg +4 -0
- package/src/Icons/Collapse.svg +5 -0
- package/src/Icons/CollapseRound.svg +5 -0
- package/src/Icons/Column.svg +3 -0
- package/src/Icons/Comment.svg +3 -0
- package/src/Icons/Completed.svg +3 -0
- package/src/Icons/Connect.svg +4 -0
- package/src/Icons/ConnectedDoc.svg +11 -0
- package/src/Icons/ContentDirectory.svg +3 -0
- package/src/Icons/ConvertToItem.svg +3 -0
- package/src/Icons/ConvertToSubitem.svg +3 -0
- package/src/Icons/Counter.svg +12 -0
- package/src/Icons/Country.svg +3 -0
- package/src/Icons/CreditCard.svg +3 -0
- package/src/Icons/Custom.svg +5 -0
- package/src/Icons/Cut.svg +6 -0
- package/src/Icons/Dashboard.svg +3 -0
- package/src/Icons/DashboardPrivate.svg +5 -0
- package/src/Icons/Deactivate.svg +3 -0
- package/src/Icons/Delete.svg +3 -0
- package/src/Icons/Dependency.svg +3 -0
- package/src/Icons/Description.svg +6 -0
- package/src/Icons/DisabledUser.svg +11 -0
- package/src/Icons/Divider.svg +3 -0
- package/src/Icons/Doc.svg +5 -0
- package/src/Icons/DocPrivate.svg +6 -0
- package/src/Icons/DocShareable.svg +3 -0
- package/src/Icons/DocTemplate.svg +3 -0
- package/src/Icons/DoubleCheck.svg +3 -0
- package/src/Icons/Download.svg +3 -0
- package/src/Icons/Drag.svg +11 -0
- package/src/Icons/Dropdown.svg +3 -0
- package/src/Icons/DropdownChevronDown.svg +4 -0
- package/src/Icons/DropdownChevronLeft.svg +4 -0
- package/src/Icons/DropdownChevronRight.svg +4 -0
- package/src/Icons/DropdownChevronUp.svg +4 -0
- package/src/Icons/DueDate.svg +3 -0
- package/src/Icons/Duplicate.svg +3 -0
- package/src/Icons/Edit.svg +3 -0
- package/src/Icons/Education.svg +3 -0
- package/src/Icons/Email.svg +3 -0
- package/src/Icons/Embed.svg +3 -0
- package/src/Icons/Emoji.svg +6 -0
- package/src/Icons/Enter.svg +3 -0
- package/src/Icons/Erase.svg +3 -0
- package/src/Icons/Event.svg +4 -0
- package/src/Icons/Expand.svg +3 -0
- package/src/Icons/ExternalPage.svg +3 -0
- package/src/Icons/Favorite.svg +3 -0
- package/src/Icons/Featured.svg +3 -0
- package/src/Icons/Feedback.svg +3 -0
- package/src/Icons/File.svg +4 -0
- package/src/Icons/Filter.svg +5 -0
- package/src/Icons/Folder.svg +5 -0
- package/src/Icons/Form.svg +6 -0
- package/src/Icons/Formula.svg +4 -0
- package/src/Icons/Forum.svg +3 -0
- package/src/Icons/Fullscreen.svg +3 -0
- package/src/Icons/FullscreenClose.svg +3 -0
- package/src/Icons/Gallery.svg +6 -0
- package/src/Icons/Gantt.svg +5 -0
- package/src/Icons/Gif.svg +5 -0
- package/src/Icons/Globe.svg +5 -0
- package/src/Icons/Graph.svg +3 -0
- package/src/Icons/Group.svg +3 -0
- package/src/Icons/Guest.svg +3 -0
- package/src/Icons/Health.svg +3 -0
- package/src/Icons/Help.svg +5 -0
- package/src/Icons/Hide.svg +3 -0
- package/src/Icons/Highlight.svg +4 -0
- package/src/Icons/HighlightColorBucket.svg +3 -0
- package/src/Icons/Home.svg +3 -0
- package/src/Icons/IPRestrictions.svg +3 -0
- package/src/Icons/Idea.svg +3 -0
- package/src/Icons/Image.svg +5 -0
- package/src/Icons/Inbox.svg +4 -0
- package/src/Icons/Info.svg +3 -0
- package/src/Icons/Integrations.svg +3 -0
- package/src/Icons/Invite.svg +11 -0
- package/src/Icons/Italic.svg +9 -0
- package/src/Icons/Item.svg +3 -0
- package/src/Icons/ItemDefaultValues.svg +3 -0
- package/src/Icons/ItemHeightTriple.svg +8 -0
- package/src/Icons/Keyboard.svg +3 -0
- package/src/Icons/Labs.svg +3 -0
- package/src/Icons/Launch.svg +10 -0
- package/src/Icons/Layout.svg +3 -0
- package/src/Icons/LearnMore.svg +5 -0
- package/src/Icons/Lines.svg +5 -0
- package/src/Icons/Link.svg +3 -0
- package/src/Icons/Location.svg +3 -0
- package/src/Icons/Locked.svg +3 -0
- package/src/Icons/LogIn.svg +8 -0
- package/src/Icons/LogOut.svg +8 -0
- package/src/Icons/LongText.svg +3 -0
- package/src/Icons/Mention.svg +4 -0
- package/src/Icons/Menu.svg +6 -0
- package/src/Icons/Microphone.svg +3 -0
- package/src/Icons/Minimize.svg +4 -0
- package/src/Icons/Mirror.svg +3 -0
- package/src/Icons/Mobile.svg +3 -0
- package/src/Icons/MondayDoc.svg +3 -0
- package/src/Icons/MondayLogoOutline.svg +3 -0
- package/src/Icons/Moon.svg +3 -0
- package/src/Icons/MoreActions.svg +3 -0
- package/src/Icons/MoreBelow.svg +5 -0
- package/src/Icons/MoreBelowFilled.svg +3 -0
- package/src/Icons/MoveArrowDown.svg +4 -0
- package/src/Icons/MoveArrowLeft.svg +4 -0
- package/src/Icons/MoveArrowLeftDouble.svg +10 -0
- package/src/Icons/MoveArrowRight.svg +4 -0
- package/src/Icons/MoveArrowUp.svg +4 -0
- package/src/Icons/Mute.svg +4 -0
- package/src/Icons/MyWeek.svg +5 -0
- package/src/Icons/NavigationChevronDown.svg +4 -0
- package/src/Icons/NavigationChevronLeft.svg +4 -0
- package/src/Icons/NavigationChevronRight.svg +4 -0
- package/src/Icons/NavigationChevronUp.svg +4 -0
- package/src/Icons/NavigationDoubleChevronLeft.svg +4 -0
- package/src/Icons/NewTab.svg +3 -0
- package/src/Icons/Night.svg +5 -0
- package/src/Icons/NoColor.svg +5 -0
- package/src/Icons/Note.svg +3 -0
- package/src/Icons/Notifications.svg +4 -0
- package/src/Icons/NotificationsMuted.svg +4 -0
- package/src/Icons/Numbers.svg +8 -0
- package/src/Icons/Offline.svg +4 -0
- package/src/Icons/Open.svg +4 -0
- package/src/Icons/Page.svg +3 -0
- package/src/Icons/Paste.svg +7 -0
- package/src/Icons/Pause.svg +3 -0
- package/src/Icons/Person.svg +4 -0
- package/src/Icons/PersonRound.svg +4 -0
- package/src/Icons/Pin.svg +3 -0
- package/src/Icons/Placeholder.svg +3 -0
- package/src/Icons/Play.svg +3 -0
- package/src/Icons/Print.svg +3 -0
- package/src/Icons/PushNotification.svg +3 -0
- package/src/Icons/Quote.svg +6 -0
- package/src/Icons/Radio.svg +3 -0
- package/src/Icons/Recurring.svg +3 -0
- package/src/Icons/RecycleBin.svg +11 -0
- package/src/Icons/Redo.svg +4 -0
- package/src/Icons/Remove.svg +3 -0
- package/src/Icons/Replay.svg +3 -0
- package/src/Icons/Retry.svg +3 -0
- package/src/Icons/Robot.svg +3 -0
- package/src/Icons/Rotate.svg +3 -0
- package/src/Icons/Search.svg +3 -0
- package/src/Icons/Security.svg +3 -0
- package/src/Icons/Send.svg +3 -0
- package/src/Icons/Settings.svg +3 -0
- package/src/Icons/SettingsKnobs.svg +3 -0
- package/src/Icons/Share.svg +3 -0
- package/src/Icons/ShortText.svg +3 -0
- package/src/Icons/Show.svg +3 -0
- package/src/Icons/Shredder.svg +3 -0
- package/src/Icons/Sort.svg +4 -0
- package/src/Icons/SortAscending.svg +3 -0
- package/src/Icons/SortDescending.svg +3 -0
- package/src/Icons/Sound.svg +4 -0
- package/src/Icons/Status.svg +10 -0
- package/src/Icons/StrikethroughS.svg +12 -0
- package/src/Icons/StrikethroughT.svg +11 -0
- package/src/Icons/Subitems.svg +3 -0
- package/src/Icons/Sun.svg +3 -0
- package/src/Icons/Switch.svg +3 -0
- package/src/Icons/Switcher.svg +18 -0
- package/src/Icons/Table.svg +3 -0
- package/src/Icons/Tags.svg +3 -0
- package/src/Icons/Team.svg +3 -0
- package/src/Icons/Text.svg +3 -0
- package/src/Icons/TextBig.svg +3 -0
- package/src/Icons/TextColorIndicator.svg +26 -0
- package/src/Icons/TextCopy.svg +3 -0
- package/src/Icons/TextHuge.svg +3 -0
- package/src/Icons/TextMedium.svg +3 -0
- package/src/Icons/TextSmall.svg +3 -0
- package/src/Icons/Textcolor.svg +5 -0
- package/src/Icons/ThumbsUp.svg +3 -0
- package/src/Icons/Time.svg +3 -0
- package/src/Icons/Timeline.svg +5 -0
- package/src/Icons/Translation.svg +3 -0
- package/src/Icons/TurnInto.svg +6 -0
- package/src/Icons/Underline.svg +8 -0
- package/src/Icons/Undo.svg +4 -0
- package/src/Icons/Unlocked.svg +3 -0
- package/src/Icons/Update.svg +3 -0
- package/src/Icons/Upgrade.svg +3 -0
- package/src/Icons/Upload.svg +3 -0
- package/src/Icons/UserDomain.svg +4 -0
- package/src/Icons/UserStatus.svg +4 -0
- package/src/Icons/Versioning.svg +3 -0
- package/src/Icons/Video.svg +6 -0
- package/src/Icons/Wand.svg +3 -0
- package/src/Icons/Warning.svg +5 -0
- package/src/Icons/WhatsNew.svg +3 -0
- package/src/Icons/Widgets.svg +3 -0
- package/src/Icons/Work.svg +3 -0
- package/src/Icons/Workflow.svg +7 -0
- package/src/Icons/Workspace.svg +3 -0
- package/src/Icons/iconsMetaData.js +1801 -0
- package/src/Themes/_basic-theme.scss +26 -0
- package/src/Themes/_black-theme.scss +23 -0
- package/src/Themes/_dark-theme.scss +23 -0
- package/src/Themes/_hacker-theme.scss +23 -0
- package/src/Themes/basic/_basic-theme-legacy-settings.scss +4 -0
- package/src/Themes/basic/_basic-theme-settings.scss +4 -0
- package/src/Themes/basic/_content-colors.scss +239 -0
- package/src/Themes/black/_black-theme-content-colors.scss +240 -0
- package/src/Themes/black/_black-theme-legacy-settings.scss +4 -0
- package/src/Themes/black/_black-theme-settings.scss +4 -0
- package/src/Themes/dark/_dark-theme-content-colors.scss +240 -0
- package/src/Themes/dark/_dark-theme-legacy-settings.scss +4 -0
- package/src/Themes/dark/_dark-theme-settings.scss +4 -0
- package/src/Themes/hacker/_hacker-theme-content-colors.scss +240 -0
- package/src/Themes/hacker/_hacker-theme-legacy-settings.scss +4 -0
- package/src/Themes/hacker/_hacker-theme-settings.scss +4 -0
- package/src/_common.scss +9 -0
- package/src/_config.scss +17 -0
- package/src/_core.scss +12 -0
- package/src/_functions.scss +8 -0
- package/src/_internal-mixins.scss +5 -0
- package/src/_mixins.scss +3 -0
- package/src/_themes.scss +5 -0
- package/src/config/maps/_config-basic-theme-maps.scss +7 -0
- package/src/config/maps/_config-black-theme-maps.scss +4 -0
- package/src/config/maps/_config-core-maps.scss +12 -0
- package/src/config/maps/_config-dark-theme-maps.scss +4 -0
- package/src/config/maps/_config-hacker-theme-maps.scss +5 -0
- package/src/config/maps/core/_core-borders.scss +9 -0
- package/src/config/maps/core/_core-common-map.scss +9 -0
- package/src/config/maps/core/_core-fonts-map-deprecated.scss +37 -0
- package/src/config/maps/core/_core-motion-map.scss +17 -0
- package/src/config/maps/core/_core-radius-map.scss +10 -0
- package/src/config/maps/core/_core-shadows-map.scss +19 -0
- package/src/config/maps/core/_core-spacing-map.scss +14 -0
- package/src/config/maps/core/_core-typography-map-deprecated.scss +40 -0
- package/src/config/maps/core/_core-typography-map.scss +52 -0
- package/src/config/maps/themes/basic/keys/_keys.scss +71 -0
- package/src/config/maps/themes/basic/keys/legacy/_legacy-keys.scss +34 -0
- package/src/config/maps/themes/basic/palette/_palette.scss +157 -0
- package/src/config/maps/themes/basic/palette/legacy/_legacy-pallete.scss +82 -0
- package/src/config/maps/themes/black/keys/_black-theme-keys.scss +70 -0
- package/src/config/maps/themes/black/keys/legacy/_black-theme-legacy-keys.scss +33 -0
- package/src/config/maps/themes/dark/keys/_dark-theme-keys.scss +72 -0
- package/src/config/maps/themes/dark/keys/legacy/_dark-theme-legacy-keys.scss +33 -0
- package/src/config/maps/themes/hacker/keys/_hacker-theme-keys.scss +69 -0
- package/src/config/maps/themes/hacker/keys/legacy/_hacker-theme-legacy-keys.scss +33 -0
- package/src/config/maps/themes/hacker/palette/legacy/_hacker-theme-legacy-palette.scss +7 -0
- package/src/config/tokens/_config-basic-theme-tokens.scss +7 -0
- package/src/config/tokens/_config-black-theme-tokens.scss +6 -0
- package/src/config/tokens/_config-core-tokens.scss +16 -0
- package/src/config/tokens/_config-dark-theme-tokens.scss +6 -0
- package/src/config/tokens/_config-hacker-theme-tokens.scss +7 -0
- package/src/config/tokens/core/_core-border.scss +5 -0
- package/src/config/tokens/core/_core-common.scss +7 -0
- package/src/config/tokens/core/_core-fonts-deprecated.scss +37 -0
- package/src/config/tokens/core/_core-motion.scss +35 -0
- package/src/config/tokens/core/_core-opacity.scss +14 -0
- package/src/config/tokens/core/_core-radius.scss +6 -0
- package/src/config/tokens/core/_core-shadows.scss +7 -0
- package/src/config/tokens/core/_core-spacing.scss +10 -0
- package/src/config/tokens/core/_core-typography-deprecated.scss +55 -0
- package/src/config/tokens/core/_core-typography.scss +55 -0
- package/src/config/tokens/themes/basic/keys/_keys.scss +87 -0
- package/src/config/tokens/themes/basic/keys/legacy/_legacy-keys.scss +51 -0
- package/src/config/tokens/themes/basic/palette/_palette.scss +210 -0
- package/src/config/tokens/themes/basic/palette/legacy/_legacy-pallete.scss +102 -0
- package/src/config/tokens/themes/black/keys/_black-theme-keys.scss +79 -0
- package/src/config/tokens/themes/black/keys/legacy/_black-theme-legacy-keys.scss +50 -0
- package/src/config/tokens/themes/black/palette/_black-theme-palette.scss +19 -0
- package/src/config/tokens/themes/dark/keys/_dark-theme-keys.scss +82 -0
- package/src/config/tokens/themes/dark/keys/legacy/_dark-theme-legacy-keys.scss +49 -0
- package/src/config/tokens/themes/dark/palette/_dark-theme-palette.scss +47 -0
- package/src/config/tokens/themes/hacker/keys/_hacker-theme-keys.scss +78 -0
- package/src/config/tokens/themes/hacker/keys/legacy/hacker-theme-legacy-keys.scss +53 -0
- package/src/config/tokens/themes/hacker/palette/_hacker-theme-palette.scss +25 -0
- package/src/config/tokens/themes/hacker/palette/legacy/_hacker-theme-legacy-palette.scss +9 -0
- package/src/core/_core-settings.scss +20 -0
- package/src/files/colors.json +696 -0
- package/src/functions/_camelize.scss +25 -0
- package/src/functions/_capitalize.scss +11 -0
- package/src/functions/_contain.scss +8 -0
- package/src/functions/_extract-rgb.scss +8 -0
- package/src/functions/_map-collect.scss +17 -0
- package/src/index.scss +18 -0
- package/src/internal-mixins/_generate-custom-properties.scss +12 -0
- package/src/internal-mixins/_utilities.scss +76 -0
- package/src/loaders/monday.svg +0 -0
- package/src/mixins/_common.scss +67 -0
- package/src/mixins/_states.scss +48 -0
- package/src/mixins/_typography.scss +24 -0
- package/src/utilities/_utilities-maps.scss +33 -0
- package/stylelint-config/index.js +7 -0
- package/stylelint-config/rules/use-defined-css-var-when-available/__tests__/fixtures/contains-values-with-multiple-replacements.scss +4 -0
- package/stylelint-config/rules/use-defined-css-var-when-available/__tests__/fixtures/contains-values-with-single-replacement.scss +8 -0
- package/stylelint-config/rules/use-defined-css-var-when-available/__tests__/index.test.js +170 -0
- package/stylelint-config/rules/use-defined-css-var-when-available/__tests__/props-to-allowed-vars.test.js +122 -0
- package/stylelint-config/rules/use-defined-css-var-when-available/index.js +105 -0
- package/stylelint-config/rules/use-defined-css-var-when-available/parse-monday-css.js +115 -0
- package/stylelint-config/rules/use-defined-css-var-when-available/props-to-allowed-vars.js +161 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const stylelint = require("stylelint");
|
|
2
|
+
const valueParser = require("postcss-value-parser");
|
|
3
|
+
const { getPropsToAllowedCssVars } = require("./parse-monday-css");
|
|
4
|
+
|
|
5
|
+
const { report, ruleMessages, validateOptions } = stylelint.utils;
|
|
6
|
+
|
|
7
|
+
const RULE_NAME = "@heliux-org/ui-style/use-defined-css-var-when-available";
|
|
8
|
+
const CONFIGS_THAT_MEAN_IGNORE_FILE = ["disabled", "disable", "off", "0"];
|
|
9
|
+
|
|
10
|
+
const messages = ruleMessages(RULE_NAME, {
|
|
11
|
+
expected: (original, expected) => {
|
|
12
|
+
const asArray = Array.isArray(expected) ? expected : [expected];
|
|
13
|
+
const multipleValues = asArray.length > 1;
|
|
14
|
+
const expectedMsg = multipleValues ? `one of vars: \n${asArray.join("\n")}\n` : `"var(${asArray[0]})"`;
|
|
15
|
+
return `Expected "${original}" to be ${expectedMsg}`;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
module.exports = stylelint.createPlugin(RULE_NAME, (primaryOption, secondaryOptionObject, context) => {
|
|
20
|
+
const propsToAllowedCssVars = getPropsToAllowedCssVars();
|
|
21
|
+
|
|
22
|
+
return function lint(postcssRoot, postcssResult) {
|
|
23
|
+
const validOptions = validateOptions(
|
|
24
|
+
postcssResult,
|
|
25
|
+
RULE_NAME,
|
|
26
|
+
{
|
|
27
|
+
actual: primaryOption,
|
|
28
|
+
possible: [...CONFIGS_THAT_MEAN_IGNORE_FILE, true, "true"],
|
|
29
|
+
optional: true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
actual: secondaryOptionObject && secondaryOptionObject.useRecommendedFixes,
|
|
33
|
+
possible: [true, "true", false, "false"],
|
|
34
|
+
optional: true
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
primaryOption = primaryOption || true;
|
|
39
|
+
const shouldNotLint =
|
|
40
|
+
!validOptions || CONFIGS_THAT_MEAN_IGNORE_FILE.includes(primaryOption.toString().toLowerCase());
|
|
41
|
+
if (shouldNotLint) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const isAutoFixing = Boolean(context.fix);
|
|
46
|
+
postcssRoot.walkDecls(decl => {
|
|
47
|
+
// Iterate CSS declarations
|
|
48
|
+
|
|
49
|
+
const valuesToVars = propsToAllowedCssVars[decl.prop];
|
|
50
|
+
if (!valuesToVars) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const parsedValue = valueParser(decl.value);
|
|
55
|
+
parsedValue.walk(node => {
|
|
56
|
+
// iterate nodes inside values, e.g. "padding: 16px 20px" will have two value nodes: "16px" and "20px"
|
|
57
|
+
if (node.type !== "word") {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const { allowedVars: varReplacementsForValue, recommended } = valuesToVars[node.value] || {};
|
|
62
|
+
|
|
63
|
+
if (!varReplacementsForValue || !varReplacementsForValue.length) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const hasSingleReplacement = varReplacementsForValue.length === 1;
|
|
67
|
+
|
|
68
|
+
const useRecommendedFixes = secondaryOptionObject && secondaryOptionObject.useRecommendedFixes;
|
|
69
|
+
|
|
70
|
+
if (isAutoFixing) {
|
|
71
|
+
// We are in “fix” mode
|
|
72
|
+
let replacementVar;
|
|
73
|
+
if (hasSingleReplacement) {
|
|
74
|
+
replacementVar = varReplacementsForValue[0];
|
|
75
|
+
} else if (useRecommendedFixes) {
|
|
76
|
+
replacementVar = recommended;
|
|
77
|
+
} else {
|
|
78
|
+
// we have multiple options, but the user chose not to follow recommendations
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const replacement = `var(${replacementVar})`;
|
|
82
|
+
const newValue = decl.value.replace(node.value, replacement);
|
|
83
|
+
// Apply the fix. It's not pretty, but that's the way to do it
|
|
84
|
+
if (decl.raws.value) {
|
|
85
|
+
decl.raws.value.raw = newValue;
|
|
86
|
+
} else {
|
|
87
|
+
decl.value = newValue;
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
// We are in “report only” mode
|
|
91
|
+
report({
|
|
92
|
+
ruleName: RULE_NAME,
|
|
93
|
+
result: postcssResult,
|
|
94
|
+
message: messages.expected(node.value, varReplacementsForValue), // Build the reported message
|
|
95
|
+
node: decl, // Specify the reported node
|
|
96
|
+
word: node.value // Which exact word caused the error? This positions the error properly
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
module.exports.ruleName = RULE_NAME;
|
|
105
|
+
module.exports.messages = messages;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const postcss = require("postcss");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { PROPS_TO_ALLOWED_VARS } = require("./props-to-allowed-vars");
|
|
5
|
+
|
|
6
|
+
function getReferencedPropFromVar(value) {
|
|
7
|
+
// var(--my-var) => --my-var
|
|
8
|
+
const VAR_REGEX = /var\(\s*(--[\w-]+)\s*\)/g;
|
|
9
|
+
return VAR_REGEX.exec(value)[1];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function readCssFromDefaultPath() {
|
|
13
|
+
const stylesCssPath = path.resolve(__dirname, "../../../dist/index.min.css");
|
|
14
|
+
return fs.readFileSync(stylesCssPath).toString();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function parseMondayUiCss(css = readCssFromDefaultPath()) {
|
|
18
|
+
const ast = postcss.parse(css);
|
|
19
|
+
|
|
20
|
+
const varsToCanonicalValue = {}; // css vars that are mapped to canonical values. e.g. {"--color-primary": "#131313"}
|
|
21
|
+
const canonicalValuesToVars = {}; // matching css vars for each canonical value. e.g. {"16px": ["--font-size-h3", "--spacing-medium"]}
|
|
22
|
+
const referenceTokens = {}; // css vars that are pointing to other css vars. e.g. {"--color-primary": "--color-red"}
|
|
23
|
+
const referenceTokensToCanonicalValue = {}; // maps between reference token names to canonical values. e.g. if "--font-size-h5: var(--font-size-30)" and "--font-size-30: 16px", then {"--font-size-h5": "16px"}
|
|
24
|
+
|
|
25
|
+
ast.walkDecls(/^--/, decl => {
|
|
26
|
+
if (!decl.parent || decl.parent.selector !== ":root") {
|
|
27
|
+
return; // we only care about truly global variables
|
|
28
|
+
}
|
|
29
|
+
const { prop, value } = decl;
|
|
30
|
+
const isValueCssProp = value.includes("var(--");
|
|
31
|
+
if (!isValueCssProp) {
|
|
32
|
+
// this is a declaration of a new css var
|
|
33
|
+
varsToCanonicalValue[prop] = value;
|
|
34
|
+
canonicalValuesToVars[value] = canonicalValuesToVars[value] || [];
|
|
35
|
+
if (!canonicalValuesToVars[value].includes(prop)) {
|
|
36
|
+
canonicalValuesToVars[value].push(prop);
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
referenceTokens[prop] = value;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
Object.keys(referenceTokens).forEach(referenceToken => {
|
|
44
|
+
const tokenValue = referenceTokens[referenceToken];
|
|
45
|
+
let referencedVar = getReferencedPropFromVar(tokenValue);
|
|
46
|
+
while (referenceTokens[referencedVar]) {
|
|
47
|
+
referencedVar = referenceTokens[referencedVar];
|
|
48
|
+
}
|
|
49
|
+
const referencedCanonicalValue = varsToCanonicalValue[referencedVar];
|
|
50
|
+
if (referencedCanonicalValue) {
|
|
51
|
+
referenceTokensToCanonicalValue[referenceToken] = referencedCanonicalValue;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const allVarsToCanonicalValue = {}; //maps between all vars (reference or not) to the canonical value
|
|
56
|
+
|
|
57
|
+
Object.keys(varsToCanonicalValue).forEach(varName => {
|
|
58
|
+
allVarsToCanonicalValue[varName] = varsToCanonicalValue[varName];
|
|
59
|
+
});
|
|
60
|
+
Object.keys(referenceTokensToCanonicalValue).forEach(varName => {
|
|
61
|
+
allVarsToCanonicalValue[varName] = referenceTokensToCanonicalValue[varName];
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return { allVarsToCanonicalValue };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @returns {{[cssProp: string]: {[value: string]: {allowedVars: string[], recommended: string | undefined}}}}: a map between a css prop to expected CSS vars replacements per values, and a recommendation if exists.
|
|
69
|
+
* For example:
|
|
70
|
+
{
|
|
71
|
+
padding: {
|
|
72
|
+
{
|
|
73
|
+
"8px": { allowedVars: [ "--spacing-small" ] },
|
|
74
|
+
"16px": { allowedVars: [ "--spacing-medium" ] },
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"font-size":{
|
|
78
|
+
"14px": {
|
|
79
|
+
allowedVars: [ "--font-size-general-label", "--font-size-subtext" ],
|
|
80
|
+
recommended: "--font-size-general-label"
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
*/
|
|
85
|
+
function getPropsToAllowedCssVars() {
|
|
86
|
+
const { allVarsToCanonicalValue } = parseMondayUiCss();
|
|
87
|
+
const propsToReplacementConfig = {};
|
|
88
|
+
Object.keys(PROPS_TO_ALLOWED_VARS).forEach(prop => {
|
|
89
|
+
const { allowedVars, recommended } = PROPS_TO_ALLOWED_VARS[prop];
|
|
90
|
+
if (!allowedVars) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
propsToReplacementConfig[prop] = {};
|
|
94
|
+
allowedVars.forEach(varName => {
|
|
95
|
+
const varCanonicalValue = allVarsToCanonicalValue[varName];
|
|
96
|
+
if (!varCanonicalValue) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
propsToReplacementConfig[prop][varCanonicalValue] = propsToReplacementConfig[prop][varCanonicalValue] || {
|
|
100
|
+
allowedVars: []
|
|
101
|
+
};
|
|
102
|
+
propsToReplacementConfig[prop][varCanonicalValue].allowedVars.push(varName);
|
|
103
|
+
if (recommended && recommended.includes(varName)) {
|
|
104
|
+
propsToReplacementConfig[prop][varCanonicalValue].recommended = varName;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return propsToReplacementConfig;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
module.exports = {
|
|
113
|
+
parseMondayUiCss,
|
|
114
|
+
getPropsToAllowedCssVars
|
|
115
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const SPACINGS = [
|
|
2
|
+
"--spacing-xs",
|
|
3
|
+
"--spacing-small",
|
|
4
|
+
"--spacing-medium",
|
|
5
|
+
"--spacing-large",
|
|
6
|
+
"--spacing-xl",
|
|
7
|
+
"--spacing-xxl",
|
|
8
|
+
"--spacing-xxxl"
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const BORDER_RADIUSES = ["--border-radius-small", "--border-radius-medium", "--border-radius-big"];
|
|
12
|
+
|
|
13
|
+
const BORDER_WIDTHS = ["--border-width"];
|
|
14
|
+
|
|
15
|
+
const BORDER_STYLES = ["--border-style"];
|
|
16
|
+
|
|
17
|
+
const FONT_SIZES = [
|
|
18
|
+
// since "--font-size-10" and "--font-size-20" have the same value, we need to pick only one of them as "valid value", to allow autofix
|
|
19
|
+
// "--font-size-10",
|
|
20
|
+
"--font-size-20",
|
|
21
|
+
"--font-size-30",
|
|
22
|
+
"--font-size-40",
|
|
23
|
+
"--font-size-50",
|
|
24
|
+
"--font-size-60",
|
|
25
|
+
"--font-size-h1",
|
|
26
|
+
"--font-size-h2",
|
|
27
|
+
"--font-size-h3",
|
|
28
|
+
"--font-size-h4",
|
|
29
|
+
"--font-size-h5",
|
|
30
|
+
"--font-size-h6",
|
|
31
|
+
"--font-size-general-label",
|
|
32
|
+
"--font-size-paragraph",
|
|
33
|
+
"--font-size-subtext"
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const FONT_FAMILIES = ["--font-family", "--title-font-family", "--h1-font-family"];
|
|
37
|
+
|
|
38
|
+
const FONT_WEIGHTS = ["--font-weight-very-light", "--font-weight-light", "--font-weight-normal", "--font-weight-bold"];
|
|
39
|
+
|
|
40
|
+
const FONT_LINE_HEIGHTS = [
|
|
41
|
+
"--font-line-height-10",
|
|
42
|
+
// since "--font-line-height-20", "--font-line-height-30" and "--font-line-height-40" have the same value, we need to pick only one of them as "valid value", to allow autofix
|
|
43
|
+
// "--font-line-height-20",
|
|
44
|
+
// "--font-line-height-30",
|
|
45
|
+
"--font-line-height-40",
|
|
46
|
+
"--font-line-height-50",
|
|
47
|
+
"--font-line-height-60",
|
|
48
|
+
"--font-line-height-h1",
|
|
49
|
+
"--font-line-height-h2",
|
|
50
|
+
"--font-line-height-h3",
|
|
51
|
+
"--font-line-height-h4",
|
|
52
|
+
"--font-line-height-h5",
|
|
53
|
+
"--font-line-height-h6",
|
|
54
|
+
"--font-line-height-general-label",
|
|
55
|
+
"--font-line-height-paragraph",
|
|
56
|
+
"--font-line-height-subtext"
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
const ANIMATION_TIMING = [
|
|
60
|
+
"--motion-timing-enter",
|
|
61
|
+
"--motion-timing-exit",
|
|
62
|
+
"--motion-timing-transition",
|
|
63
|
+
"--motion-timing-emphasize",
|
|
64
|
+
"--expand-animation-timing"
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const ANIMATION_DURATION = [
|
|
68
|
+
"--motion-productive-short",
|
|
69
|
+
"--motion-productive-medium",
|
|
70
|
+
"--motion-productive-long",
|
|
71
|
+
"--motion-expressive-short",
|
|
72
|
+
"--motion-expressive-long"
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const SPACING_PROPS = [
|
|
76
|
+
"padding",
|
|
77
|
+
"padding-top",
|
|
78
|
+
"padding-bottom",
|
|
79
|
+
"padding-left",
|
|
80
|
+
"padding-right",
|
|
81
|
+
"padding-inline",
|
|
82
|
+
"padding-inline-end",
|
|
83
|
+
"padding-inline-start",
|
|
84
|
+
"padding-block",
|
|
85
|
+
"padding-block-end",
|
|
86
|
+
"padding-block-start",
|
|
87
|
+
|
|
88
|
+
"margin",
|
|
89
|
+
"margin-top",
|
|
90
|
+
"margin-bottom",
|
|
91
|
+
"margin-left",
|
|
92
|
+
"margin-right",
|
|
93
|
+
"margin-inline",
|
|
94
|
+
"margin-inline-end",
|
|
95
|
+
"margin-inline-start",
|
|
96
|
+
"margin-block",
|
|
97
|
+
"margin-block-end",
|
|
98
|
+
"margin-block-start",
|
|
99
|
+
|
|
100
|
+
"inset",
|
|
101
|
+
"inset-end",
|
|
102
|
+
"inset-start"
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
const BORDER_RADIUSES_PROPS = [
|
|
106
|
+
"border-radius",
|
|
107
|
+
"border-top-left-radius",
|
|
108
|
+
"border-top-right-radius",
|
|
109
|
+
"border-bottom-left-radius",
|
|
110
|
+
"border-bottom-right-radius",
|
|
111
|
+
"border-start-start-radius",
|
|
112
|
+
"border-start-end-radius",
|
|
113
|
+
"border-end-start-radius",
|
|
114
|
+
"border-end-end-radius"
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
const FONT_FAMILIES_PROPS = ["font", "font-family"];
|
|
118
|
+
|
|
119
|
+
const BORDER_WIDTHS_PROPS = ["border", "border-width"];
|
|
120
|
+
|
|
121
|
+
const BORDER_STYLES_PROPS = ["border", "border-style"];
|
|
122
|
+
|
|
123
|
+
const TIMING_FUNCTION_PROPS = ["transition", "transition-timing", "animation", "animation-timing-function"];
|
|
124
|
+
|
|
125
|
+
const DURATION_FUNCTION_PROPS = ["transition", "transition-duration", "animation", "animation-duration"];
|
|
126
|
+
|
|
127
|
+
const OPACITY_PROPS = ["opacity"];
|
|
128
|
+
|
|
129
|
+
function mapPropsToAllowedVars(propNames, allowedVars, recommended = undefined) {
|
|
130
|
+
allowedVars = Array.isArray(allowedVars) ? allowedVars : [allowedVars];
|
|
131
|
+
propNames = Array.isArray(propNames) ? propNames : [propNames];
|
|
132
|
+
|
|
133
|
+
return propNames.reduce(
|
|
134
|
+
(result, propName) => ({
|
|
135
|
+
...result,
|
|
136
|
+
[propName]: { allowedVars, recommended }
|
|
137
|
+
}),
|
|
138
|
+
{}
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// List the CSS props we want to lint, and map each one to the values we would prefer to use.
|
|
143
|
+
// For example, let's say that the key "border-radius" is mapped to --border-radius-small and --border-radius-medium.
|
|
144
|
+
// This means that if --border-radius-small or --border-radius-medium can be used while linting a rule with the property "border-radius", we will show an error
|
|
145
|
+
|
|
146
|
+
const PROPS_TO_ALLOWED_VARS = {
|
|
147
|
+
...mapPropsToAllowedVars(SPACING_PROPS, SPACINGS),
|
|
148
|
+
...mapPropsToAllowedVars(BORDER_RADIUSES_PROPS, BORDER_RADIUSES),
|
|
149
|
+
...mapPropsToAllowedVars(BORDER_WIDTHS_PROPS, BORDER_WIDTHS),
|
|
150
|
+
...mapPropsToAllowedVars(BORDER_STYLES_PROPS, BORDER_STYLES),
|
|
151
|
+
...mapPropsToAllowedVars(FONT_FAMILIES_PROPS, FONT_FAMILIES, ["--title-font-family"]),
|
|
152
|
+
...mapPropsToAllowedVars(TIMING_FUNCTION_PROPS, ANIMATION_TIMING, ["--expand-animation-timing"]),
|
|
153
|
+
...mapPropsToAllowedVars(DURATION_FUNCTION_PROPS, ANIMATION_DURATION, ["--animation-expressive-short"]),
|
|
154
|
+
...mapPropsToAllowedVars(OPACITY_PROPS, "--disabled-component-opacity"),
|
|
155
|
+
"-webkit-font-smoothing": { allowedVars: ["--font-smoothing-webkit"] },
|
|
156
|
+
"-moz-osx-font-smoothing": { allowedVars: ["--font-smoothing-moz"] }
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
module.exports = {
|
|
160
|
+
PROPS_TO_ALLOWED_VARS
|
|
161
|
+
};
|