Skip to content

Commit

Permalink
docs: added an ability to show video demos (#437)
Browse files Browse the repository at this point in the history
## 📜 Description

Added an ability to show video as demo (before it was possible to show
only lottie - but it was expensive in terms of creation).

## 💡 Motivation and Context

Videos are much faster to create and upload/paste. So I decided to give
a try and upload a first video for selection demo (I think when people
are having visual reference - it's easier to understand how it works).

## 📢 Changelog

### Docs

- added `Video` component;
- started to use it in `useFocusedInputHandler` page;
- corrected documentation for `useFocusedInputHandler` slightly.

## 🤔 How Has This Been Tested?

Tested manually on `localhost:3000`.

## 📸 Screenshots (if appropriate):


![image](https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/bb521d2f-4b8a-4a0a-b55b-3802b317f55b)

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
  • Loading branch information
kirillzyusko committed May 10, 2024
1 parent 427c26c commit 990574c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
"ccache",
"ivar",
"objc",
"QWERT"
"QWERT",
"autoplayed"
],
"ignorePaths": [
"node_modules",
Expand Down
4 changes: 4 additions & 0 deletions docs/__tests__/screenshot.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ img[src$='.gif'],
.playwright {
display: none;
}
/* Videos are autoplayed */
.video {
display: none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ useFocusedInputHandler(
onChangeText: ({ text }) => {
"worklet";
},
onSelectionChange: ({ target, selection }) => {
"worklet";
},
},
[],
);
Expand Down Expand Up @@ -70,4 +73,8 @@ type FocusedInputSelectionChangedEvent = {
};
```

This handler can be handy when you need to have an access to input on a global level (i. e. when you don't have a direct access to your `TextInput`) or if you need to have an access to coordinates of text selection (for example to draw a custom element that follows caret position).
This handler can be handy when you need to have an access to input on a global level (i. e. when you don't have a direct access to your `TextInput`) or if you need to have an access to coordinates of text selection (for example to draw a custom element that follows caret position):

import Video from "@site/src/components/Video";

<Video src="/video/selection-demo.mov" width={60} />
26 changes: 26 additions & 0 deletions docs/src/components/Video/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import useBaseUrl from "@docusaurus/useBaseUrl";
import React from "react";

type VideoProps = {
src: string;
width?: number;
};

export default function Video({ src, width = 100, ...props }: VideoProps) {
const source = useBaseUrl(src);

return (
<div className="center video">
<video
src={source}
width={`${width}%`}
height="100%"
playsInline
autoPlay
muted
loop
{...props}
/>
</div>
);
}
8 changes: 8 additions & 0 deletions docs/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,11 @@ h3 .label {
white-space: nowrap;
width: 6px;
}

.center {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
Binary file added docs/static/video/selection-demo.mov
Binary file not shown.

0 comments on commit 990574c

Please sign in to comment.