@massimo-cassandro/minimo 1.15.0 → 1.15.1

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.
@@ -1,5 +1,11 @@
1
1
  #!/bin/zsh
2
2
 
3
+ # Questo script richiede zsh: se lanciato con sh/bash blocca l'esecuzione
4
+ if [ -z "$ZSH_VERSION" ]; then
5
+ echo "Errore: lanciare con 'zsh starter-install.sh', non con sh/bash." >&2
6
+ exit 1
7
+ fi
8
+
3
9
  # Configurazione variabili
4
10
  # BASE_URL="https://raw.githubusercontent.com/massimo-cassandro/minimo/refs/heads/main"
5
11
 
@@ -24,33 +30,38 @@ NC='\033[0m' # No Color
24
30
  # protezione contro la sovrascrittura
25
31
  set -C
26
32
 
27
- # Array per tracciare le copie bloccati
33
+ # Array per tracciare i file già esistenti
28
34
  BLOCKED_FILES=()
29
35
 
30
- # Wrapper: copia solo se il file non esiste, altrimenti registra il blocco
36
+ # Wrapper: copia solo se il file non esiste, altrimenti registra il blocco.
37
+ # Con terzo argomento "new", se la destinazione esiste già la copia viene
38
+ # comunque creata con prefisso NEW- (da integrare manualmente o rimuovere)
31
39
  safe_cat() {
32
40
  local src="$1"
33
41
  local dest="$2"
42
+ local mode="$3"
43
+ if [ ! -f "$src" ]; then
44
+ echo -e "${RED}Sorgente mancante: $src${NC}"
45
+ return 1
46
+ fi
34
47
  if [ -e "$dest" ]; then
35
- BLOCKED_FILES+=("$dest")
48
+ if [ "$mode" = "new" ]; then
49
+ local new_dest="$(dirname "$dest")/NEW-$(basename "$dest")"
50
+ cat "$src" >| "$new_dest"
51
+ BLOCKED_FILES+=("$dest → copiato come $new_dest")
52
+ else
53
+ BLOCKED_FILES+=("$dest")
54
+ fi
36
55
  else
37
56
  cat "$src" > "$dest"
38
57
  fi
39
58
  }
40
59
 
41
60
  echo -e "${GREEN}...package.json${NC}"
42
- if [ ! -f package.json ]; then
43
- safe_cat "${TEMPLATES_DIR}/package-tpl.json" package.json
44
- else
45
- echo -e "${GREEN}package.json already exists${NC}"
46
- fi
61
+ safe_cat "${TEMPLATES_DIR}/package-tpl.json" package.json new
47
62
 
48
63
  echo -e "${GREEN}...gitignore${NC}"
49
- if [ ! -f .gitignore ]; then
50
- safe_cat "${TEMPLATES_DIR}/_gitignore" .gitignore
51
- else
52
- echo -e "${GREEN}.gitignore already exists${NC}"
53
- fi
64
+ safe_cat "${TEMPLATES_DIR}/_gitignore" .gitignore new
54
65
 
55
66
  echo -e "\n${GREEN}Where do you want to install the frontend configuration?${NC}"
56
67
  echo "1) Root directory"
@@ -73,20 +84,20 @@ fi
73
84
 
74
85
  echo -e "\n${GREEN}...config files & utilities${NC}"
75
86
 
76
- safe_cat "${TEMPLATES_DIR}/_browserslistrc" .browserslistrc
77
- safe_cat "${TEMPLATES_DIR}/_editorconfig" .editorconfig
78
- safe_cat "${TEMPLATES_DIR}/_prettierrc" .prettierrc
79
- safe_cat "${TEMPLATES_DIR}/jsconfig.json" jsconfig.json
80
- safe_cat "${TEMPLATES_DIR}/__project__.code-workspace" __project__.code-workspace
87
+ safe_cat "${TEMPLATES_DIR}/_browserslistrc" .browserslistrc new
88
+ safe_cat "${TEMPLATES_DIR}/_editorconfig" .editorconfig new
89
+ safe_cat "${TEMPLATES_DIR}/_prettierrc" .prettierrc new
90
+ safe_cat "${TEMPLATES_DIR}/jsconfig.json" jsconfig.json new
91
+ safe_cat "${TEMPLATES_DIR}/__project__.code-workspace" __project__.code-workspace new
81
92
 
82
93
 
83
94
  echo -e "\n${GREEN}...eslint${NC}"
84
95
  npm i -D @massimo-cassandro/eslint-config
85
- safe_cat "${TEMPLATES_DIR}/eslint.config.mjs" eslint.config.mjs
96
+ safe_cat "${TEMPLATES_DIR}/eslint.config.mjs" eslint.config.mjs new
86
97
 
