[UI > Components] Move Search to our styled wrapper
This commit is contained in:
parent
fbfc7d0d0b
commit
474aad2a47
4 changed files with 27 additions and 14 deletions
8
src/def.d.ts
vendored
8
src/def.d.ts
vendored
|
@ -27,6 +27,12 @@ interface CodeblockProps {
|
||||||
children?: string;
|
children?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface SearchProps {
|
||||||
|
onChangeText?: (v: string) => void;
|
||||||
|
placeholder?: string;
|
||||||
|
style?: _RN.TextStyle;
|
||||||
|
}
|
||||||
|
|
||||||
// Helper types for API functions
|
// Helper types for API functions
|
||||||
type PropIntellisense<P extends string | symbol> = Record<P, any> & Record<PropertyKey, any>;
|
type PropIntellisense<P extends string | symbol> = Record<P, any> & Record<PropertyKey, any>;
|
||||||
type PropsFinder = <T extends string | symbol>(...props: T[]) => PropIntellisense<T>;
|
type PropsFinder = <T extends string | symbol>(...props: T[]) => PropIntellisense<T>;
|
||||||
|
@ -412,7 +418,6 @@ interface VendettaObject {
|
||||||
// Discord
|
// Discord
|
||||||
Forms: PropIntellisense<"Form" | "FormSection">;
|
Forms: PropIntellisense<"Form" | "FormSection">;
|
||||||
General: PropIntellisense<"Button" | "Text" | "View">;
|
General: PropIntellisense<"Button" | "Text" | "View">;
|
||||||
Search: _React.ComponentType;
|
|
||||||
Alert: _React.ComponentType;
|
Alert: _React.ComponentType;
|
||||||
Button: _React.ComponentType<any> & { Looks: any, Colors: ButtonColors, Sizes: any };
|
Button: _React.ComponentType<any> & { Looks: any, Colors: ButtonColors, Sizes: any };
|
||||||
HelpMessage: _React.ComponentType;
|
HelpMessage: _React.ComponentType;
|
||||||
|
@ -421,6 +426,7 @@ interface VendettaObject {
|
||||||
Summary: _React.ComponentType<SummaryProps>;
|
Summary: _React.ComponentType<SummaryProps>;
|
||||||
ErrorBoundary: _React.ComponentType<ErrorBoundaryProps>;
|
ErrorBoundary: _React.ComponentType<ErrorBoundaryProps>;
|
||||||
Codeblock: _React.ComponentType<CodeblockProps>;
|
Codeblock: _React.ComponentType<CodeblockProps>;
|
||||||
|
Search: _React.ComponentType<SearchProps>;
|
||||||
}
|
}
|
||||||
toasts: {
|
toasts: {
|
||||||
showToast: (content: string, asset: number) => void;
|
showToast: (content: string, asset: number) => void;
|
||||||
|
|
17
src/ui/components/Search.tsx
Normal file
17
src/ui/components/Search.tsx
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import { SearchProps } from "@types";
|
||||||
|
import { stylesheet } from "@metro/common";
|
||||||
|
import { findByName } from "@metro/filters";
|
||||||
|
|
||||||
|
const Search = findByName("StaticSearchBarContainer");
|
||||||
|
|
||||||
|
const styles = stylesheet.createThemedStyleSheet({
|
||||||
|
search: {
|
||||||
|
margin: 0,
|
||||||
|
padding: 0,
|
||||||
|
borderBottomWidth: 0,
|
||||||
|
background: "none",
|
||||||
|
backgroundColor: "none",
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default ({ onChangeText, placeholder, style }: SearchProps) => <Search style={[styles.search, style]} placeholder={placeholder} onChangeText={onChangeText} />
|
|
@ -4,7 +4,6 @@ import { findByName, findByProps } from "@metro/filters";
|
||||||
// Discord
|
// Discord
|
||||||
export const Forms = findByProps("Form", "FormSection");
|
export const Forms = findByProps("Form", "FormSection");
|
||||||
export const General = findByProps("Button", "Text", "View");
|
export const General = findByProps("Button", "Text", "View");
|
||||||
export const Search = findByName("StaticSearchBarContainer");
|
|
||||||
export const Alert = findByProps("alertDarkStyles", "alertLightStyles").default;
|
export const Alert = findByProps("alertDarkStyles", "alertLightStyles").default;
|
||||||
export const Button = findByProps("Looks", "Colors", "Sizes") as React.ComponentType<any> & { Looks: any, Colors: any, Sizes: any };
|
export const Button = findByProps("Looks", "Colors", "Sizes") as React.ComponentType<any> & { Looks: any, Colors: any, Sizes: any };
|
||||||
export const HelpMessage = findByName("HelpMessage");
|
export const HelpMessage = findByName("HelpMessage");
|
||||||
|
@ -14,4 +13,5 @@ export const SafeAreaView = findByProps("useSafeAreaInsets").SafeAreaView as typ
|
||||||
// Vendetta
|
// Vendetta
|
||||||
export { default as Summary } from "@ui/components/Summary";
|
export { default as Summary } from "@ui/components/Summary";
|
||||||
export { default as ErrorBoundary } from "@ui/components/ErrorBoundary";
|
export { default as ErrorBoundary } from "@ui/components/ErrorBoundary";
|
||||||
export { default as Codeblock } from "@ui/components/Codeblock";
|
export { default as Codeblock } from "@ui/components/Codeblock";
|
||||||
|
export { default as Search } from "@ui/components/Search";
|
|
@ -1,4 +1,4 @@
|
||||||
import { ReactNative as RN, stylesheet } from "@metro/common";
|
import { ReactNative as RN } from "@metro/common";
|
||||||
import { all } from "@ui/assets";
|
import { all } from "@ui/assets";
|
||||||
import { Forms, Search } from "@ui/components";
|
import { Forms, Search } from "@ui/components";
|
||||||
import ErrorBoundary from "@ui/components/ErrorBoundary";
|
import ErrorBoundary from "@ui/components/ErrorBoundary";
|
||||||
|
@ -6,15 +6,6 @@ import AssetDisplay from "@ui/settings/components/AssetDisplay";
|
||||||
|
|
||||||
const { FormDivider } = Forms;
|
const { FormDivider } = Forms;
|
||||||
|
|
||||||
const styles = stylesheet.createThemedStyleSheet({
|
|
||||||
search: {
|
|
||||||
margin: 0,
|
|
||||||
padding: 15,
|
|
||||||
borderBottomWidth: 0,
|
|
||||||
background: "none",
|
|
||||||
backgroundColor: "none",
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function AssetBrowser() {
|
export default function AssetBrowser() {
|
||||||
const [search, setSearch] = React.useState("");
|
const [search, setSearch] = React.useState("");
|
||||||
|
@ -23,7 +14,6 @@ export default function AssetBrowser() {
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
<RN.View style={{ flex: 1 }}>
|
<RN.View style={{ flex: 1 }}>
|
||||||
<Search
|
<Search
|
||||||
style={styles.search}
|
|
||||||
onChangeText={(v: string) => setSearch(v)}
|
onChangeText={(v: string) => setSearch(v)}
|
||||||
placeholder="Search"
|
placeholder="Search"
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue