diff --git a/docs/assets/img/custom-button-preview-1.png b/docs/assets/img/custom-button-preview-1.png new file mode 100644 index 00000000..4058706f Binary files /dev/null and b/docs/assets/img/custom-button-preview-1.png differ diff --git a/docs/assets/img/custom-button-preview-2.png b/docs/assets/img/custom-button-preview-2.png new file mode 100644 index 00000000..f160b76c Binary files /dev/null and b/docs/assets/img/custom-button-preview-2.png differ diff --git a/docs/assets/img/custom-button-preview-3.png b/docs/assets/img/custom-button-preview-3.png new file mode 100644 index 00000000..68694001 Binary files /dev/null and b/docs/assets/img/custom-button-preview-3.png differ diff --git a/docs/docs/api/modal.md b/docs/docs/api/modal.md index 9f81d1b9..d5039b62 100644 --- a/docs/docs/api/modal.md +++ b/docs/docs/api/modal.md @@ -111,6 +111,18 @@ Reveal the search bar, used to find specific emoji. +### `hideSearchBarClearIcon` + +Hide the search bar clear icon inside the search input. + + + +### `customButtons` + +Inject custom buttons into the component. + + + ### `enableCategoryChangeAnimation` Allow to turn off FlatList scrolling animation when category is changed. diff --git a/docs/docs/documentation/Examples/custom-buttons.mdx b/docs/docs/documentation/Examples/custom-buttons.mdx new file mode 100644 index 00000000..98b5268d --- /dev/null +++ b/docs/docs/documentation/Examples/custom-buttons.mdx @@ -0,0 +1,63 @@ +--- +sidebar_position: 13 +title: Custom Buttons +--- + +import preview1 from '../../../assets/img/custom-button-preview-1.png' +import preview2 from '../../../assets/img/custom-button-preview-2.png' +import preview3 from '../../../assets/img/custom-button-preview-3.png' + +:::info +To preview app with this example, clone [**github repo**](https://github.com/TheWidlarzGroup/rn-emoji-keyboard.git) and run `yarn example ios` or `yarn example android`. +::: + +### Usage + +We've introduced a custom button feature to provide you with the flexibility to add your unique functionality to our interface. + +The `customButtons` prop allows you to inject custom buttons into the `EmojiPicker` component, enabling additional functionalities or actions within the emoji picker interface. This flexible prop accepts an array of React elements, allowing for multiple custom buttons to be specified. + +To use the `customButtons` prop, pass an array of React components that you wish to render as buttons within the emoji picker. Each component must be assigned a unique key prop to help React identify which items have changed, are being added, or are removed. + +If search bar is enabled, custom buttons shows next to it. + +The `DeleteButton` is a pre-designed component that can be used within the `EmojiPicker` as part of the customButtons prop array. You can add `onPress` prop with a function that will be called when the DeleteButton is pressed. This allows you to define the specific action that should occur on press, such as deleting an emoji from the input field. +. You can add any pressableProps you need to this custom component. + +```jsx +import EmojiPicker from 'rn-emoji-keyboard' + +const ExampleComponent = () => { + // ... + + return ( + setIsModalOpen(false)} + enableSearchBar + customButtons={[ + ({ + backgroundColor: pressed ? '#000' : '#e1e1e1', + padding: 10, + borderRadius: 100, + })} + iconNormalColor="#000" + iconActiveColor="#fff" + />, + ]} + allowMultipleSelections + categoryPosition="top" + /> + ) +} +``` + +
+ First Image + Second Image + Third Image +
diff --git a/docs/docs/documentation/Examples/dark.md b/docs/docs/documentation/Examples/dark.md index ac55f3b0..f28afa64 100644 --- a/docs/docs/documentation/Examples/dark.md +++ b/docs/docs/documentation/Examples/dark.md @@ -6,7 +6,7 @@ title: Dark Mode We do not provide a prop that will directly enable dark mode, but with the ability to adjust theme, you can easily achieve it using theme prop. -```tsx +```jsx setIsModalOpen(false)} + theme={{ + backdrop: '#16161888', + knob: '#766dfc', + container: '#282829', + header: '#fff', + skinTonesContainer: '#252427', + category: { + icon: '#766dfc', + iconActive: '#fff', + container: '#252427', + containerActive: '#766dfc', + }, + customButton: { + icon: '#766dfc', + iconPressed: '#fff', + background: '#252427', + backgroundPressed: '#766dfc', + }, + search: { + text: '#fff', + placeholder: '#ffffff2c', + icon: '#fff', + background: '#00000011', + }, + }} +/> +``` diff --git a/docs/docs/documentation/Examples/search.md b/docs/docs/documentation/Examples/search.md index 9d93077a..fa8d4014 100644 --- a/docs/docs/documentation/Examples/search.md +++ b/docs/docs/documentation/Examples/search.md @@ -11,6 +11,8 @@ To preview app with this example, clone [**github repo**](https://github.com/The If you want to reveal the search bar, used to find specific emoji, just pass `enableSearchBar` to `EmojiPicker`. +You can also choose whether to display the search bar clear icon (which appears when you type something in search input). To hide this icon, pass the `hideSearchBarClearIcon` prop to `EmojiPicker`. + ```jsx import EmojiPicker from 'rn-emoji-keyboard' diff --git a/docs/src/css/custom.css b/docs/src/css/custom.css index 239f26d2..637394d2 100644 --- a/docs/src/css/custom.css +++ b/docs/src/css/custom.css @@ -46,3 +46,34 @@ font-weight: 700; src: local('JetBrainsMono'), url(../../assets/fonts/JetBrainsMono-Bold.woff2) format('woff2'); } + +.gallery { + display: flex; + justify-content: space-between; + align-items: center; + flex-direction: row; +} + +.gallery img { + width: 32%; + margin-right: 2%; +} + +.gallery img:last-child { + margin-right: 0; +} + +@media (max-width: 768px) { + .gallery { + flex-direction: column; + } + .gallery img { + width: 100%; + margin-right: 0px; + margin-bottom: 20px; + } + + .gallery img:last-child { + margin-right: 0; + } +} diff --git a/example/app/(examples)/custom-buttons.tsx b/example/app/(examples)/custom-buttons.tsx new file mode 100644 index 00000000..b1c343b1 --- /dev/null +++ b/example/app/(examples)/custom-buttons.tsx @@ -0,0 +1,53 @@ +import { Button } from 'example/src/components/Button' +import React from 'react' +import { Results } from 'example/src/components/Results' +import EmojiPicker, { type EmojiType } from 'rn-emoji-keyboard' +import { DeleteButton } from '../../../src/components/DeleteButton' + +export default function () { + const [result, setResult] = React.useState() + const [isModalOpen, setIsModalOpen] = React.useState(false) + + const handlePick = (emoji: EmojiType) => { + console.log(emoji) + setResult(emoji.emoji) + setIsModalOpen((prev) => !prev) + } + + const deleteLastEmoji = () => { + if (result) { + let arrayFromString = Array.from(result) + arrayFromString.pop() + setResult(arrayFromString.join('')) + } + } + + return ( + <> + +