87
98
  echo -e "\n${GREEN}...stylelint${NC}"
88
99
  npm i -D @massimo-cassandro/stylelint-config
89
- safe_cat "${TEMPLATES_DIR}/stylelint.config.mjs" stylelint.config.mjs
100
+ safe_cat "${TEMPLATES_DIR}/stylelint.config.mjs" stylelint.config.mjs new
90
101
 
91
102
  echo -e "\n${GREEN}...webpack${NC}"
92
103
  npm i -D webpack-cli webpack-dev-server webpack-manifest-plugin webpack
@@ -117,15 +128,19 @@ FILES=(
117
128
  'postcss.config.mjs'
118
129
  )
119
130
 
120
- if [ ! -d "$WEBPACK_LOCAL_DIR" ]; then
121
- mkdir -p "$WEBPACK_LOCAL_DIR"
131
+ # se la cartella esiste già, i moduli vengono copiati in NEW-webpack-modules
132
+ # (da integrare manualmente o rimuovere)
133
+ if [ -d "$WEBPACK_LOCAL_DIR" ]; then
134
+ NEW_WEBPACK_LOCAL_DIR="$(dirname "$WEBPACK_LOCAL_DIR")/NEW-$(basename "$WEBPACK_LOCAL_DIR")"
135
+ BLOCKED_FILES+=("$WEBPACK_LOCAL_DIR → copiata come $NEW_WEBPACK_LOCAL_DIR")
136
+ WEBPACK_LOCAL_DIR="$NEW_WEBPACK_LOCAL_DIR"
137
+ fi
122
138
 
123
- for FILE in "${FILES[@]}"; do
124
- # echo "Scaricamento di $FILE..."
125
- safe_cat "${WEBPACK_MODULES_REMOTE_URL}/${FILE}" "${WEBPACK_LOCAL_DIR}/${FILE}"
126
- done
139
+ mkdir -p "$WEBPACK_LOCAL_DIR"
127
140
 
128
- fi
141
+ for FILE in "${FILES[@]}"; do
142
+ safe_cat "${WEBPACK_MODULES_REMOTE_URL}/${FILE}" "${WEBPACK_LOCAL_DIR}/${FILE}"
143
+ done
129
144
 
130
145
  echo -e "\n${GREEN}Creating a template of your frontend application's folder structured${NC}"
131
146
 
@@ -136,9 +151,9 @@ mkdir -p error-pages imgs icons src src/css favicons design-tokens
136
151
  cd ..
137
152
  set +C
138
153
 
139
- # Riepilogo finale dei file bloccati
154
+ # Riepilogo finale dei file già esistenti
140
155
  if [ ${#BLOCKED_FILES[@]} -gt 0 ]; then
141
- echo -e "\n${YELLOW}*** File non copiati (già esistenti): ***${NC}"
156
+ echo -e "\n${YELLOW}*** File già esistenti (non copiati o copiati con prefisso NEW-): ***${NC}"
142
157
  for F in "${BLOCKED_FILES[@]}"; do
143
158
  echo -e "${YELLOW} ✗ $F${NC}"
144
159
  done
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massimo-cassandro/minimo",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -15,6 +15,7 @@ References
15
15
 
16
16
  // TODO snackbar action
17
17
  // TODO handle multiple simultaneous snackbars (no stacking)
18
+ // TODO test con prefers-reduced-motion
18
19
 
19
20
  /**
20
21
  * Displays a snackbar / toast notification using the Popover API.
@@ -53,12 +54,22 @@ export function snackbar(message, options = {}){
53
54
 
54
55
  if (_timeoutID) clearTimeout(_timeoutID);
55
56
 
56
- _popover?.classList.add(styles.isHiding);
57
-
58
- _popover?.addEventListener('animationend', () => {
57
+ const remove = () => {
59
58
  _popover?.hidePopover();
60
59
  _popover?.remove();
61
- }, { once: true }); // 'once' prevents duplicate listeners; the flag guards against calls before animation ends
60
+ };
61
+
62
+ _popover?.classList.add(styles.isHiding);
63
+
64
+ // with `prefers-reduced-motion` (or any override disabling animations) no animation
65
+ // runs and `animationend` would never fire: in that case remove immediately
66
+ if (_popover?.getAnimations().length) {
67
+ // 'once' prevents duplicate listeners; the flag guards against calls before animation ends
68
+ _popover.addEventListener('animationend', remove, { once: true });
69
+ }
70
+ else {
71
+ remove();
72
+ }
62
73
  };
63
74
 
64
75
  _popover = domBuilder([