Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/client/components/ui/components/design/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Show, createRenderEffect, on, splitProps } from "solid-js";
import { Show, createRenderEffect, mergeProps, on, splitProps } from "solid-js";
import { JSX } from "solid-js/jsx-runtime";

import { AriaButtonProps, createButton } from "@solid-aria/button";
import { cva } from "styled-system/css/cva";

import { debounce } from "@revolt/common";
Comment thread
Pecacheu marked this conversation as resolved.

import { Ripple } from "./Ripple";
import { typography } from "./Text";

Expand Down Expand Up @@ -118,11 +120,18 @@ export function Button(props: Props) {
),
);

const { buttonProps } = createButton(rest, () => ref);
const [btn, noBtnRest] = splitProps(rest, ["onPress"]);

// eslint-disable-next-line @typescript-eslint/no-explicit-any, solid/reactivity
Comment thread
Pecacheu marked this conversation as resolved.
const onPress = debounce((e: any) => btn.onPress?.(e), 100),
btnRest = mergeProps(noBtnRest, { onPress });

const { buttonProps } = createButton(btnRest, () => ref);
return (
<button
{...passthrough}
{...buttonProps}
onTouchEnd={onPress}
ref={ref}
class={button({
shape: shape(),
Expand Down
13 changes: 11 additions & 2 deletions packages/client/components/ui/components/design/IconButton.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Show, splitProps } from "solid-js";
import { mergeProps, Show, splitProps } from "solid-js";
import { JSX } from "solid-js/jsx-runtime";

import { AriaButtonProps, createButton } from "@solid-aria/button";
import { cva } from "styled-system/css/cva";

import { debounce } from "@revolt/common";

import { Ripple } from "./Ripple";
import { typography } from "./Text";

Expand Down Expand Up @@ -39,11 +41,18 @@ export function IconButton(props: Props) {
]);
let ref: HTMLButtonElement | undefined;

const { buttonProps } = createButton(rest, () => ref);
const [btn, noBtnRest] = splitProps(rest, ["onPress"]);

// eslint-disable-next-line @typescript-eslint/no-explicit-any, solid/reactivity
const onPress = debounce((e: any) => btn.onPress?.(e), 100),
restBtn = mergeProps(noBtnRest, { onPress });

const { buttonProps } = createButton(restBtn, () => ref);
return (
<button
{...passthrough}
{...buttonProps}
onTouchEnd={onPress}
ref={ref}
class={iconButton2({
...style,
Expand Down
Loading