@c8y/style 1023.14.76 → 1023.14.94
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/branding-login.less +1 -1
- package/helper-scripts/README-variable-imports.md +155 -0
- package/helper-scripts/README.md +104 -0
- package/helper-scripts/convert-scss-to-less.sh +502 -0
- package/helper-scripts/convert-stroke-icons-to-less.js +115 -0
- package/helper-scripts/remove-redundant-variable-imports.sh +80 -0
- package/helper-scripts/scss-to-less-skip +20 -0
- package/{sync-scss-to-less.sh → helper-scripts/sync-scss-to-less.sh} +2 -2
- package/helper-scripts/test-compile.sh +71 -0
- package/markdown-files/MANUAL-SYNC-FILES.md +56 -0
- package/package.json +2 -2
- package/styles/_login-app.less +34 -0
- package/styles/_login-app.scss +2 -2
- package/styles/_mixins.less +47 -0
- package/styles/_utilities.less +21 -0
- package/styles/_utilities.scss +1 -0
- package/styles/animations/_animate.less +18 -13
- package/styles/animations/_component-animations.less +18 -16
- package/styles/animations/_realtime-animation-list.less +11 -1
- package/styles/animations/_spinner-snake.less +17 -2
- package/styles/animations/_spinner.less +24 -6
- package/styles/base/_normalize.less +14 -0
- package/styles/base/_print.less +25 -12
- package/styles/base/_scaffolding.less +24 -28
- package/styles/base/_type.less +41 -19
- package/styles/components/_markdown-content.less +4 -1
- package/styles/components/_smartrules.less +14 -8
- package/styles/components/_smartrules.scss +6 -2
- package/styles/components/application-and-system/_c8y-cookie-banner.less +36 -0
- package/styles/components/{specialized → application-and-system}/_c8y-login.less +20 -6
- package/styles/components/data-display-and-visualization/_boxed-label.less +45 -0
- package/styles/components/data-display-and-visualization/_boxed-label.scss +46 -0
- package/styles/components/{specialized → data-display-and-visualization}/_c8y-data-explorer.less +76 -24
- package/styles/components/{specialized → data-display-and-visualization}/_c8y-data-explorer.scss +39 -1
- package/styles/components/{specialized → data-display-and-visualization}/_c8y-datapoint-pill.less +29 -13
- package/styles/components/{specialized → data-display-and-visualization}/_c8y-pulse.less +33 -6
- package/styles/components/data-display-and-visualization/_range-display.less +25 -16
- package/styles/components/{specialized → data-display-and-visualization}/_smart-list-icon-label.less +19 -5
- package/styles/components/{specialized → data-display-and-visualization}/_status.less +16 -2
- package/styles/components/{specialized → data-display-and-visualization}/_statusContainer.less +16 -2
- package/styles/components/data-display-and-visualization/_timelines-chart.less +2 -0
- package/styles/components/data-display-and-visualization/lists/_c8y-data-point-list.less +10 -0
- package/styles/components/data-display-and-visualization/lists/_c8y-empty-state.less +26 -12
- package/styles/components/data-display-and-visualization/lists/_c8y-list-group.less +88 -42
- package/styles/components/data-display-and-visualization/lists/_cards-layout.less +38 -16
- package/styles/components/data-display-and-visualization/lists/_list-group.less +46 -28
- package/styles/components/data-display-and-visualization/lists/_smart-rules-template-list.less +12 -1
- package/styles/components/data-display-and-visualization/lists/{timeline-list.less → _timeline-list.less} +46 -24
- package/styles/components/data-display-and-visualization/tables/_data-grid.less +45 -25
- package/styles/components/data-display-and-visualization/tables/_resizable-grid.less +18 -1
- package/styles/components/data-display-and-visualization/tables/_tables.less +25 -9
- package/styles/components/data-input/_c8y-ai-chat.less +1 -0
- package/styles/components/{specialized → data-input}/_c8y-countdown-interval.less +15 -13
- package/styles/components/{specialized → data-input}/_c8y-range.less +22 -6
- package/styles/components/{specialized → data-input}/_dtm-icon-selector.less +17 -2
- package/styles/components/{specialized → data-input}/_dtm-icon-selector.scss +1 -2
- package/styles/components/{specialized → data-input}/_measurements-time-control.less +34 -6
- package/styles/components/{specialized → data-input}/_measurements-time-control.scss +14 -2
- package/styles/components/{specialized → data-input}/_search-header.less +22 -6
- package/styles/components/data-input/_static-assets-file-picker.less +22 -0
- package/styles/components/data-input/assets/_asset-property-list.less +38 -23
- package/styles/components/data-input/assets/_asset-table.less +21 -3
- package/styles/components/data-input/assets/_c8y-asset-notes.less +13 -1
- package/styles/components/data-input/assets/_c8y-asset-selector-miller.less +27 -8
- package/styles/components/data-input/assets/_c8y-asset-selector.less +32 -15
- package/styles/components/data-input/assets/_c8y-child-assets-selector.less +90 -9
- package/styles/components/{specialized → forms}/_c8y-schema-form.less +44 -17
- package/styles/components/{specialized → forms}/_c8y-schema-form.scss +15 -3
- package/styles/components/{specialized → navigation-and-layout}/_c8y-role-card.less +21 -5
- package/styles/components/{specialized → navigation-and-layout}/_c8y-scrollbar.less +24 -7
- package/styles/components/{specialized → navigation-and-layout}/_c8y-smart-rest-tab.less +21 -6
- package/styles/components/{specialized → navigation-and-layout}/_c8y-stepper.less +15 -1
- package/styles/components/{specialized → navigation-and-layout}/_c8y-user-roles.less +45 -28
- package/styles/components/{specialized → navigation-and-layout}/_device-software-tab.less +14 -0
- package/styles/components/navigation-and-layout/action-bars/_app-switcher.less +27 -5
- package/styles/components/navigation-and-layout/action-bars/_c8y-action-bar.less +49 -21
- package/styles/components/navigation-and-layout/cards/_card-dashboard.less +25 -4
- package/styles/components/navigation-and-layout/cards/_card-flip.less +41 -14
- package/styles/components/navigation-and-layout/cards/_card-grid.less +20 -4
- package/styles/components/navigation-and-layout/cards/_card.less +90 -75
- package/styles/components/navigation-and-layout/cards/_panels.less +38 -20
- package/styles/components/navigation-and-layout/navigation/_breadcrumbs.less +22 -49
- package/styles/components/navigation-and-layout/navigation/_c8y-nav-stacked.less +26 -14
- package/styles/components/navigation-and-layout/navigation/_main-header.less +39 -13
- package/styles/components/navigation-and-layout/navigation/_main-header.scss +1 -1
- package/styles/components/navigation-and-layout/navigation/_navbar.less +22 -25
- package/styles/components/navigation-and-layout/navigation/_navbar.scss +7 -7
- package/styles/components/navigation-and-layout/navigation/_navigator.less +71 -69
- package/styles/components/navigation-and-layout/navigation/_navs.less +13 -0
- package/styles/components/navigation-and-layout/navigation/_pagination.less +24 -5
- package/styles/components/navigation-and-layout/navigation/{steps-navbar.less → _steps-navbar.less} +7 -6
- package/styles/components/navigation-and-layout/navigation/_tabs.less +18 -14
- package/styles/components/navigation-and-layout/navigation/_tabs.scss +2 -2
- package/styles/components/{specialized → status-feedback-and-notifications}/_c8y-message-banner.less +14 -0
- package/styles/components/{specialized → status-feedback-and-notifications}/_code.less +18 -2
- package/styles/core/buttons/_button-groups.less +29 -79
- package/styles/core/buttons/_buttons.less +229 -198
- package/styles/core/buttons/_buttons.scss +6 -10
- package/styles/core/feedback/_alerts.less +52 -41
- package/styles/core/feedback/_badges.less +29 -17
- package/styles/core/feedback/_close.less +24 -7
- package/styles/core/feedback/_labels.less +21 -8
- package/styles/core/feedback/_progress-bars.less +24 -7
- package/styles/core/feedback/_tag.less +23 -6
- package/styles/core/feedback/_tooltip.less +44 -20
- package/styles/core/forms/_c8y-switch.less +39 -19
- package/styles/core/forms/_c8y-switch.scss +37 -29
- package/styles/core/forms/_file-picker.less +79 -61
- package/styles/core/forms/_forms.less +130 -133
- package/styles/core/forms/_input-groups.less +110 -59
- package/styles/core/forms/_input-groups.scss +21 -3
- package/styles/core/overlays/_c8y-dashboard-modal.less +25 -29
- package/styles/core/overlays/_c8y-wizard.less +38 -15
- package/styles/core/overlays/_dropdowns.less +86 -63
- package/styles/core/overlays/_modals.less +58 -40
- package/styles/core/overlays/_popovers.less +25 -9
- package/styles/dashboard/_availability-pie.less +3 -0
- package/styles/dashboard/_c8y-dashboard-style.less +61 -34
- package/styles/dashboard/_c8y-gauges.less +20 -4
- package/styles/dashboard/_dashboard-widgets.less +17 -4
- package/styles/dashboard/_info-gauge.less +20 -5
- package/styles/dashboard/_quick-links-widget.less +13 -3
- package/styles/{welcome-widget.less → dashboard/_welcome-widget.less} +21 -4
- package/styles/dashboard/{welcome.less → _welcome.less} +54 -45
- package/styles/icons/_c8y-glyphs.less +12 -1
- package/styles/icons/_c8y-glyphs.scss +2 -1
- package/styles/icons/_c8y-icons.less +214 -199
- package/styles/icons/_dlt-c8y-icons-stroke.less +7238 -1834
- package/styles/icons/_dlt-c8y-icons.less +14 -0
- package/styles/icons/_marker-icons.less +10 -0
- package/styles/index.less +160 -134
- package/styles/index.scss +53 -29
- package/styles/layout/_bottom-drawer.less +21 -7
- package/styles/layout/_c8y-help-drawer.less +30 -9
- package/styles/layout/_c8y-right-drawer.less +34 -19
- package/styles/layout/_c8y-top-drawer.less +43 -28
- package/styles/layout/_grid.less +18 -4
- package/styles/layout/_group-info.less +14 -2
- package/styles/layout/_layouts.less +48 -30
- package/styles/layout/_mcontainer.less +26 -12
- package/styles/layout/_page-tabs.less +115 -23
- package/styles/layout/_split-scroll.less +16 -4
- package/styles/layout/_split-view.less +34 -2
- package/styles/login-app-use.scss +2 -2
- package/styles/login-app.less +4 -4
- package/styles/mixins/_buttons.scss +1 -0
- package/styles/mixins/{color-mixins.less → _color-mixins.less} +2 -2
- package/styles/mixins/{element-queries.less → _element-queries.less} +2 -2
- package/styles/mixins/{forms.less → _forms.less} +1 -1
- package/styles/mixins/_gradients.less +117 -0
- package/styles/mixins/{grid-framework.less → _grid-framework.less} +21 -21
- package/styles/mixins/_icon-base.less +29 -0
- package/styles/mixins/{nav-vertical-align.less → _nav-vertical-align.less} +6 -2
- package/styles/mixins/_nav-vertical-align.scss +5 -2
- package/styles/mixins/{progress-bar.less → _progress-bar.less} +1 -1
- package/styles/mixins/{shadows-helper.less → _shadows-helper.less} +3 -5
- package/styles/mixins/_shadows-helper.scss +1 -4
- package/styles/mixins/{vendor-prefixes.less → _vendor-prefixes.less} +7 -22
- package/styles/mixins/_vendor-prefixes.scss +1 -17
- package/styles/utilities/_borders.less +21 -11
- package/styles/{components/specialized → utilities}/_c8y-utils.less +14 -0
- package/styles/{components/specialized → utilities}/_c8y-utils.scss +1 -1
- package/styles/utilities/_caret.less +18 -4
- package/styles/utilities/_container-queries.less +11 -3
- package/styles/utilities/_contextual-colors.less +48 -119
- package/styles/utilities/_display.less +26 -41
- package/styles/utilities/_elevation.less +17 -7
- package/styles/utilities/_flex-containers.less +10 -0
- package/styles/utilities/_flex-items.less +11 -0
- package/styles/utilities/_icon-utils.less +15 -3
- package/styles/utilities/_margins-paddings.less +23 -4
- package/styles/utilities/_overflows.less +10 -0
- package/styles/utilities/_position.less +11 -0
- package/styles/utilities/_quickfloats.less +20 -1
- package/styles/utilities/_separators.less +11 -0
- package/styles/utilities/_shadows.less +5 -49
- package/styles/{utilities.less → utilities/_sizing.less} +13 -21
- package/styles/utilities/_text-utils.less +35 -24
- package/styles/vendor/ace-editor/_ace-editor.less +1 -0
- package/styles/vendor/angular/_loading-bar.less +1 -0
- package/styles/vendor/angular/_ui-sortable.less +2 -1
- package/styles/vendor/angular/_uib-accordion.less +1 -0
- package/styles/{angular-ui-select/select.less → vendor/angular/angular-ui-select/_select.less} +2 -10
- package/styles/vendor/cdk/_cdk-drag.less +3 -0
- package/styles/vendor/cdk/_cdk-tree.less +6 -3
- package/styles/vendor/cdk/_cdk-virtual-scroll-window.less +1 -0
- package/styles/vendor/datepicker/_bs-datepicker.less +26 -6
- package/styles/vendor/datepicker/_uib-datepicker.less +37 -4
- package/styles/vendor/leaflet/_c8y-map-internal.less +44 -54
- package/styles/vendor/leaflet/_leaflet.less +4 -1
- package/styles/vendor/other/_colorpicker.less +3 -2
- package/styles/vendor/selectize/_c8y-selectize.less +33 -10
- package/variables/_color-defaults.less +29 -10
- package/variables/_color-defaults.scss +29 -10
- package/variables/_color-vars.less +37 -89
- package/variables/_color-vars.scss +19 -77
- package/variables/{login-vars.less → _login-vars.less} +3 -5
- package/variables/index.less +3 -3
- package/variables/tokens/{c8y-design-tokens-dark.less → _c8y-design-tokens-dark.less} +5 -1
- package/variables/tokens/{c8y-design-tokens.less → _c8y-design-tokens.less} +5 -1
- package/styles/components/specialized/_boxed-label.less +0 -21
- package/styles/components/specialized/_boxed-label.scss +0 -36
- package/styles/components/specialized/_c8y-cookie-banner.less +0 -22
- package/styles/components/specialized/_static-assets-file-picker.less +0 -8
- package/styles/dashboard/welcome-widget.less +0 -50
- package/styles/mixins/gradients.less +0 -142
- package/styles/mixins.less +0 -45
- package/styles/steps-navbar.less +0 -97
- package/styles/timeline-list.less +0 -210
- package/styles/vendor/angular/angular-ui-select/select.less +0 -161
- package/styles/welcome.less +0 -128
- /package/styles/components/{specialized → application-and-system}/_c8y-cookie-banner.scss +0 -0
- /package/styles/components/{specialized → application-and-system}/_c8y-login.scss +0 -0
- /package/styles/components/{specialized → data-display-and-visualization}/_c8y-datapoint-pill.scss +0 -0
- /package/styles/components/{specialized → data-display-and-visualization}/_c8y-pulse.scss +0 -0
- /package/styles/components/{specialized → data-display-and-visualization}/_smart-list-icon-label.scss +0 -0
- /package/styles/components/{specialized → data-display-and-visualization}/_status.scss +0 -0
- /package/styles/components/{specialized → data-display-and-visualization}/_statusContainer.scss +0 -0
- /package/styles/components/{specialized → data-input}/_c8y-countdown-interval.scss +0 -0
- /package/styles/components/{specialized → data-input}/_c8y-range.scss +0 -0
- /package/styles/components/{specialized → data-input}/_search-header.scss +0 -0
- /package/styles/components/{specialized → data-input}/_static-assets-file-picker.scss +0 -0
- /package/styles/components/{specialized → navigation-and-layout}/_c8y-role-card.scss +0 -0
- /package/styles/components/{specialized → navigation-and-layout}/_c8y-scrollbar.scss +0 -0
- /package/styles/components/{specialized → navigation-and-layout}/_c8y-smart-rest-tab.scss +0 -0
- /package/styles/components/{specialized → navigation-and-layout}/_c8y-stepper.scss +0 -0
- /package/styles/components/{specialized → navigation-and-layout}/_c8y-user-roles.scss +0 -0
- /package/styles/components/{specialized → navigation-and-layout}/_device-software-tab.scss +0 -0
- /package/styles/components/{specialized → status-feedback-and-notifications}/_c8y-message-banner.scss +0 -0
- /package/styles/components/{specialized → status-feedback-and-notifications}/_code.scss +0 -0
- /package/styles/mixins/{alert-variant.less → _alert-variant.less} +0 -0
- /package/styles/mixins/{animation.less → _animation.less} +0 -0
- /package/styles/mixins/{background-variant.less → _background-variant.less} +0 -0
- /package/styles/mixins/{border-radius.less → _border-radius.less} +0 -0
- /package/styles/mixins/{buttons.less → _buttons.less} +0 -0
- /package/styles/mixins/{c8y-scrollbar.less → _c8y-scrollbar.less} +0 -0
- /package/styles/mixins/{center-block.less → _center-block.less} +0 -0
- /package/styles/mixins/{clearfix.less → _clearfix.less} +0 -0
- /package/styles/mixins/{create-grid.less → _create-grid.less} +0 -0
- /package/styles/mixins/{grid.less → _grid.less} +0 -0
- /package/styles/mixins/{hide-scrollbars.less → _hide-scrollbars.less} +0 -0
- /package/styles/mixins/{hide-text.less → _hide-text.less} +0 -0
- /package/styles/mixins/{image.less → _image.less} +0 -0
- /package/styles/mixins/{labels.less → _labels.less} +0 -0
- /package/styles/mixins/{list-group.less → _list-group.less} +0 -0
- /package/styles/mixins/{nav-divider.less → _nav-divider.less} +0 -0
- /package/styles/mixins/{opacity.less → _opacity.less} +0 -0
- /package/styles/mixins/{pagination.less → _pagination.less} +0 -0
- /package/styles/mixins/{panels.less → _panels.less} +0 -0
- /package/styles/mixins/{reset-filter.less → _reset-filter.less} +0 -0
- /package/styles/mixins/{reset-text.less → _reset-text.less} +0 -0
- /package/styles/mixins/{resize.less → _resize.less} +0 -0
- /package/styles/mixins/{responsive-visibility.less → _responsive-visibility.less} +0 -0
- /package/styles/mixins/{size.less → _size.less} +0 -0
- /package/styles/mixins/{tab-focus.less → _tab-focus.less} +0 -0
- /package/styles/mixins/{table-row.less → _table-row.less} +0 -0
- /package/styles/mixins/{tag.less → _tag.less} +0 -0
- /package/styles/mixins/{text-emphasis.less → _text-emphasis.less} +0 -0
- /package/styles/mixins/{text-overflow.less → _text-overflow.less} +0 -0
- /package/variables/{login-vars.scss → _login-vars.scss} +0 -0
- /package/variables/{shadows.less → _shadows.less} +0 -0
- /package/variables/{shadows.scss → _shadows.scss} +0 -0
- /package/variables/tokens/{c8y-design-tokens-dark.scss → _c8y-design-tokens-dark.scss} +0 -0
- /package/variables/tokens/{c8y-design-tokens.scss → _c8y-design-tokens.scss} +0 -0
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Semi-Automated SCSS → LESS Converter
|
|
4
|
+
# Converts SCSS syntax to LESS syntax with safety checks and manual review
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
# Get script directory for relative file paths
|
|
9
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
+
|
|
11
|
+
# Colors for output
|
|
12
|
+
RED='\033[0;31m'
|
|
13
|
+
GREEN='\033[0;32m'
|
|
14
|
+
YELLOW='\033[1;33m'
|
|
15
|
+
BLUE='\033[0;34m'
|
|
16
|
+
NC='\033[0m' # No Color
|
|
17
|
+
|
|
18
|
+
# Flags
|
|
19
|
+
DRY_RUN=false
|
|
20
|
+
VERBOSE=false
|
|
21
|
+
AUTO_APPROVE=false
|
|
22
|
+
CONVERT_ALL=false
|
|
23
|
+
|
|
24
|
+
# Parse arguments
|
|
25
|
+
while [[ $# -gt 0 ]]; do
|
|
26
|
+
case $1 in
|
|
27
|
+
--dry-run)
|
|
28
|
+
DRY_RUN=true
|
|
29
|
+
shift
|
|
30
|
+
;;
|
|
31
|
+
--verbose)
|
|
32
|
+
VERBOSE=true
|
|
33
|
+
shift
|
|
34
|
+
;;
|
|
35
|
+
--yes|-y)
|
|
36
|
+
AUTO_APPROVE=true
|
|
37
|
+
shift
|
|
38
|
+
;;
|
|
39
|
+
--all)
|
|
40
|
+
CONVERT_ALL=true
|
|
41
|
+
shift
|
|
42
|
+
;;
|
|
43
|
+
--help|-h)
|
|
44
|
+
cat <<EOF
|
|
45
|
+
SCSS to LESS Converter
|
|
46
|
+
|
|
47
|
+
Usage: $0 [OPTIONS] [FILE]
|
|
48
|
+
|
|
49
|
+
Options:
|
|
50
|
+
--dry-run Show what would be converted without writing files
|
|
51
|
+
--verbose Show detailed conversion steps
|
|
52
|
+
--yes, -y Auto-approve all conversions (use with caution)
|
|
53
|
+
--all Convert all modified SCSS files
|
|
54
|
+
--help, -h Show this help message
|
|
55
|
+
|
|
56
|
+
Examples:
|
|
57
|
+
$0 styles/core/buttons/_buttons.scss
|
|
58
|
+
$0 --dry-run styles/core/forms/_forms.scss
|
|
59
|
+
$0 --all
|
|
60
|
+
$0 --yes --all
|
|
61
|
+
|
|
62
|
+
Note:
|
|
63
|
+
Variable imports are automatically removed from LESS files since LESS uses
|
|
64
|
+
global scope (variables imported at entry points are available everywhere).
|
|
65
|
+
This differs from SCSS's @use module system which requires explicit imports.
|
|
66
|
+
|
|
67
|
+
EOF
|
|
68
|
+
exit 0
|
|
69
|
+
;;
|
|
70
|
+
*)
|
|
71
|
+
SCSS_FILE="$1"
|
|
72
|
+
shift
|
|
73
|
+
;;
|
|
74
|
+
esac
|
|
75
|
+
done
|
|
76
|
+
|
|
77
|
+
# Function to print colored messages
|
|
78
|
+
print_info() {
|
|
79
|
+
echo -e "${BLUE}ℹ${NC} $1"
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
print_success() {
|
|
83
|
+
echo -e "${GREEN}✅${NC} $1"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
print_warning() {
|
|
87
|
+
echo -e "${YELLOW}⚠️${NC} $1"
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
print_error() {
|
|
91
|
+
echo -e "${RED}❌${NC} $1"
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
# Function to convert SCSS syntax to LESS
|
|
95
|
+
convert_syntax() {
|
|
96
|
+
local content="$1"
|
|
97
|
+
local warnings=""
|
|
98
|
+
|
|
99
|
+
# Track complex patterns that need review
|
|
100
|
+
local needs_review=false
|
|
101
|
+
|
|
102
|
+
# 0a. Remove SCSS-specific @use imports FIRST (sass:string, sass:math, etc.)
|
|
103
|
+
if [[ $VERBOSE == true ]]; then
|
|
104
|
+
print_info "Removing SCSS-specific @use imports"
|
|
105
|
+
fi
|
|
106
|
+
content=$(echo "$content" | sed '/^@use[[:space:]]*["'"'"']sass:/d')
|
|
107
|
+
|
|
108
|
+
# 0b. Convert string.unquote() to ~'' BEFORE other conversions
|
|
109
|
+
if [[ $VERBOSE == true ]]; then
|
|
110
|
+
print_info "Converting string.unquote() → ~''"
|
|
111
|
+
fi
|
|
112
|
+
# Handle single quotes
|
|
113
|
+
content=$(echo "$content" | sed -E "s/string\.unquote\('([^']+)'\)/~'\1'/g")
|
|
114
|
+
# Handle double quotes
|
|
115
|
+
content=$(echo "$content" | sed -E "s/string\.unquote\(\"([^\"]+)\"\)/~\"\1\"/g")
|
|
116
|
+
|
|
117
|
+
# 0c. Convert @use to @import (remove 'as *' and add .less extension)
|
|
118
|
+
if [[ $VERBOSE == true ]]; then
|
|
119
|
+
print_info "Converting @use → @import"
|
|
120
|
+
fi
|
|
121
|
+
# With 'as *' suffix - double quotes
|
|
122
|
+
content=$(echo "$content" | sed -E 's/@use +"([^"]+)" +as +\*;/@import "\1";/g')
|
|
123
|
+
# With 'as *' suffix - single quotes
|
|
124
|
+
content=$(echo "$content" | sed -E "s/@use +'([^']+)' +as +\*;/@import '\1';/g")
|
|
125
|
+
# Without 'as *' - double quotes
|
|
126
|
+
content=$(echo "$content" | sed -E 's/@use +"([^"]+)";/@import "\1";/g')
|
|
127
|
+
# Without 'as *' - single quotes
|
|
128
|
+
content=$(echo "$content" | sed -E "s/@use +'([^']+)';/@import '\1';/g")
|
|
129
|
+
|
|
130
|
+
# 0d. Add underscore prefix and .less extension to @import paths
|
|
131
|
+
# SCSS allows omitting _ and extension, LESS requires exact filenames
|
|
132
|
+
if [[ $VERBOSE == true ]]; then
|
|
133
|
+
print_info "Normalizing @import paths for LESS"
|
|
134
|
+
fi
|
|
135
|
+
# Process @import statements with path/filename pattern
|
|
136
|
+
# Add _ prefix if filename doesn't start with _ (unless it's index)
|
|
137
|
+
# Add .less extension if not present
|
|
138
|
+
# IMPORTANT: Anchor to start of line to avoid matching quoted strings in CSS properties
|
|
139
|
+
content=$(echo "$content" | perl -pe '
|
|
140
|
+
s{^\s*\@import\s+(["'\''])([^"'\'']*/)([^_/][^"'\''/]+?)["'\'']}{
|
|
141
|
+
my ($quote, $path, $file) = ($1, $2, $3);
|
|
142
|
+
$file = "_$file" unless $file =~ /^index$/;
|
|
143
|
+
$file .= ".less" unless $file =~ /\.less$/;
|
|
144
|
+
"\@import $quote$path$file$quote"
|
|
145
|
+
}gme;
|
|
146
|
+
s{^\s*\@import\s+(["'\''])([^/]+?)["'\'']}{
|
|
147
|
+
my ($quote, $file) = ($1, $2);
|
|
148
|
+
$file = "_$file" unless $file =~ /^_/ or $file =~ /^index$/;
|
|
149
|
+
$file .= ".less" unless $file =~ /\.less$/;
|
|
150
|
+
"\@import $quote$file$quote"
|
|
151
|
+
}gme;
|
|
152
|
+
')
|
|
153
|
+
# Add .less extension to imports that already have _ but no extension
|
|
154
|
+
content=$(echo "$content" | sed -E "s/@import (['\"])(_[^'\"]+)(['\"])/\@import \1\2.less\3/g")
|
|
155
|
+
# Fix double .less.less
|
|
156
|
+
content=$(echo "$content" | sed -E 's/\.less\.less/.less/g')
|
|
157
|
+
|
|
158
|
+
# 0e. Remove redundant variable imports (LESS has global scope)
|
|
159
|
+
# Variables are imported at entry points (main.less, branding.less, login.less), so component
|
|
160
|
+
# files don't need to re-import them. This is different from SCSS @use which requires
|
|
161
|
+
# explicit imports due to its module system.
|
|
162
|
+
if [[ $VERBOSE == true ]]; then
|
|
163
|
+
print_info "Removing redundant variable imports (LESS has global scope)"
|
|
164
|
+
fi
|
|
165
|
+
# Remove any import of variables/index.less or _login-vars.less
|
|
166
|
+
content=$(echo "$content" | sed -E '/@import[[:space:]]+.*variables\/index\.less/d')
|
|
167
|
+
content=$(echo "$content" | sed -E '/@import[[:space:]]+.*variables\/_login-vars\.less/d')
|
|
168
|
+
|
|
169
|
+
# 1. Remove @content keyword (LESS doesn't support it)
|
|
170
|
+
# Mixins with @content need manual expansion - just remove the keyword itself
|
|
171
|
+
if echo "$content" | grep -q "@content"; then
|
|
172
|
+
if [[ $VERBOSE == true ]]; then
|
|
173
|
+
print_info "Removing @content keywords (not supported in LESS)"
|
|
174
|
+
fi
|
|
175
|
+
# Simply remove @content; lines - the mixin caller still needs manual work
|
|
176
|
+
content=$(echo "$content" | sed '/^[[:space:]]*@content;*$/d')
|
|
177
|
+
warnings="${warnings}⚠️ @content removed - mixins need manual handling in LESS\n"
|
|
178
|
+
needs_review=true
|
|
179
|
+
fi
|
|
180
|
+
|
|
181
|
+
# 2. Convert mixin definitions (before converting variables): @mixin name() → .name()
|
|
182
|
+
if [[ $VERBOSE == true ]]; then
|
|
183
|
+
print_info "Converting mixin definitions: @mixin → .name()"
|
|
184
|
+
fi
|
|
185
|
+
content=$(echo "$content" | sed -E 's/@mixin[[:space:]]+([a-zA-Z0-9_-]+)/.\1/g')
|
|
186
|
+
|
|
187
|
+
# 2. Remove SCSS module namespacing BEFORE converting @include
|
|
188
|
+
if [[ $VERBOSE == true ]]; then
|
|
189
|
+
print_info "Removing module namespacing"
|
|
190
|
+
fi
|
|
191
|
+
# Remove module prefix before dollar signs (variables): module.$var → $var
|
|
192
|
+
content=$(echo "$content" | sed -E 's/[a-zA-Z0-9_-]+\.\$/\$/g')
|
|
193
|
+
# Remove module prefix for mixin calls: @include module.mixin() → @include mixin()
|
|
194
|
+
content=$(echo "$content" | sed -E 's/@include +[a-zA-Z0-9_-]+\.([a-zA-Z0-9_-]+)/@include \1/g')
|
|
195
|
+
|
|
196
|
+
# 2b. Convert mixin includes: @include mixin() → .mixin()
|
|
197
|
+
if [[ $VERBOSE == true ]]; then
|
|
198
|
+
print_info "Converting mixin calls: @include → .mixin()"
|
|
199
|
+
fi
|
|
200
|
+
content=$(echo "$content" | sed -E 's/@include[[:space:]]+([a-zA-Z0-9_-]+)/.\1/g')
|
|
201
|
+
|
|
202
|
+
# Note: Mixin calls without parentheses will generate LESS deprecated warnings
|
|
203
|
+
# These should be manually fixed in LESS files after conversion
|
|
204
|
+
# Automatic conversion is too error-prone (matches decimals, @content, etc.)
|
|
205
|
+
|
|
206
|
+
# 3. Convert variables: $var → @var (after mixins so @mixin doesn't become @.ixin)
|
|
207
|
+
if [[ $VERBOSE == true ]]; then
|
|
208
|
+
print_info "Converting variables: \$var → @var"
|
|
209
|
+
fi
|
|
210
|
+
content=$(echo "$content" | sed -E 's/\$([a-zA-Z0-9_-]+)/@\1/g')
|
|
211
|
+
|
|
212
|
+
# 4. Convert interpolation: #{$var} → @{var}
|
|
213
|
+
if [[ $VERBOSE == true ]]; then
|
|
214
|
+
print_info "Converting interpolation: #{} → @{}"
|
|
215
|
+
fi
|
|
216
|
+
content=$(echo "$content" | sed -E 's/#\{@([a-zA-Z0-9_-]+)\}/@{\1}/g')
|
|
217
|
+
|
|
218
|
+
# 5. Convert mixin parameter separators: commas → semicolons (LESS prefers semicolons)
|
|
219
|
+
# IMPORTANT: Only convert commas that are clearly inside mixin definitions/calls, not selector commas
|
|
220
|
+
if [[ $VERBOSE == true ]]; then
|
|
221
|
+
print_info "Converting mixin parameter separators: , → ; (in mixin definitions/calls only)"
|
|
222
|
+
fi
|
|
223
|
+
|
|
224
|
+
# Strategy: Convert commas to semicolons ONLY in mixin definitions/calls
|
|
225
|
+
# This specifically targets mixin parameter lists: .mixin(@param1, @param2, @param3)
|
|
226
|
+
# But PRESERVES commas in CSS function calls: transform: translate(@x, @y)
|
|
227
|
+
#
|
|
228
|
+
# Key distinction:
|
|
229
|
+
# - Mixin definitions/calls: .name(@params) or lines starting with .
|
|
230
|
+
# - CSS property values: lines with property: value pattern
|
|
231
|
+
#
|
|
232
|
+
# Solution: Only convert commas on lines that start with . (mixin definitions/calls)
|
|
233
|
+
# This reliably identifies mixin contexts and avoids CSS property values
|
|
234
|
+
|
|
235
|
+
# Process line by line to have better context control
|
|
236
|
+
content=$(echo "$content" | perl -pe '
|
|
237
|
+
# Only process lines that start with . (after optional whitespace) - these are mixin definitions/calls
|
|
238
|
+
if (/^\s*\./) {
|
|
239
|
+
# On mixin definition/call lines, convert comma-before-@variable to semicolon-before-@variable
|
|
240
|
+
# This simpler pattern works even when default values contain commas (like rgba())
|
|
241
|
+
# because we only care about commas that are directly followed by @variable names
|
|
242
|
+
s/,(\s*@[a-zA-Z0-9_-]+)/;$1/g;
|
|
243
|
+
}
|
|
244
|
+
')
|
|
245
|
+
|
|
246
|
+
# Check if we converted @use
|
|
247
|
+
if echo "$content" | grep -q "@import.*\.less"; then
|
|
248
|
+
warnings="${warnings}⚠️ @use converted to @import - review if needed\n"
|
|
249
|
+
fi
|
|
250
|
+
|
|
251
|
+
# 6. Convert @forward to @import
|
|
252
|
+
if echo "$content" | grep -q "@forward "; then
|
|
253
|
+
if [[ $VERBOSE == true ]]; then
|
|
254
|
+
print_info "Converting @forward → @import"
|
|
255
|
+
fi
|
|
256
|
+
content=$(echo "$content" | sed -E "s/@forward[[:space:]]+(['\"])([^'\"]+)\\1/@import \\1\\2\\1/g")
|
|
257
|
+
warnings="${warnings}⚠️ @forward converted to @import - review re-exports\n"
|
|
258
|
+
needs_review=true
|
|
259
|
+
fi
|
|
260
|
+
|
|
261
|
+
# 7. Flag complex color functions for review
|
|
262
|
+
if echo "$content" | grep -qE "rgba\(@[a-zA-Z0-9_-]+,[[:space:]]*0\.[0-9]+\)"; then
|
|
263
|
+
warnings="${warnings}⚠️ rgba() with alpha detected - consider using fade() in LESS\n"
|
|
264
|
+
needs_review=true
|
|
265
|
+
fi
|
|
266
|
+
|
|
267
|
+
# 8. Convert @extend to LESS :extend() syntax
|
|
268
|
+
# SCSS: @extend .class !optional;
|
|
269
|
+
# LESS: &:extend(.class);
|
|
270
|
+
if echo "$content" | grep -q "@extend "; then
|
|
271
|
+
if [[ $VERBOSE == true ]]; then
|
|
272
|
+
print_info "Converting @extend → &:extend()"
|
|
273
|
+
fi
|
|
274
|
+
# Convert @extend .class !optional; to &:extend(.class);
|
|
275
|
+
content=$(echo "$content" | sed -E 's/^([[:space:]]*)@extend[[:space:]]+\.([a-zA-Z0-9_-]+)[[:space:]]+!optional;/\1\&:extend(.\2);/g')
|
|
276
|
+
# Convert @extend .class; to &:extend(.class);
|
|
277
|
+
content=$(echo "$content" | sed -E 's/^([[:space:]]*)@extend[[:space:]]+\.([a-zA-Z0-9_-]+);/\1\&:extend(.\2);/g')
|
|
278
|
+
# Convert @extend class !optional; to &:extend(.class); (for classes without dot)
|
|
279
|
+
content=$(echo "$content" | sed -E 's/^([[:space:]]*)@extend[[:space:]]+([a-zA-Z0-9_-]+)[[:space:]]+!optional;/\1\&:extend(.\2);/g')
|
|
280
|
+
warnings="${warnings}⚠️ @extend converted to :extend() - review output\n"
|
|
281
|
+
fi
|
|
282
|
+
|
|
283
|
+
# 9. Convert @if/@else to LESS guards
|
|
284
|
+
# SCSS: @if $var == value { ... } @else if $var == value2 { ... } @else { ... }
|
|
285
|
+
# LESS: & when (@var = value) { ... } & when (@var = value2) { ... } & when (default()) { ... }
|
|
286
|
+
if echo "$content" | grep -qE "@if |@else"; then
|
|
287
|
+
if [[ $VERBOSE == true ]]; then
|
|
288
|
+
print_info "Converting @if/@else → LESS guards"
|
|
289
|
+
fi
|
|
290
|
+
|
|
291
|
+
# Convert @else if to & when (note: after variable conversion $ → @)
|
|
292
|
+
content=$(echo "$content" | sed -E 's/^([[:space:]]*)} @else if ([^{]+)\{/\1}\n\1\& when (\2) {/g')
|
|
293
|
+
|
|
294
|
+
# Convert standalone @if to & when
|
|
295
|
+
content=$(echo "$content" | sed -E 's/^([[:space:]]*)@if ([^{]+)\{/\1\& when (\2) {/g')
|
|
296
|
+
|
|
297
|
+
# Convert @else { to & when (default()) {
|
|
298
|
+
content=$(echo "$content" | sed -E 's/^([[:space:]]*)} @else \{/\1}\n\1\& when (default()) {/g')
|
|
299
|
+
|
|
300
|
+
# Convert == to = in guards (LESS uses single =)
|
|
301
|
+
content=$(echo "$content" | sed -E 's/& when \(([^)]*) == /\& when (\1 = /g')
|
|
302
|
+
|
|
303
|
+
# Add comment about guard conversion
|
|
304
|
+
warnings="${warnings}⚠️ @if/@else converted to LESS guards - review conditional logic\n"
|
|
305
|
+
needs_review=true
|
|
306
|
+
fi
|
|
307
|
+
|
|
308
|
+
# Return results via file (since we can't return complex data from bash function)
|
|
309
|
+
echo "$content" > /tmp/scss-less-convert-content.tmp
|
|
310
|
+
echo -e "$warnings" > /tmp/scss-less-convert-warnings.tmp
|
|
311
|
+
if [[ $needs_review == true ]]; then
|
|
312
|
+
echo "1" > /tmp/scss-less-convert-needsreview.tmp
|
|
313
|
+
else
|
|
314
|
+
echo "0" > /tmp/scss-less-convert-needsreview.tmp
|
|
315
|
+
fi
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
# Function to convert a single file
|
|
319
|
+
convert_file() {
|
|
320
|
+
local scss_file="$1"
|
|
321
|
+
|
|
322
|
+
# Strip packages/style/ prefix if present
|
|
323
|
+
scss_file="${scss_file#packages/style/}"
|
|
324
|
+
|
|
325
|
+
# Check skip list for files that need manual conversion
|
|
326
|
+
if [[ -f "$SCRIPT_DIR/scss-to-less-skip" ]]; then
|
|
327
|
+
if grep -q "^${scss_file}$" "$SCRIPT_DIR/scss-to-less-skip" 2>/dev/null; then
|
|
328
|
+
print_warning "Skipping $scss_file (in skip list - requires manual sync)"
|
|
329
|
+
return 0
|
|
330
|
+
fi
|
|
331
|
+
fi
|
|
332
|
+
|
|
333
|
+
# Special case: stroke icons file uses a different conversion process
|
|
334
|
+
if [[ "$scss_file" == *"_dlt-c8y-icons-stroke.scss" ]]; then
|
|
335
|
+
print_info "Converting stroke icons file (uses special converter)"
|
|
336
|
+
if [[ $DRY_RUN == false ]]; then
|
|
337
|
+
node "$SCRIPT_DIR/convert-stroke-icons-to-less.js"
|
|
338
|
+
print_success "Stroke icons converted successfully"
|
|
339
|
+
else
|
|
340
|
+
print_info "Dry run - would run: node $SCRIPT_DIR/convert-stroke-icons-to-less.js"
|
|
341
|
+
fi
|
|
342
|
+
return 0
|
|
343
|
+
fi
|
|
344
|
+
|
|
345
|
+
# Check if file exists
|
|
346
|
+
if [[ ! -f "$scss_file" ]]; then
|
|
347
|
+
print_error "SCSS file not found: $scss_file"
|
|
348
|
+
return 1
|
|
349
|
+
fi
|
|
350
|
+
|
|
351
|
+
# Determine LESS file path
|
|
352
|
+
local less_file="${scss_file%.scss}.less"
|
|
353
|
+
|
|
354
|
+
if [[ ! -f "$less_file" ]]; then
|
|
355
|
+
print_error "Corresponding LESS file not found: $less_file"
|
|
356
|
+
return 1
|
|
357
|
+
fi
|
|
358
|
+
|
|
359
|
+
print_info "Converting: $scss_file → $less_file"
|
|
360
|
+
|
|
361
|
+
# Read SCSS content
|
|
362
|
+
local scss_content=$(cat "$scss_file")
|
|
363
|
+
|
|
364
|
+
# Convert syntax
|
|
365
|
+
convert_syntax "$scss_content"
|
|
366
|
+
|
|
367
|
+
# Read results
|
|
368
|
+
local less_content=$(cat /tmp/scss-less-convert-content.tmp)
|
|
369
|
+
local warnings=$(cat /tmp/scss-less-convert-warnings.tmp)
|
|
370
|
+
local needs_review=$(cat /tmp/scss-less-convert-needsreview.tmp)
|
|
371
|
+
|
|
372
|
+
# Clean up temp files
|
|
373
|
+
rm -f /tmp/scss-less-convert-content.tmp /tmp/scss-less-convert-warnings.tmp /tmp/scss-less-convert-needsreview.tmp
|
|
374
|
+
|
|
375
|
+
# Show warnings if any
|
|
376
|
+
if [[ -n "$warnings" && "$warnings" != "" ]]; then
|
|
377
|
+
echo ""
|
|
378
|
+
echo -e "$warnings"
|
|
379
|
+
fi
|
|
380
|
+
|
|
381
|
+
# Create temp file with new content
|
|
382
|
+
echo "$less_content" > /tmp/scss-less-new-content.tmp
|
|
383
|
+
|
|
384
|
+
# Show diff
|
|
385
|
+
echo ""
|
|
386
|
+
print_info "Changes to be applied:"
|
|
387
|
+
echo ""
|
|
388
|
+
|
|
389
|
+
# Create a colored diff
|
|
390
|
+
if command -v colordiff >/dev/null 2>&1; then
|
|
391
|
+
diff -u "$less_file" /tmp/scss-less-new-content.tmp | colordiff || true
|
|
392
|
+
else
|
|
393
|
+
diff -u "$less_file" /tmp/scss-less-new-content.tmp || true
|
|
394
|
+
fi
|
|
395
|
+
|
|
396
|
+
echo ""
|
|
397
|
+
|
|
398
|
+
# Check if there are actual changes
|
|
399
|
+
if diff -q "$less_file" /tmp/scss-less-new-content.tmp >/dev/null 2>&1; then
|
|
400
|
+
print_success "No changes needed - files already in sync"
|
|
401
|
+
rm /tmp/scss-less-new-content.tmp
|
|
402
|
+
return 0
|
|
403
|
+
fi
|
|
404
|
+
|
|
405
|
+
# Ask for confirmation (unless dry-run or auto-approve)
|
|
406
|
+
if [[ $DRY_RUN == true ]]; then
|
|
407
|
+
print_info "Dry run - no files modified"
|
|
408
|
+
rm /tmp/scss-less-new-content.tmp
|
|
409
|
+
return 0
|
|
410
|
+
fi
|
|
411
|
+
|
|
412
|
+
if [[ $AUTO_APPROVE == false ]]; then
|
|
413
|
+
if [[ $needs_review == "1" ]]; then
|
|
414
|
+
print_warning "Complex patterns detected - manual review recommended"
|
|
415
|
+
fi
|
|
416
|
+
|
|
417
|
+
echo -n "Apply these changes to $less_file? [y/N] "
|
|
418
|
+
read -r response
|
|
419
|
+
|
|
420
|
+
if [[ ! "$response" =~ ^[Yy]$ ]]; then
|
|
421
|
+
print_info "Skipped - no changes made"
|
|
422
|
+
rm /tmp/scss-less-new-content.tmp
|
|
423
|
+
return 0
|
|
424
|
+
fi
|
|
425
|
+
fi
|
|
426
|
+
|
|
427
|
+
# Apply changes
|
|
428
|
+
mv /tmp/scss-less-new-content.tmp "$less_file"
|
|
429
|
+
print_success "Converted: $less_file"
|
|
430
|
+
|
|
431
|
+
return 0
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
# Main execution
|
|
435
|
+
echo "==========================================="
|
|
436
|
+
echo "SCSS → LESS Semi-Automated Converter"
|
|
437
|
+
echo "==========================================="
|
|
438
|
+
echo ""
|
|
439
|
+
|
|
440
|
+
if [[ $CONVERT_ALL == true ]]; then
|
|
441
|
+
# Convert all modified SCSS files
|
|
442
|
+
print_info "Finding all modified SCSS files..."
|
|
443
|
+
|
|
444
|
+
SCSS_FILES=$(git diff --name-only HEAD | grep '\.scss$' || true)
|
|
445
|
+
SCSS_STAGED=$(git diff --cached --name-only | grep '\.scss$' || true)
|
|
446
|
+
ALL_SCSS=$(printf "%s\n%s" "$SCSS_FILES" "$SCSS_STAGED" | sort -u | grep -v '^$' || true)
|
|
447
|
+
|
|
448
|
+
if [[ -z "$ALL_SCSS" ]]; then
|
|
449
|
+
print_success "No modified SCSS files found"
|
|
450
|
+
exit 0
|
|
451
|
+
fi
|
|
452
|
+
|
|
453
|
+
SCSS_COUNT=$(echo "$ALL_SCSS" | wc -l | tr -d ' ')
|
|
454
|
+
print_info "Found $SCSS_COUNT modified SCSS file(s)"
|
|
455
|
+
echo ""
|
|
456
|
+
|
|
457
|
+
SUCCESS_COUNT=0
|
|
458
|
+
SKIP_COUNT=0
|
|
459
|
+
ERROR_COUNT=0
|
|
460
|
+
|
|
461
|
+
while IFS= read -r file; do
|
|
462
|
+
if [[ -z "$file" ]]; then
|
|
463
|
+
continue
|
|
464
|
+
fi
|
|
465
|
+
|
|
466
|
+
if convert_file "$file"; then
|
|
467
|
+
SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
|
|
468
|
+
else
|
|
469
|
+
ERROR_COUNT=$((ERROR_COUNT + 1))
|
|
470
|
+
fi
|
|
471
|
+
|
|
472
|
+
echo ""
|
|
473
|
+
done <<< "$ALL_SCSS"
|
|
474
|
+
|
|
475
|
+
echo "==========================================="
|
|
476
|
+
print_info "Conversion Summary:"
|
|
477
|
+
print_success "$SUCCESS_COUNT file(s) converted"
|
|
478
|
+
if [[ $ERROR_COUNT -gt 0 ]]; then
|
|
479
|
+
print_error "$ERROR_COUNT file(s) failed"
|
|
480
|
+
fi
|
|
481
|
+
echo "==========================================="
|
|
482
|
+
|
|
483
|
+
exit 0
|
|
484
|
+
|
|
485
|
+
elif [[ -n "$SCSS_FILE" ]]; then
|
|
486
|
+
# Convert single file
|
|
487
|
+
if convert_file "$SCSS_FILE"; then
|
|
488
|
+
exit 0
|
|
489
|
+
else
|
|
490
|
+
exit 1
|
|
491
|
+
fi
|
|
492
|
+
|
|
493
|
+
else
|
|
494
|
+
# No file specified
|
|
495
|
+
print_error "No file specified"
|
|
496
|
+
echo ""
|
|
497
|
+
echo "Usage: $0 [OPTIONS] <scss-file>"
|
|
498
|
+
echo " $0 --all"
|
|
499
|
+
echo ""
|
|
500
|
+
echo "Use --help for more options"
|
|
501
|
+
exit 1
|
|
502
|
+
fi
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Convert SCSS stroke icons file to LESS
|
|
5
|
+
*
|
|
6
|
+
* The SCSS version uses SCSS maps and map.get() which LESS doesn't support.
|
|
7
|
+
* This script converts it to direct LESS class definitions.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
|
|
13
|
+
const scssFile = path.join(__dirname, 'styles/icons/_dlt-c8y-icons-stroke.scss');
|
|
14
|
+
const lessFile = path.join(__dirname, 'styles/icons/_dlt-c8y-icons-stroke.less');
|
|
15
|
+
|
|
16
|
+
console.log('Converting SCSS stroke icons to LESS...');
|
|
17
|
+
|
|
18
|
+
// Read SCSS file
|
|
19
|
+
const scssContent = fs.readFileSync(scssFile, 'utf8');
|
|
20
|
+
|
|
21
|
+
// Extract the icon map
|
|
22
|
+
const mapMatch = scssContent.match(/\$dlt-c8y-icons:\s*\(([\s\S]*?)\);/);
|
|
23
|
+
if (!mapMatch) {
|
|
24
|
+
console.error('Could not find icon map in SCSS file');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Parse the map entries
|
|
29
|
+
const mapContent = mapMatch[1];
|
|
30
|
+
const iconEntries = [];
|
|
31
|
+
const lines = mapContent.split('\n');
|
|
32
|
+
|
|
33
|
+
for (const line of lines) {
|
|
34
|
+
const match = line.match(/['"]([^'"]+)['"]\s*:\s*["']([^"']+)["']/);
|
|
35
|
+
if (match) {
|
|
36
|
+
iconEntries.push({
|
|
37
|
+
name: match[1],
|
|
38
|
+
unicode: match[2]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log(`Found ${iconEntries.length} icon entries in map`);
|
|
44
|
+
|
|
45
|
+
// Extract all icon-stroke mixin calls to get the complete list
|
|
46
|
+
const mixinCalls = [];
|
|
47
|
+
const mixinCallRegex = /@include icon-stroke\(['"]([^'"]+)['"]\);/g;
|
|
48
|
+
let match;
|
|
49
|
+
while ((match = mixinCallRegex.exec(scssContent)) !== null) {
|
|
50
|
+
mixinCalls.push(match[1]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log(`Found ${mixinCalls.length} mixin calls`);
|
|
54
|
+
|
|
55
|
+
// Create a map for quick lookup
|
|
56
|
+
const iconMap = new Map();
|
|
57
|
+
for (const entry of iconEntries) {
|
|
58
|
+
iconMap.set(entry.name, entry.unicode);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Generate LESS content
|
|
62
|
+
let lessContent = `@import "../../variables/index.less";
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* DLT C8Y Icons Stroke - Stroked icon definitions (GENERATED FILE)
|
|
66
|
+
*
|
|
67
|
+
* Note: This file is auto-generated from the SCSS version by convert-stroke-icons-to-less.js
|
|
68
|
+
* DO NOT EDIT MANUALLY - Changes will be overwritten
|
|
69
|
+
*
|
|
70
|
+
* Intentionally hardcoded values:
|
|
71
|
+
* - Stroke width (2px): Icon stroke rendering
|
|
72
|
+
* - Unicode icon codes: Icon font character mappings
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
// Stroked icon styles - CONVERTED FROM SCSS
|
|
76
|
+
// Auto-converted from _dlt-c8y-icons-stroke.scss
|
|
77
|
+
// DO NOT EDIT MANUALLY - Run 'node convert-stroke-icons-to-less.js' to regenerate
|
|
78
|
+
|
|
79
|
+
// Base stroked-icon styles (applies to all icons with .stroked-icon class)
|
|
80
|
+
[class^='dlt-c8y-icon-'],
|
|
81
|
+
[class*=' dlt-c8y-icon-'] {
|
|
82
|
+
&.stroked-icon {
|
|
83
|
+
position: relative;
|
|
84
|
+
z-index: 0;
|
|
85
|
+
|
|
86
|
+
&::before {
|
|
87
|
+
position: absolute;
|
|
88
|
+
-webkit-text-stroke-width: 2px;
|
|
89
|
+
-webkit-text-stroke-color: var(--c8y-icon-stroke-color, @component-background-default);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&::after {
|
|
93
|
+
position: relative;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Individual icon definitions
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
// Generate class definitions for each icon
|
|
102
|
+
for (const iconName of mixinCalls) {
|
|
103
|
+
const unicode = iconMap.get(iconName);
|
|
104
|
+
if (unicode) {
|
|
105
|
+
lessContent += `.${iconName}.stroked-icon::after {\n content: "${unicode}";\n}\n\n`;
|
|
106
|
+
} else {
|
|
107
|
+
console.warn(`Warning: No unicode value found for ${iconName}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Write LESS file
|
|
112
|
+
fs.writeFileSync(lessFile, lessContent, 'utf8');
|
|
113
|
+
|
|
114
|
+
console.log(`✅ Successfully converted to ${lessFile}`);
|
|
115
|
+
console.log(` Generated ${mixinCalls.length} icon class definitions`);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Remove redundant variable imports from LESS files
|
|
4
|
+
# Variables are imported at entry points (main.less, branding.less, login.less),
|
|
5
|
+
# so component files don't need to import them due to LESS's global scope.
|
|
6
|
+
|
|
7
|
+
set -e
|
|
8
|
+
|
|
9
|
+
cd "$(dirname "$0")/.."
|
|
10
|
+
|
|
11
|
+
echo "=============================================="
|
|
12
|
+
echo "Removing Redundant Variable Imports"
|
|
13
|
+
echo "=============================================="
|
|
14
|
+
echo ""
|
|
15
|
+
echo "LESS uses global scope, so variables imported at entry points"
|
|
16
|
+
echo "are available to all subsequent imports. This is different from"
|
|
17
|
+
echo "SCSS's @use module system which requires explicit imports."
|
|
18
|
+
echo ""
|
|
19
|
+
|
|
20
|
+
# Find all LESS files with variable imports (excluding entry points)
|
|
21
|
+
FILES=$(grep -rl '@import.*variables/index\.less' styles --include="*.less" 2>/dev/null || true)
|
|
22
|
+
|
|
23
|
+
# Exclude entry points that SHOULD keep variable imports
|
|
24
|
+
FILES=$(echo "$FILES" | grep -v "^styles/login-app\.less$" || true)
|
|
25
|
+
FILES=$(echo "$FILES" | grep -v "^styles/_login-app\.less$" || true)
|
|
26
|
+
|
|
27
|
+
if [ -z "$FILES" ]; then
|
|
28
|
+
echo "✅ No redundant variable imports found!"
|
|
29
|
+
exit 0
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
COUNT=$(echo "$FILES" | wc -l | tr -d ' ')
|
|
33
|
+
echo "Found $COUNT file(s) with redundant variable imports:"
|
|
34
|
+
echo ""
|
|
35
|
+
echo "$FILES" | sed 's/^/ - /'
|
|
36
|
+
echo ""
|
|
37
|
+
|
|
38
|
+
read -p "Remove redundant imports from these files? [y/N] " -n 1 -r
|
|
39
|
+
echo ""
|
|
40
|
+
|
|
41
|
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
42
|
+
echo "Cancelled - no changes made"
|
|
43
|
+
exit 0
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
echo ""
|
|
47
|
+
echo "Removing redundant variable imports..."
|
|
48
|
+
echo ""
|
|
49
|
+
|
|
50
|
+
UPDATED=0
|
|
51
|
+
|
|
52
|
+
while IFS= read -r file; do
|
|
53
|
+
if [ -z "$file" ]; then
|
|
54
|
+
continue
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# Remove variable import lines
|
|
58
|
+
sed -i.bak -E '/@import[[:space:]]+.*variables\/index\.less/d' "$file"
|
|
59
|
+
|
|
60
|
+
# Check if file changed
|
|
61
|
+
if ! diff -q "$file" "$file.bak" >/dev/null 2>&1; then
|
|
62
|
+
echo " ✅ Updated: $file"
|
|
63
|
+
UPDATED=$((UPDATED + 1))
|
|
64
|
+
rm "$file.bak"
|
|
65
|
+
else
|
|
66
|
+
echo " ⏭️ Skipped (no changes): $file"
|
|
67
|
+
rm "$file.bak"
|
|
68
|
+
fi
|
|
69
|
+
done <<< "$FILES"
|
|
70
|
+
|
|
71
|
+
echo ""
|
|
72
|
+
echo "=============================================="
|
|
73
|
+
echo "✅ Updated $UPDATED file(s)"
|
|
74
|
+
echo "=============================================="
|
|
75
|
+
echo ""
|
|
76
|
+
echo "Next steps:"
|
|
77
|
+
echo "1. Run: npm test (to verify LESS/SCSS compilation)"
|
|
78
|
+
echo "2. Review changes: git diff"
|
|
79
|
+
echo "3. Commit if all looks good"
|
|
80
|
+
echo ""
|