Skip to content

Commit

Permalink
Added searchPlaceholder prop to config, as an alternative to `searc…
Browse files Browse the repository at this point in the history
…hPlaceHolder`.
  • Loading branch information
talisraeli authored and ealush committed Aug 29, 2023
1 parent 626b827 commit 5cc46f4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.4.11",
"version": "4.4.12",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
6 changes: 5 additions & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {

const KNOWN_FAILING_EMOJIS = ['2640-fe0f', '2642-fe0f', '2695-fe0f'];

export const DEFAULT_SEARCH_PLACEHOLDER = 'Search';

export function mergeConfig(
userConfig: PickerConfig = {}
): PickerConfigInternal {
Expand Down Expand Up @@ -66,7 +68,8 @@ export function basePickerConfig(): PickerConfigInternal {
...basePreviewConfig
},
searchDisabled: false,
searchPlaceHolder: 'Search',
searchPlaceHolder: DEFAULT_SEARCH_PLACEHOLDER,
searchPlaceholder: DEFAULT_SEARCH_PLACEHOLDER,
skinTonePickerLocation: SkinTonePickerLocation.SEARCH,
skinTonesDisabled: false,
suggestedEmojisMode: SuggestionMode.FREQUENT,
Expand All @@ -79,6 +82,7 @@ export function basePickerConfig(): PickerConfigInternal {
export type PickerConfigInternal = {
emojiVersion: string | null;
searchPlaceHolder: string;
searchPlaceholder: string;
defaultSkinTone: SkinTones;
skinTonesDisabled: boolean;
autoFocusSearch: boolean;
Expand Down
14 changes: 11 additions & 3 deletions src/config/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ import {
} from '../types/exposedTypes';

import { CategoriesConfig } from './categoryConfig';
import { PickerDimensions, PreviewConfig } from './config';
import {
DEFAULT_SEARCH_PLACEHOLDER,
PickerDimensions,
PreviewConfig,
} from './config';

export function useSearchPlaceHolderConfig(): string {
const { searchPlaceHolder } = usePickerConfig();
return searchPlaceHolder;
const { searchPlaceHolder, searchPlaceholder } = usePickerConfig();
return (
[searchPlaceHolder, searchPlaceholder].find(
(p) => p !== DEFAULT_SEARCH_PLACEHOLDER
) ?? DEFAULT_SEARCH_PLACEHOLDER
);
}

export function useDefaultSkinToneConfig(): SkinTones {
Expand Down
18 changes: 10 additions & 8 deletions stories/picker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const EmojiImageTwitter = (args: Props) => (
<Template {...args} emojiStyle={EmojiStyle.TWITTER} />
);
export const CustomSearchPlaceholder = (args: Props) => (
<Template searchPlaceHolder="👀 Find" />
<Template searchPlaceholder="👀 Find" />
);
export const SkinTonesDisabled = (args: Props) => (
<Template {...args} skinTonesDisabled />
Expand Down Expand Up @@ -172,16 +172,18 @@ export const StandaloneEmojiNative = () => {
return <Emoji unified="1f60a" emojiStyle={EmojiStyle.NATIVE} size={35} />;
};
export const CustomUnifiedEmojiImage = () => {
const [unified, setUnified] = useState("1f9d1-1f3ff-200d-1f4bc");
const [unified, setUnified] = useState('1f9d1-1f3ff-200d-1f4bc');

return <>
<Emoji unified={unified} size={35} />
<input onChange={(e) => setUnified(e.target.value)} value={unified} />
</>
}
return (
<>
<Emoji unified={unified} size={35} />
<input onChange={e => setUnified(e.target.value)} value={unified} />
</>
);
};

export const HideEmojisByUnicode = (args: Props) => (
<Template {...args} emojiStyle={EmojiStyle.NATIVE} />
<Template {...args} emojiStyle={EmojiStyle.NATIVE} />
);

function TemplateDark(args) {
Expand Down

0 comments on commit 5cc46f4

Please sign in to comment.