@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,25 @@
|
|
|
1
|
+
// FUNCTIONS: Camelize string
|
|
2
|
+
|
|
3
|
+
// Modules imports
|
|
4
|
+
@use "sass:string";
|
|
5
|
+
|
|
6
|
+
// @arguments [string] $string
|
|
7
|
+
// @return camelcase string
|
|
8
|
+
@function camelize($string) {
|
|
9
|
+
$progress: $string;
|
|
10
|
+
$result: "";
|
|
11
|
+
$exclude: " ", "-", "–", "—", "_", ",", ";", ":", ".";
|
|
12
|
+
|
|
13
|
+
@while str-length($progress) > 0 {
|
|
14
|
+
$char: string.slice($progress, 1, 1);
|
|
15
|
+
|
|
16
|
+
@if contain($exclude, $char) {
|
|
17
|
+
$progress: capitalize(string.slice($progress, 2, 2)) + string.slice($progress, 3);
|
|
18
|
+
} @else {
|
|
19
|
+
$result: $result + $char;
|
|
20
|
+
$progress: string.slice($progress, 2);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@return $result;
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// MIXINS: Capitalize
|
|
2
|
+
// - Helper function
|
|
3
|
+
|
|
4
|
+
// Modules imports
|
|
5
|
+
@use "sass:string";
|
|
6
|
+
|
|
7
|
+
// @arguments: $string
|
|
8
|
+
// @return capitalize string
|
|
9
|
+
@function capitalize($string) {
|
|
10
|
+
@return to-upper-case(string.slice($string, 1, 1)) + string.slice($string, 2);
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// MIXINS: Extract Rgb
|
|
2
|
+
// @arguments $color (can be hardcoded or $color)
|
|
3
|
+
// @return: comma separated RGB values
|
|
4
|
+
// Use: We use "extract-rgb" when we want to return a comma separated list of rgb values from a color.
|
|
5
|
+
// - We use it in some of our token assignments and their custom-properties output.
|
|
6
|
+
@function extract-rgb($color) {
|
|
7
|
+
@return red($color), green($color), blue($color);
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// MIXINS: Map Collect
|
|
2
|
+
|
|
3
|
+
// Modules imports
|
|
4
|
+
@use "sass:map";
|
|
5
|
+
|
|
6
|
+
// @arguments: multiple coma separated $maps.
|
|
7
|
+
// @return: a single map with merged values.
|
|
8
|
+
// Use: we use "map-collect" to merge maps from different scopes.
|
|
9
|
+
// - We assume there will be no key duplication since scopes are separated.
|
|
10
|
+
@function map-collect($maps...) {
|
|
11
|
+
$collection: ();
|
|
12
|
+
|
|
13
|
+
@each $map in $maps {
|
|
14
|
+
$collection: map.merge($collection, $map);
|
|
15
|
+
}
|
|
16
|
+
@return $collection;
|
|
17
|
+
}
|
package/src/index.scss
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// HELIUX DESIGN SYSTEM : DESIGN TOKENS
|
|
2
|
+
// - This partial Imports all of VIBE's Token scope.
|
|
3
|
+
// - It include:
|
|
4
|
+
// - global functions.
|
|
5
|
+
// - Core Tokens and Core Maps.
|
|
6
|
+
// - Theme based Tokens and maps.
|
|
7
|
+
// - Custom properties are generated per each scope from a unified scope related settings map.
|
|
8
|
+
// - CSS Output is custom properties definitions for global :root and themes scopes.
|
|
9
|
+
// - Currently we do not include themes within this refactor scope.
|
|
10
|
+
|
|
11
|
+
// Dependencies
|
|
12
|
+
@import "functions";
|
|
13
|
+
@import "internal-mixins";
|
|
14
|
+
@import "config";
|
|
15
|
+
|
|
16
|
+
// Output
|
|
17
|
+
@import "core";
|
|
18
|
+
@import "themes";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// MIXINS: Generate custom properties
|
|
2
|
+
|
|
3
|
+
// Used to create custom properties from a $map
|
|
4
|
+
// @arguments: $map
|
|
5
|
+
// Loops over the map
|
|
6
|
+
// - Generates custom properties from its keys
|
|
7
|
+
// - Each Custom property value is the map key value.
|
|
8
|
+
@mixin generate-custom-properties($map) {
|
|
9
|
+
@each $key, $value in $map {
|
|
10
|
+
--#{$key}: #{$value};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// MIXINS: Utility
|
|
2
|
+
|
|
3
|
+
// Modules imports
|
|
4
|
+
@use "sass:map";
|
|
5
|
+
@use "sass:string";
|
|
6
|
+
@use "sass:list";
|
|
7
|
+
/* stylelint-disable scss/at-if-no-null */
|
|
8
|
+
|
|
9
|
+
// These internal-mixins Create Utility class definitions from a utilities map.
|
|
10
|
+
|
|
11
|
+
// Generate utilities
|
|
12
|
+
// @arguments: $utility , $infix, $export
|
|
13
|
+
// - $utility is a scope key from the utilities map.
|
|
14
|
+
// - $infix is defined by utility values
|
|
15
|
+
// - $export enables Camelcase by capitalizing the $infix
|
|
16
|
+
// -- This is achieved via flag using $export:"modules" (for css modules)
|
|
17
|
+
// This mixin generates classes with definition per a utility scope
|
|
18
|
+
// - Utility scopes are nested within a utility map
|
|
19
|
+
// - Map keys are fixed and defined within the mixin:
|
|
20
|
+
// -- property, class,values,
|
|
21
|
+
@mixin generate-utility-class($utility, $infix, $export) {
|
|
22
|
+
$values: map.get($utility, values);
|
|
23
|
+
@if type-of($values) == "string" or type-of(nth($values, 1)) != "list" {
|
|
24
|
+
$values: list.zip($values, $values);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@each $key, $value in $values {
|
|
28
|
+
$properties: map.get($utility, property);
|
|
29
|
+
|
|
30
|
+
// Multiple properties are possible, for example with vertical or horizontal margins or paddings
|
|
31
|
+
@if type-of($properties) == "string" {
|
|
32
|
+
$properties: list.append((), $properties);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Use custom class if present
|
|
36
|
+
$property-class: if(map.has-key($utility, class), map.get($utility, class), list.nth($properties, 1));
|
|
37
|
+
$property-class: if($property-class == null, "", $property-class);
|
|
38
|
+
|
|
39
|
+
$infix: if($property-class == "" and string.slice($infix, 1, 1) == "-", string.slice($infix, 2), $infix);
|
|
40
|
+
|
|
41
|
+
// Don't prefix if value key is null (eg. with shadow class)
|
|
42
|
+
$property-class-modifier: if($key, if($property-class == "" and $infix == "", "", "") + $key, "");
|
|
43
|
+
|
|
44
|
+
@if $value != null {
|
|
45
|
+
@if $export == "modules" {
|
|
46
|
+
$class-name: $property-class + capitalize(camelize($infix)) + capitalize(camelize($property-class-modifier));
|
|
47
|
+
.#{$class-name} {
|
|
48
|
+
@each $property in $properties {
|
|
49
|
+
#{$property}: $value !important;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} @else {
|
|
53
|
+
$class-name: $property-class + $infix + -#{$property-class-modifier};
|
|
54
|
+
.#{$class-name} {
|
|
55
|
+
@each $property in $properties {
|
|
56
|
+
#{$property}: $value !important;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Generate utilities
|
|
65
|
+
// This mixin invoke the utility mixin by setting its map and export type, and initializing the $infix.
|
|
66
|
+
@mixin utility-class-factory($map, $infix: "", $export: "") {
|
|
67
|
+
@each $key, $utility in $map {
|
|
68
|
+
// The utility can be disabled with `false`, thus check if the utility is a map first
|
|
69
|
+
// Only proceed if responsive media queries are enabled or if it's the base media query
|
|
70
|
+
@if type-of($utility) == "map" and ($infix == "") {
|
|
71
|
+
@include generate-utility-class($utility, $infix, $export);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* stylelint-enable scss/at-if-no-null */
|
|
File without changes
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
$expand-animation-timing: cubic-bezier(0, 0, 0.35, 1);
|
|
2
|
+
|
|
3
|
+
// Grid auto fit sizes
|
|
4
|
+
$grid-auto-fit-cell-width-small: 120px;
|
|
5
|
+
$grid-auto-fit-cell-width-medium: 180px;
|
|
6
|
+
$grid-auto-fit-cell-width-large: 240px;
|
|
7
|
+
$grid-auto-fit-cell-width-xl: 300px;
|
|
8
|
+
|
|
9
|
+
@mixin hidden-element() {
|
|
10
|
+
opacity: 0;
|
|
11
|
+
width: 0;
|
|
12
|
+
height: 0;
|
|
13
|
+
position: absolute;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Grid auto fit
|
|
17
|
+
// - This mixin defines a grid with auto fit repeat cells using min-max funtion.
|
|
18
|
+
// -- This allows grid to accommodate container width without media queries.
|
|
19
|
+
// -- it uses a repeat grid function with auto fix and minmax.
|
|
20
|
+
// -- grid adaptation is due to the min value along with auto-fit and 1fr max value.
|
|
21
|
+
|
|
22
|
+
// @params:
|
|
23
|
+
// - $grid-gap: null , defines grid "gap" attribute.
|
|
24
|
+
// - $grid-column-gap: null, defines grid "column-gap" attribute.
|
|
25
|
+
// - $grid-row-gap: null, defines grid "row-gap" attribute.
|
|
26
|
+
// - $grid-cell-min-width: {mandatory}, defined min value in for grid-template-columns
|
|
27
|
+
// - $grid-cell-array-calc: {mandatory}, defined max num of items using calc
|
|
28
|
+
|
|
29
|
+
@mixin grid-auto-fit(
|
|
30
|
+
$grid-gap: null,
|
|
31
|
+
$grid-column-gap: null,
|
|
32
|
+
$grid-row-gap: null,
|
|
33
|
+
$grid-cell-min-width,
|
|
34
|
+
$grid-cell-array-calc: null,
|
|
35
|
+
$important: false
|
|
36
|
+
) {
|
|
37
|
+
display: grid;
|
|
38
|
+
@if $important {
|
|
39
|
+
grid-template-columns: repeat(
|
|
40
|
+
auto-fit,
|
|
41
|
+
minmax(clamp(#{$grid-cell-array-calc}, #{$grid-cell-min-width}, 100%), 1fr)
|
|
42
|
+
) !important;
|
|
43
|
+
gap: $grid-gap !important;
|
|
44
|
+
column-gap: $grid-column-gap !important;
|
|
45
|
+
row-gap: $grid-row-gap !important;
|
|
46
|
+
} @else {
|
|
47
|
+
grid-template-columns: repeat(
|
|
48
|
+
auto-fit,
|
|
49
|
+
minmax(clamp(#{$grid-cell-array-calc}, #{$grid-cell-min-width}, 100%), 1fr)
|
|
50
|
+
);
|
|
51
|
+
gap: $grid-gap;
|
|
52
|
+
column-gap: $grid-column-gap;
|
|
53
|
+
row-gap: $grid-row-gap;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@mixin scroller($width: 4px, $height: 6px, $color: var(--divider-primary)) {
|
|
58
|
+
&::-webkit-scrollbar {
|
|
59
|
+
width: $width;
|
|
60
|
+
height: $height;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&::-webkit-scrollbar-thumb {
|
|
64
|
+
background-color: $color;
|
|
65
|
+
border-radius: 4px;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
@mixin disabled {
|
|
2
|
+
border-color: var(--disabled-background-color);
|
|
3
|
+
color: var(--disabled-text-color);
|
|
4
|
+
cursor: not-allowed;
|
|
5
|
+
|
|
6
|
+
&:hover {
|
|
7
|
+
background-color: transparent;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@mixin reset-button {
|
|
12
|
+
border: none;
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding: 0;
|
|
15
|
+
width: auto;
|
|
16
|
+
overflow: visible;
|
|
17
|
+
background: transparent;
|
|
18
|
+
|
|
19
|
+
/* inherit font & color from ancestor */
|
|
20
|
+
color: inherit;
|
|
21
|
+
font: inherit;
|
|
22
|
+
|
|
23
|
+
/* Normalize `line-height`. Cannot be changed from `normal` in Firefox 4+. */
|
|
24
|
+
line-height: normal;
|
|
25
|
+
|
|
26
|
+
/* Corrects font smoothing for webkit */
|
|
27
|
+
-webkit-font-smoothing: inherit;
|
|
28
|
+
-moz-osx-font-smoothing: inherit;
|
|
29
|
+
|
|
30
|
+
/* Corrects inability to style clickable `input` types in iOS */
|
|
31
|
+
appearance: none;
|
|
32
|
+
|
|
33
|
+
@include focus-style;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@mixin focus-style($focus-radius: 4px) {
|
|
37
|
+
&:focus-visible,
|
|
38
|
+
&.focus-visible {
|
|
39
|
+
outline: none;
|
|
40
|
+
z-index: 11;
|
|
41
|
+
border-radius: $focus-radius;
|
|
42
|
+
box-shadow: 0 0 0 3px hsl(209deg 100% 50% / 50%), 0 0 0 1px var(--primary-hover-color) inset;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&:focus:not(.focus-visible) {
|
|
46
|
+
outline: none;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@mixin vibe-text($type-prefix, $weight-type) {
|
|
2
|
+
font: var(--font-#{$type-prefix}-#{$weight-type});
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
@mixin vibe-heading($type-prefix, $weight-type) {
|
|
6
|
+
font: var(--font-#{$type-prefix}-#{$weight-type});
|
|
7
|
+
letter-spacing: var(--letter-spacing-#{$type-prefix}-#{$weight-type});
|
|
8
|
+
-webkit-font-smoothing: var(--font-smoothing-webkit);
|
|
9
|
+
-moz-osx-font-smoothing: var(--font-smoothing-moz);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@mixin line-clamp($lines: 1le) {
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
display: -webkit-box;
|
|
15
|
+
-webkit-line-clamp: $lines;
|
|
16
|
+
-webkit-box-orient: vertical;
|
|
17
|
+
white-space: initial; // doesn't work with white-space: no-wrap
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@mixin ellipsis {
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
text-overflow: ellipsis;
|
|
23
|
+
white-space: nowrap;
|
|
24
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// UTILITIES: Value Maps
|
|
2
|
+
// - Maps for the utility mixin.
|
|
3
|
+
// - imported using "common.scss" partial.
|
|
4
|
+
|
|
5
|
+
$utility-spacing-vars: (
|
|
6
|
+
0: 0,
|
|
7
|
+
xs: var(--spacing-xs),
|
|
8
|
+
small: var(--spacing-small),
|
|
9
|
+
medium: var(--spacing-medium),
|
|
10
|
+
large: var(--spacing-large),
|
|
11
|
+
xl: var(--spacing-xl),
|
|
12
|
+
xxl: var(--spacing-xxl),
|
|
13
|
+
xxxl: var(--spacing-xxxl)
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
$utility-border-colors-vars: (
|
|
17
|
+
uiBorderColor: var(--divider-primary),
|
|
18
|
+
layoutBorderColor: var(--divider-secondary)
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
$utility-colors-vars: (
|
|
22
|
+
primaryTextColor: var(--text-primary),
|
|
23
|
+
textColorOnInverted: var(--text-color-on-inverted),
|
|
24
|
+
secondaryTextColor: var(--text-secondary)
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
$utility-background-colors-vars: (
|
|
28
|
+
primaryBackgroundColor: var(--surface-primary),
|
|
29
|
+
secondaryBackgroundColor: var(--surface-secondary),
|
|
30
|
+
greyBackgroundColor: var(--surface-tertiary),
|
|
31
|
+
allgreyBackgroundColor: var(--surface-quaternary),
|
|
32
|
+
invertedColorBackground: var(--surface-inverse)
|
|
33
|
+
);
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
const { lint } = require("stylelint");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
|
|
5
|
+
const config = {
|
|
6
|
+
plugins: [path.resolve(__dirname, "../index.js")],
|
|
7
|
+
customSyntax: "postcss-scss",
|
|
8
|
+
rules: {
|
|
9
|
+
"@heliux-org/ui-style/use-defined-css-var-when-available": true
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const configWithUseRecommendation = {
|
|
14
|
+
...config,
|
|
15
|
+
rules: {
|
|
16
|
+
"@heliux-org/ui-style/use-defined-css-var-when-available": [
|
|
17
|
+
true,
|
|
18
|
+
{
|
|
19
|
+
useRecommendedFixes: true
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe("@heliux-org/ui-style/use-defined-css-var-when-available", () => {
|
|
26
|
+
// since we run tests that actually perform code fixes, the fixtures are expected to change
|
|
27
|
+
const fixturesContentBeforeTests = new Map();
|
|
28
|
+
|
|
29
|
+
beforeAll(() => {
|
|
30
|
+
const allFiles = fs.readdirSync(path.resolve(__dirname, "fixtures"));
|
|
31
|
+
|
|
32
|
+
allFiles.forEach(fixture => {
|
|
33
|
+
const fixturePath = path.resolve(__dirname, "fixtures", fixture);
|
|
34
|
+
const fixtureContent = fs.readFileSync(fixturePath).toString();
|
|
35
|
+
fixturesContentBeforeTests.set(fixturePath, fixtureContent);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
for (const [filePath, content] of fixturesContentBeforeTests) {
|
|
41
|
+
try {
|
|
42
|
+
fs.writeFileSync(filePath, content, { encoding: "utf-8" });
|
|
43
|
+
} catch (e) {
|
|
44
|
+
console.error(
|
|
45
|
+
`Failed resetting file content for file: ${filePath}. This may result in changes that should have been reverted automatically. You will need to manually revert this, sorry.`
|
|
46
|
+
);
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("warns for values that can be replaced with single CSS vars", async () => {
|
|
53
|
+
const {
|
|
54
|
+
results: [{ warnings }]
|
|
55
|
+
} = await lint({
|
|
56
|
+
files: path.resolve(__dirname, "./fixtures/contains-values-with-single-replacement.scss"),
|
|
57
|
+
config
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
expect(warnings).toHaveLength(2);
|
|
61
|
+
const [firstWarning, secondWarning] = warnings;
|
|
62
|
+
|
|
63
|
+
expect(firstWarning.text).toBe(
|
|
64
|
+
`Expected \"16px\" to be \"var(--spacing-medium)\" (@heliux-org/ui-style/use-defined-css-var-when-available)`
|
|
65
|
+
);
|
|
66
|
+
expect(firstWarning.line).toBe(3);
|
|
67
|
+
expect(firstWarning.column).toBe(15);
|
|
68
|
+
|
|
69
|
+
expect(secondWarning.text).toBe(
|
|
70
|
+
`Expected \"16px\" to be \"var(--border-radius-big)\" (@heliux-org/ui-style/use-defined-css-var-when-available)`
|
|
71
|
+
);
|
|
72
|
+
expect(secondWarning.line).toBe(7);
|
|
73
|
+
expect(secondWarning.column).toBe(18);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("fixes values that can be replaced with single CSS vars", async () => {
|
|
77
|
+
const { results } = await lint({
|
|
78
|
+
files: path.resolve(__dirname, "./fixtures/contains-values-with-single-replacement.scss"),
|
|
79
|
+
config,
|
|
80
|
+
fix: true
|
|
81
|
+
});
|
|
82
|
+
const file = results[0]._postcssResult.opts.from;
|
|
83
|
+
const expectedOutputAfterFix = `
|
|
84
|
+
.some-class {
|
|
85
|
+
width: 16px;
|
|
86
|
+
margin-top: var(--spacing-medium);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#id {
|
|
90
|
+
border-radius: var(--border-radius-big) 14px;
|
|
91
|
+
}`.trim();
|
|
92
|
+
|
|
93
|
+
const contentAfterFix = fs.readFileSync(file).toString().trim();
|
|
94
|
+
|
|
95
|
+
expect(contentAfterFix).toEqual(expectedOutputAfterFix);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// We currently not supporting this use case after stop recommending use font size variables
|
|
99
|
+
it.skip("warns for values that can be replaced with multiple CSS vars", async () => {
|
|
100
|
+
const {
|
|
101
|
+
results: [{ warnings }]
|
|
102
|
+
} = await lint({
|
|
103
|
+
files: path.resolve(__dirname, "./fixtures/contains-values-with-multiple-replacements.scss"),
|
|
104
|
+
config
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
expect(warnings).toHaveLength(1);
|
|
108
|
+
const [firstWarning] = warnings;
|
|
109
|
+
|
|
110
|
+
expect(firstWarning.text).toBe(
|
|
111
|
+
`Expected "14px" to be one of vars:
|
|
112
|
+
--font-size-20
|
|
113
|
+
--font-size-general-label
|
|
114
|
+
--font-size-subtext
|
|
115
|
+
(@heliux-org/ui-style/use-defined-css-var-when-available)`
|
|
116
|
+
);
|
|
117
|
+
expect(firstWarning.line).toBe(3);
|
|
118
|
+
expect(firstWarning.column).toBe(14);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// We currently not supporting this use case after stop recommending use font size variables
|
|
122
|
+
it.skip("perform fixes when there are multiple var replacements, when specifying the useRecommendedFixes flag", async () => {
|
|
123
|
+
const { results } = await lint({
|
|
124
|
+
files: path.resolve(__dirname, "./fixtures/contains-values-with-multiple-replacements.scss"),
|
|
125
|
+
config: configWithUseRecommendation,
|
|
126
|
+
fix: true
|
|
127
|
+
});
|
|
128
|
+
const file = results[0]._postcssResult.opts.from;
|
|
129
|
+
const expectedOutputAfterFix = `
|
|
130
|
+
.some-font-class {
|
|
131
|
+
width: 16px;
|
|
132
|
+
font-size: var(--font-size-general-label);
|
|
133
|
+
}`.trim();
|
|
134
|
+
|
|
135
|
+
const contentAfterFix = fs.readFileSync(file).toString().trim();
|
|
136
|
+
|
|
137
|
+
expect(contentAfterFix).toEqual(expectedOutputAfterFix);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("does not perform fixes when there are multiple var replacements, when not specifying the useRecommendedFixes flag", async () => {
|
|
141
|
+
const { results } = await lint({
|
|
142
|
+
files: path.resolve(__dirname, "./fixtures/contains-values-with-multiple-replacements.scss"),
|
|
143
|
+
config,
|
|
144
|
+
fix: true
|
|
145
|
+
});
|
|
146
|
+
const originalContent = results[0]._postcssResult.css;
|
|
147
|
+
const file = results[0]._postcssResult.opts.from;
|
|
148
|
+
const expectedOutputAfterFix = originalContent;
|
|
149
|
+
|
|
150
|
+
const contentAfterFix = fs.readFileSync(file).toString();
|
|
151
|
+
|
|
152
|
+
expect(contentAfterFix).toEqual(expectedOutputAfterFix);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
["disabled", "DiSaBlE", "off", 0, false, "false", "0"].forEach(ruleConfigValue => {
|
|
156
|
+
it(`does not lint if the rule is disabled by config value of "${ruleConfigValue}"`, async () => {
|
|
157
|
+
const { results } = await lint({
|
|
158
|
+
files: path.resolve(__dirname, "./fixtures/contains-values-with-multiple-replacements.scss"),
|
|
159
|
+
config: {
|
|
160
|
+
...config,
|
|
161
|
+
rules: {
|
|
162
|
+
"@heliux-org/ui-style/use-defined-css-var-when-available": ruleConfigValue
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
expect(results).toHaveLength(1);
|
|
167
|
+
expect(results[0].warnings).toHaveLength(0); // the errors were ignored
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const { parseMondayUiCss, getPropsToAllowedCssVars } = require("../parse-monday-css");
|
|
2
|
+
const { PROPS_TO_ALLOWED_VARS } = require("../props-to-allowed-vars");
|
|
3
|
+
|
|
4
|
+
const ALLOWED_CSS_VARS_PREFIX_WITHOUT_MAPPING = [
|
|
5
|
+
"--font-h",
|
|
6
|
+
"--font-text",
|
|
7
|
+
"--font-general-label",
|
|
8
|
+
"--font-subtext",
|
|
9
|
+
"--font-paragraph",
|
|
10
|
+
"--font-weight",
|
|
11
|
+
"--font-size",
|
|
12
|
+
"--font-line-height",
|
|
13
|
+
"--letter-spacing"
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
describe("props-to-allowed-vars", () => {
|
|
17
|
+
const { allVarsToCanonicalValue } = parseMondayUiCss();
|
|
18
|
+
const propsToAllowedCssVars = getPropsToAllowedCssVars();
|
|
19
|
+
|
|
20
|
+
describe("PROPS_TO_ALLOWED_VARS", () => {
|
|
21
|
+
const allRootCssVarsFromGeneratedCss = Object.keys(allVarsToCanonicalValue);
|
|
22
|
+
const allMappedCssVars = [
|
|
23
|
+
...new Set(
|
|
24
|
+
Object.values(PROPS_TO_ALLOWED_VARS).reduce((acc, { allowedVars, recommended }) => [...acc, ...allowedVars], [])
|
|
25
|
+
)
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
allMappedCssVars.forEach(cssVarName => {
|
|
29
|
+
it(`should only include css vars that are under :root, without additional selectors - checking ${cssVarName} `, () => {
|
|
30
|
+
//if this fails, this means that we mapped a css prop to a css var that doesn't exist in our CSS output
|
|
31
|
+
const isExistingInCssOutput = allRootCssVarsFromGeneratedCss.includes(cssVarName);
|
|
32
|
+
|
|
33
|
+
expect(isExistingInCssOutput).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
allRootCssVarsFromGeneratedCss.forEach(varFromGeneratedCss => {
|
|
38
|
+
it(`should map the css var ${varFromGeneratedCss} to valid css props that can use it`, () => {
|
|
39
|
+
const isCssVarMapped = allMappedCssVars.includes(varFromGeneratedCss);
|
|
40
|
+
|
|
41
|
+
if (!ALLOWED_CSS_VARS_PREFIX_WITHOUT_MAPPING.some(prefix => varFromGeneratedCss.startsWith(prefix))) {
|
|
42
|
+
// If this fails, a CSS var was added without mapping it to recommended CSS props.
|
|
43
|
+
// Without this mapping, we won't be able to recommend the proper usage of the CSS var.
|
|
44
|
+
// Please add your var to PROPS_TO_ALLOWED_VARS
|
|
45
|
+
expect(isCssVarMapped).toBeTruthy();
|
|
46
|
+
} else {
|
|
47
|
+
// If this fails, a CSS var was whitelisted as a variable without mapping, but it has mapping in PROPS_TO_ALLOWED_VARS.
|
|
48
|
+
// Either remove the CSS var from ALLOWED_CSS_VARS_WITHOUT_MAPPINGS, or remove the CSS var mapping from PROPS_TO_ALLOWED_VARS.
|
|
49
|
+
expect(isCssVarMapped).toBeFalsy();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
Object.keys(PROPS_TO_ALLOWED_VARS).forEach(cssProp => {
|
|
55
|
+
const { allowedVars, recommended } = PROPS_TO_ALLOWED_VARS[cssProp];
|
|
56
|
+
const valuesToMatchingVars = {};
|
|
57
|
+
allowedVars.forEach(varName => {
|
|
58
|
+
const varValue = allVarsToCanonicalValue[varName];
|
|
59
|
+
valuesToMatchingVars[varValue] = valuesToMatchingVars[varValue] || [];
|
|
60
|
+
valuesToMatchingVars[varValue].push(varName);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
Object.keys(valuesToMatchingVars).forEach(value => {
|
|
64
|
+
it(`should have a recommended var for each value that has multiple variables, for CSS prop ${cssProp} and value ${value}`, () => {
|
|
65
|
+
const matchingVars = valuesToMatchingVars[value];
|
|
66
|
+
if (matchingVars.length === 1) {
|
|
67
|
+
// only one option, no need for a recommendation
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const recommendationsToApply = intersect(matchingVars, recommended);
|
|
71
|
+
if (recommendationsToApply.length === 1) {
|
|
72
|
+
//only one recommendation, that's good
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (recommendationsToApply.length === 0) {
|
|
76
|
+
fail(`Expected "${value}" to have a recommendation when being used in the CSS prop "${cssProp}", since it has multiple options: ${matchingVars.join(
|
|
77
|
+
", "
|
|
78
|
+
)}
|
|
79
|
+
Please choose a single variable which should be used as a recommendation.`);
|
|
80
|
+
} else {
|
|
81
|
+
fail(`Expected "${value}" to have a single recommendation when being used in the CSS prop "${cssProp}", since it has multiple options: ${matchingVars.join(
|
|
82
|
+
", "
|
|
83
|
+
)}
|
|
84
|
+
Instead, there were multiple recommendations with the same value: ${recommendationsToApply.join(", ")}.
|
|
85
|
+
Please choose a single variable which should be used as a recommendation.`);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
Object.keys(propsToAllowedCssVars[cssProp]).forEach(value => {
|
|
91
|
+
it(`should only have recommendations for values that have multiple possible variables, for CSS prop ${cssProp} and value ${value}`, () => {
|
|
92
|
+
const { recommended } = propsToAllowedCssVars[cssProp][value];
|
|
93
|
+
if (!recommended) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const matchingVarsCount = valuesToMatchingVars[value].length;
|
|
98
|
+
if (matchingVarsCount === 0) {
|
|
99
|
+
fail(`Found a recommendation for css prop "${cssProp}" and value "${value}", even though there are no matching variables.
|
|
100
|
+
Recommendations should only be added in cases that there are multiple variables that can be used, and have the same value.`);
|
|
101
|
+
}
|
|
102
|
+
if (matchingVarsCount === 1) {
|
|
103
|
+
fail(`Found a recommendation for css prop "${cssProp}" and value "${value}", even though only one variables matches this value: "${valuesToMatchingVars[value]}".
|
|
104
|
+
Recommendations should only be added in cases that there are multiple variables that can be used, and have the same value.`);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
//shamelessly copied from https://stackoverflow.com/a/37041756/17779778
|
|
113
|
+
function intersect(arr1, arr2) {
|
|
114
|
+
var set1 = new Set(arr1);
|
|
115
|
+
var set2 = new Set(arr2);
|
|
116
|
+
var intersection = new Set([...set1].filter(x => set2.has(x)));
|
|
117
|
+
return Array.from(intersection);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function fail(message) {
|
|
121
|
+
throw new Error(message);
|
|
122
|
+
}
|