mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-13 19:04:06 +08:00
clenaup
This commit is contained in:
parent
6ad1a6d8ba
commit
c191012022
2 changed files with 6 additions and 6 deletions
|
|
@ -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()}
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue