@remotion/design 4.0.373 → 4.0.375

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.
package/dist/Button.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
2
  export declare const Button: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & {
3
3
  readonly depth?: number;
4
+ readonly loading?: boolean;
4
5
  }>;
package/dist/Button.js CHANGED
@@ -1,12 +1,13 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useRef, useState } from 'react';
3
3
  import { cn } from './helpers/cn';
4
4
  import { useHoverTransforms } from './helpers/hover-transforms';
5
5
  import { Outer } from './helpers/Outer';
6
- export const Button = ({ children, className, disabled, depth, ...buttonProps }) => {
6
+ import { Spinner } from './Spinner';
7
+ export const Button = ({ children, className, disabled, depth, loading, ...buttonProps }) => {
7
8
  const [dimensions, setDimensions] = useState(null);
8
9
  const ref = useRef(null);
9
- const { isActive, progress } = useHoverTransforms(ref, Boolean(disabled));
10
+ const { isActive, progress } = useHoverTransforms(ref, Boolean(disabled || loading));
10
11
  const onPointerEnter = useCallback((e) => {
11
12
  if (e.pointerType !== 'mouse') {
12
13
  return;
@@ -43,6 +44,6 @@ export const Button = ({ children, className, disabled, depth, ...buttonProps })
43
44
  };
44
45
  });
45
46
  }, []);
46
- const content = (_jsx("button", { type: "button", disabled: disabled, className: cn('text-text', 'flex', 'justify-center', 'bg-button-bg', 'items-center', 'font-brand', 'border-solid', 'text-[1em]', 'rounded-lg', 'border-black', 'border-2', 'border-b-4', 'cursor-pointer', 'px-4', 'h-12', 'flex', 'flex-row', 'items-center', 'disabled:cursor-default', 'disabled:border-gray-500', 'disabled:text-gray-500', className), ...buttonProps, children: children }));
47
+ const content = (_jsxs("button", { type: "button", disabled: disabled || loading, className: cn('text-text', 'flex', 'justify-center', 'bg-button-bg', 'items-center', 'font-brand', 'border-solid', 'text-[1em]', 'rounded-lg', 'border-black', 'border-2', 'border-b-4', 'cursor-pointer', 'px-4', 'h-12', 'flex', 'flex-row', 'items-center', 'disabled:cursor-default', 'disabled:opacity-50', 'relative', 'overflow-hidden', className), ...buttonProps, children: [_jsx("div", { className: cn(loading && 'invisible', 'inline-flex'), children: children }), loading ? (_jsx("div", { className: cn('absolute w-full h-full flex inset-0 items-center justify-center text-inherit bg-inherit'), children: _jsx(Spinner, { size: 20, duration: 1 }) })) : null] }));
47
48
  return (_jsx("div", { ref: ref, className: "contents", onPointerEnter: onPointerEnter, children: dimensions && (isActive || progress > 0) ? (_jsx(Outer, { parentRef: ref, width: dimensions.width, height: dimensions.height, cornerRadius: dimensions.borderRadius, hoverTransform: progress, depthFactor: depth ?? 1, children: content })) : (content) }));
48
49
  };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
3
+ export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
4
+ export {};
package/dist/Input.js ADDED
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { cn } from './helpers/cn';
4
+ export const Input = React.forwardRef(({ className, ...props }, ref) => {
5
+ return (_jsx("input", { ref: ref, className: cn('w-full dark:bg-[#121212] rounded-lg border-2 border-b-4 border-black outline-none h-14 px-3 fontbrand text-lg box-border', className), ...props }));
6
+ });
7
+ Input.displayName = 'Input';
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const Spinner: React.FC<{
3
+ readonly size: number;
4
+ readonly duration: number;
5
+ }>;
@@ -0,0 +1,45 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef } from 'react';
3
+ const viewBox = 100;
4
+ const lines = 8;
5
+ // Generated from https://github.com/remotion-dev/template-next/commit/9282c93f7c51ada31a42e18a94680fa09a14eee3
6
+ const translated = 'M 44 0 L 50 0 a 6 6 0 0 1 6 6 L 56 26 a 6 6 0 0 1 -6 6 L 50 32 a 6 6 0 0 1 -6 -6 L 44 6 a 6 6 0 0 1 6 -6 Z';
7
+ export const Spinner = ({ size, duration }) => {
8
+ const style = useMemo(() => {
9
+ return {
10
+ width: size,
11
+ height: size,
12
+ };
13
+ }, [size]);
14
+ const pathsRef = useRef([]);
15
+ useEffect(() => {
16
+ const animate = () => {
17
+ const now = performance.now();
18
+ for (let index = 0; index < lines; index++) {
19
+ const path = pathsRef.current[index];
20
+ if (!path)
21
+ continue;
22
+ // Calculate current opacity using the same animation as before
23
+ const progress = ((now / 1000 - index * (duration / lines)) % duration) / duration;
24
+ // Animation: opacity 1 → 0.15
25
+ const opacity = 1 - 0.85 * progress;
26
+ path.style.opacity = opacity.toString();
27
+ }
28
+ requestAnimationFrame(animate);
29
+ };
30
+ const id = requestAnimationFrame(animate);
31
+ return () => {
32
+ cancelAnimationFrame(id);
33
+ };
34
+ }, [duration]);
35
+ return (_jsx("svg", { style: style, viewBox: `0 0 ${viewBox} ${viewBox}`, children: new Array(lines).fill(true).map((_, index) => {
36
+ return (_jsx("path", {
37
+ // @ts-expect-error
38
+ // eslint-disable-next-line no-return-assign
39
+ ref: (el) => (pathsRef.current[index] = el), style: {
40
+ rotate: `${(index * Math.PI * 2) / lines}rad`,
41
+ transformOrigin: 'center center',
42
+ opacity: 1,
43
+ }, d: translated, fill: 'currentColor' }, index));
44
+ }) }));
45
+ };