This commit is contained in:
Christian Fehmer 2026-01-08 19:13:17 +01:00
parent 6ad1a6d8ba
commit c191012022
No known key found for this signature in database
GPG key ID: A567394D76EBDD7C
2 changed files with 6 additions and 6 deletions

View file

@ -1,13 +1,15 @@
import { Accessor, JSXElement } from "solid-js";
import { VisibleDirectiveProps } from "../types/solid-directives";
import { visible } from "../utils/solid-visible";
// oxlint-disable-next-line no-unused-expressions no-constant-binary-expression
false && visible; // Prevents tree-shaking
export function LiveCounter(props: {
value: Accessor<string>;
visible?: VisibleDirectiveProps;
class?: string;
}): JSXElement {
console.log("### counter", { visible: props.visible?.() });
return (
<div class={props.class} use:visible={props.visible}>
{props.value()}

View file

@ -1,20 +1,18 @@
import { createEffect } from "solid-js";
import { Accessor, createEffect } from "solid-js";
import { ElementWithUtils } from "./dom";
import { applyReducedMotion } from "./misc";
import { isFocused } from "../test/focus";
import { VisibleDirectiveProps } from "../types/solid-directives";
export function visible(
el: HTMLElement,
accessorWrapper: () => VisibleDirectiveProps,
accessorWrapper: Accessor<VisibleDirectiveProps>,
): void {
const divUtil = new ElementWithUtils(el);
createEffect(() => {
const focused = isFocused();
const state = accessorWrapper()();
if (state.value && focused) {
if (state.value) {
if (state.withAnimation) {
divUtil.animate({
opacity: [0, 1],