wilday_ui 0.8.0 → 0.9.0
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.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/app/assets/builds/wilday_ui/index.js +78 -27
- data/app/assets/builds/wilday_ui/index.js.map +3 -3
- data/app/assets/stylesheets/wilday_ui/components/button/base.css +12 -0
- data/app/assets/stylesheets/wilday_ui/components/button/features/animation.css +284 -0
- data/app/assets/stylesheets/wilday_ui/components/button/features/sizes.css +36 -0
- data/app/assets/stylesheets/wilday_ui/components/button/index.css +1 -0
- data/app/helpers/wilday_ui/application_helper.rb +1 -1
- data/app/helpers/wilday_ui/components/button/button_helper.rb +348 -0
- data/app/helpers/wilday_ui/components/button/feature_engine.rb +74 -0
- data/app/helpers/wilday_ui/components/button/features/animation.rb +97 -0
- data/app/helpers/wilday_ui/components/button/features/confirm_dialog.rb +70 -0
- data/app/helpers/wilday_ui/components/button/features/copy_to_clipboard.rb +56 -0
- data/app/helpers/wilday_ui/components/button/features/dropdown.rb +74 -0
- data/app/helpers/wilday_ui/components/button/features/loading.rb +32 -0
- data/app/helpers/wilday_ui/components/button/features/tooltip.rb +138 -0
- data/app/javascript/wilday_ui/controllers/animation_controller.js +97 -0
- data/app/javascript/wilday_ui/controllers/index.js +2 -0
- data/app/javascript/wilday_ui/controllers/tooltip_controller.js +0 -33
- data/lib/wilday_ui/version.rb +1 -1
- metadata +12 -3
- data/app/helpers/wilday_ui/components/button_helper.rb +0 -672
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98a6a22d0353bcf51b1a26cc31550fe21562298385fb9b048f00c597d4102bea
|
4
|
+
data.tar.gz: 90431c125b51b0e20b8ca77bb28b4a5530235e143091cbaec60ffc3406855d49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d250424a5ecb2fb6228f1d40ec314b4d2df84e6814814cd0ba1a7cba85963197c6cd231ac8befb4afd2de3befe8eaf519562b81f00c64cdd5c0cd28f1e5b3985
|
7
|
+
data.tar.gz: 56712497f70a613b790d1b8b2455fbdd055607d4229f582cb68787936e357f5b38d35dd4fa878d2ca78062c9b2c7a22106dcfc363d533942c7da197f4119a05b
|
data/README.md
CHANGED
@@ -36,9 +36,10 @@ Place it in the `<head>` section, before your application's JavaScript:
|
|
36
36
|
<%= csrf_meta_tags %>
|
37
37
|
<%= csp_meta_tag %>
|
38
38
|
|
39
|
-
<%= w_js %> # Add this line in head
|
40
|
-
|
41
39
|
<%= stylesheet_link_tag "application" %>
|
40
|
+
<%= javascript_importmap_tags %>
|
41
|
+
|
42
|
+
<%= w_js %> # Add this line in head
|
42
43
|
</head>
|
43
44
|
<body>
|
44
45
|
<%= yield %>
|
@@ -3051,15 +3051,6 @@ var tooltip_controller_default = class extends Controller {
|
|
3051
3051
|
const arrowOffset = this.arrowValue ? 2 : 0;
|
3052
3052
|
const scrollX = window.pageXOffset || document.documentElement.scrollLeft;
|
3053
3053
|
const scrollY = window.pageYOffset || document.documentElement.scrollTop;
|
3054
|
-
console.log("=== Initial Values ===");
|
3055
|
-
console.log("Viewport Height:", viewportHeight);
|
3056
|
-
console.log("Viewport Width:", viewportWidth);
|
3057
|
-
console.log("Trigger Top:", triggerRect.top);
|
3058
|
-
console.log("Trigger Bottom:", triggerRect.bottom);
|
3059
|
-
console.log("Trigger Left:", triggerRect.left);
|
3060
|
-
console.log("Trigger Right:", triggerRect.right);
|
3061
|
-
console.log("Tooltip Height:", tooltipRect.height);
|
3062
|
-
console.log("Tooltip Width:", tooltipRect.width);
|
3063
3054
|
let position = this.positionValue;
|
3064
3055
|
let top, left;
|
3065
3056
|
const spaceBelow = viewportHeight - triggerRect.bottom;
|
@@ -3068,31 +3059,18 @@ var tooltip_controller_default = class extends Controller {
|
|
3068
3059
|
const spaceLeft = triggerRect.left;
|
3069
3060
|
const requiredSpaceVertical = tooltipRect.height + this.offsetValue + arrowOffset;
|
3070
3061
|
const requiredSpaceHorizontal = tooltipRect.width + this.offsetValue + arrowOffset;
|
3071
|
-
console.log("\n=== Space Calculation ===");
|
3072
|
-
console.log("Space Above:", spaceAbove);
|
3073
|
-
console.log("Space Below:", spaceBelow);
|
3074
|
-
console.log("Space Left:", spaceLeft);
|
3075
|
-
console.log("Space Right:", spaceRight);
|
3076
|
-
console.log("Required Space Vertical:", requiredSpaceVertical);
|
3077
|
-
console.log("Required Space Horizontal:", requiredSpaceHorizontal);
|
3078
3062
|
if (position === "right" && spaceRight >= requiredSpaceHorizontal) {
|
3079
3063
|
position = "right";
|
3080
|
-
console.log("Using right - sufficient space");
|
3081
3064
|
} else if (position === "left" && spaceLeft >= requiredSpaceHorizontal) {
|
3082
3065
|
position = "left";
|
3083
|
-
console.log("Using left - sufficient space");
|
3084
3066
|
} else if (position === "top" && spaceAbove >= requiredSpaceVertical) {
|
3085
3067
|
position = "top";
|
3086
|
-
console.log("Using top - sufficient space");
|
3087
3068
|
} else if (position === "bottom" && spaceBelow >= requiredSpaceVertical) {
|
3088
3069
|
position = "bottom";
|
3089
|
-
console.log("Using bottom - sufficient space");
|
3090
3070
|
} else if (spaceBelow >= requiredSpaceVertical) {
|
3091
3071
|
position = "bottom";
|
3092
|
-
console.log("Fallback to bottom - sufficient space");
|
3093
3072
|
} else {
|
3094
3073
|
position = "top";
|
3095
|
-
console.log("Fallback to top - insufficient space below");
|
3096
3074
|
}
|
3097
3075
|
switch (position) {
|
3098
3076
|
case "top":
|
@@ -3146,11 +3124,6 @@ var tooltip_controller_default = class extends Controller {
|
|
3146
3124
|
} else if (left + tooltipRect.width > viewportWidth) {
|
3147
3125
|
left = viewportWidth - tooltipRect.width - this.offsetValue;
|
3148
3126
|
}
|
3149
|
-
console.log("\n=== Final Position ===");
|
3150
|
-
console.log("Position:", position);
|
3151
|
-
console.log("Top:", top);
|
3152
|
-
console.log("Left:", left);
|
3153
|
-
console.log("Alignment:", this.alignValue);
|
3154
3127
|
top += scrollY;
|
3155
3128
|
left += scrollX;
|
3156
3129
|
this.tooltipElement.setAttribute("data-position", position);
|
@@ -3165,6 +3138,83 @@ var tooltip_controller_default = class extends Controller {
|
|
3165
3138
|
}
|
3166
3139
|
};
|
3167
3140
|
|
3141
|
+
// app/javascript/wilday_ui/controllers/animation_controller.js
|
3142
|
+
var animation_controller_default = class extends Controller {
|
3143
|
+
connect() {
|
3144
|
+
console.log("AnimationController connected");
|
3145
|
+
this.setupAnimation();
|
3146
|
+
}
|
3147
|
+
setupAnimation() {
|
3148
|
+
const animationData = JSON.parse(this.element.dataset.animation || "{}");
|
3149
|
+
if (!animationData.name) return;
|
3150
|
+
const {
|
3151
|
+
name,
|
3152
|
+
trigger,
|
3153
|
+
duration = 0.3,
|
3154
|
+
timing = "ease",
|
3155
|
+
delay = 0,
|
3156
|
+
// Add default value here
|
3157
|
+
iteration = 1,
|
3158
|
+
direction = "normal",
|
3159
|
+
fill_mode = "none",
|
3160
|
+
properties
|
3161
|
+
} = animationData;
|
3162
|
+
this.element.style.setProperty("--animation-name", name);
|
3163
|
+
this.element.style.setProperty("--animation-duration", `${duration}s`);
|
3164
|
+
this.element.style.setProperty("--animation-delay", `${delay}s`);
|
3165
|
+
this.element.style.setProperty(
|
3166
|
+
"--animation-timing",
|
3167
|
+
this.getTimingFunction(timing, properties)
|
3168
|
+
);
|
3169
|
+
this.element.style.setProperty(
|
3170
|
+
"--animation-iteration",
|
3171
|
+
iteration === "infinite" ? "infinite" : iteration || 1
|
3172
|
+
);
|
3173
|
+
this.element.style.setProperty(
|
3174
|
+
"--animation-direction",
|
3175
|
+
direction.replace(/_/g, "-")
|
3176
|
+
);
|
3177
|
+
this.element.style.setProperty(
|
3178
|
+
"--animation-fill-mode",
|
3179
|
+
fill_mode.replace(/_/g, "-")
|
3180
|
+
);
|
3181
|
+
if (properties && name === "custom") {
|
3182
|
+
Object.entries(properties).forEach(([key, value]) => {
|
3183
|
+
this.element.style.setProperty(`--animation-custom-${key}`, value);
|
3184
|
+
});
|
3185
|
+
}
|
3186
|
+
if (trigger === "click") {
|
3187
|
+
this.element.addEventListener("click", () => this.animate());
|
3188
|
+
} else if (trigger === "load") {
|
3189
|
+
this.animate();
|
3190
|
+
}
|
3191
|
+
}
|
3192
|
+
animate() {
|
3193
|
+
const animationData = JSON.parse(this.element.dataset.animation || "{}");
|
3194
|
+
if (!animationData.name) return;
|
3195
|
+
this.element.classList.remove("is-animating");
|
3196
|
+
void this.element.offsetWidth;
|
3197
|
+
this.element.classList.add("is-animating");
|
3198
|
+
}
|
3199
|
+
getTimingFunction(timing, properties) {
|
3200
|
+
if (!timing) return "ease";
|
3201
|
+
if (timing === "cubic_bezier" && properties?.cubic_bezier) {
|
3202
|
+
const [x1, y1, x2, y2] = properties.cubic_bezier;
|
3203
|
+
return `cubic-bezier(${x1}, ${y1}, ${x2}, ${y2})`;
|
3204
|
+
}
|
3205
|
+
return timing.replace(/_/g, "-");
|
3206
|
+
}
|
3207
|
+
disableAfterAnimation() {
|
3208
|
+
const animationConfig = JSON.parse(this.element.dataset.animation || "{}");
|
3209
|
+
if (!animationConfig.disabled) return;
|
3210
|
+
const duration = parseFloat(this.element.style.getPropertyValue("--animation-duration")) * 1e3;
|
3211
|
+
const delay = parseFloat(this.element.style.getPropertyValue("--animation-delay")) * 1e3;
|
3212
|
+
setTimeout(() => {
|
3213
|
+
this.element.disabled = true;
|
3214
|
+
}, duration + delay);
|
3215
|
+
}
|
3216
|
+
};
|
3217
|
+
|
3168
3218
|
// app/javascript/wilday_ui/controllers/index.js
|
3169
3219
|
var application = Application.start();
|
3170
3220
|
window.Stimulus = application;
|
@@ -3173,6 +3223,7 @@ application.register("dropdown", dropdown_controller_default);
|
|
3173
3223
|
application.register("clipboard", clipboard_controller_default);
|
3174
3224
|
application.register("confirmation", confirmation_controller_default);
|
3175
3225
|
application.register("tooltip", tooltip_controller_default);
|
3226
|
+
application.register("animation", animation_controller_default);
|
3176
3227
|
|
3177
3228
|
// app/javascript/wilday_ui/components/button.js
|
3178
3229
|
document.addEventListener("DOMContentLoaded", () => {
|