feat: placeholder adapts to the public state

This commit is contained in:
JimmFly
2022-12-23 16:34:25 +08:00
parent 0014a69da0
commit b8a521342c
4 changed files with 10 additions and 4 deletions
@@ -8,6 +8,7 @@ import React, {
import { SearchIcon } from '@blocksuite/icons';
import { StyledInputContent, StyledLabel } from './style';
import { Command } from 'cmdk';
import { useAppState } from '@/providers/app-state-provider';
export const Input = (props: {
query: string;
setQuery: Dispatch<SetStateAction<string>>;
@@ -16,6 +17,11 @@ export const Input = (props: {
const [isComposition, setIsComposition] = useState(false);
const [inputValue, setInputValue] = useState('');
const inputRef = useRef<HTMLInputElement>(null);
const { currentWorkspaceId, workspacesMeta, currentWorkspace } =
useAppState();
const isPublic = workspacesMeta.find(
meta => String(meta.id) === String(currentWorkspaceId)
)?.public;
useEffect(() => {
inputRef.current?.addEventListener(
'blur',
@@ -73,7 +79,7 @@ export const Input = (props: {
}
}
}}
placeholder="Quick Search..."
placeholder={isPublic ? currentWorkspace?.meta.name : 'Quick Search...'}
/>
</StyledInputContent>
);