feat(docs/components): Implement AnimationPlayer
This commit is contained in:
parent
1be2023fe6
commit
85021f64f2
3 changed files with 63 additions and 13 deletions
|
@ -5,7 +5,7 @@ sidebar_label: Hold-Tap
|
|||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
import '@motion-canvas/player'
|
||||
import AnimationPlayer from '@site/src/components/AnimationPlayer';
|
||||
|
||||
## Summary
|
||||
|
||||
|
@ -17,21 +17,11 @@ Simply put, the hold-tap key will output the 'hold' behavior if it's held for a
|
|||
|
||||
The graph below shows how the hold-tap decides between a 'tap' and a 'hold'.
|
||||
|
||||

|
||||
|
||||
<motion-canvas-player
|
||||
src={"/animations/hold_tap_comparison.js"}
|
||||
auto={true}
|
||||
/>
|
||||
<AnimationPlayer auto small name="hold_tap_comparison" />
|
||||
|
||||
By default, the hold-tap is configured to also select the 'hold' functionality if another key is tapped while it's active:
|
||||
|
||||

|
||||
|
||||
<motion-canvas-player
|
||||
src={"/animations/hold_tap_interrupted.js"}
|
||||
auto={true}
|
||||
/>
|
||||
<AnimationPlayer auto small name="hold_tap_interrupted" />
|
||||
|
||||
We call this the 'hold-preferred' flavor of hold-taps. While this flavor may work very well for a ctrl/escape key, it's not very well suited for home-row mods or layer-taps. That's why there are two more flavors to choose from: 'tap-preferred' and 'balanced'.
|
||||
|
||||
|
|
39
docs/src/components/AnimationPlayer/index.tsx
Normal file
39
docs/src/components/AnimationPlayer/index.tsx
Normal file
|
@ -0,0 +1,39 @@
|
|||
import type { MotionCanvasPlayerProps } from "@motion-canvas/player";
|
||||
import React, { ComponentProps } from "react";
|
||||
import styles from "./styles.module.css";
|
||||
import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
|
||||
import clsx from "clsx";
|
||||
|
||||
if (ExecutionEnvironment.canUseDOM) {
|
||||
import("@motion-canvas/player");
|
||||
}
|
||||
|
||||
declare global {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
"motion-canvas-player": MotionCanvasPlayerProps & ComponentProps<"div">;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface AnimationPlayerProps {
|
||||
small?: boolean;
|
||||
auto?: boolean;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export default function AnimationPlayer({
|
||||
name,
|
||||
auto,
|
||||
small,
|
||||
}: AnimationPlayerProps) {
|
||||
return (
|
||||
<div className={clsx(styles.container, small && styles.small)}>
|
||||
<motion-canvas-player
|
||||
class={styles.player}
|
||||
src={`/animations/${name}.js`}
|
||||
auto={auto}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
21
docs/src/components/AnimationPlayer/styles.module.css
Normal file
21
docs/src/components/AnimationPlayer/styles.module.css
Normal file
|
@ -0,0 +1,21 @@
|
|||
.container {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
border-radius: var(--ifm-global-radius);
|
||||
background-color: var(--ifm-background-surface-color);
|
||||
position: relative;
|
||||
aspect-ratio: 16 / 9;
|
||||
border: 1px solid var(--ifm-color-emphasis-300);
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.container.small {
|
||||
max-width: 720px;
|
||||
aspect-ratio: 16/9;
|
||||
margin: 0 auto var(--ifm-leading);
|
||||
}
|
||||
|
||||
.player {
|
||||
aspect-ratio: 16 / 9;
|
||||
}
|
Loading…
Add table
Reference in a new issue