Skip to content

Commit 5d7bc94

Browse files
committed
wip
1 parent 3e69149 commit 5d7bc94

4 files changed

Lines changed: 30 additions & 1 deletion

File tree

packages/react-filters-bar/src/filter-context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ export function useFilterCtx() {
2121
export function FilterProvider({
2222
children,
2323
...props
24-
}: PropsWithChildren<Provider>) {
24+
}: PropsWithChildren<FilterState>) {
2525
return <FilterCtx.Provider value={props}>{children}</FilterCtx.Provider>;
2626
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { createContext, PropsWithChildren, useContext } from "react";
2+
3+
type FiltersDef = Record<string, JSX.Element>;
4+
5+
const FiltersBarCtx = createContext<{ filtersDef: FiltersDef } | null>(null);
6+
7+
export function useFiltersBarCtx() {
8+
const ctx = useContext(FiltersBarCtx);
9+
if (ctx == null) {
10+
throw Error("FiltersBarCtx.Provider is missing.");
11+
}
12+
return ctx;
13+
}
14+
15+
export function FiltersBarProvider<TFiltersDef extends FiltersDef>({
16+
children,
17+
filtersDef,
18+
}: PropsWithChildren<{ filtersDef: TFiltersDef }>) {
19+
return (
20+
<FiltersBarCtx.Provider value={{ filtersDef }}>
21+
{children}
22+
</FiltersBarCtx.Provider>
23+
);
24+
}

packages/react-filters-bar/src/main.ts

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { FiltersBarProvider } from "./filtersbar-context";
2+
3+
export function FiltersBar({filtersDef}: ) {
4+
return <FiltersBarProvider filtersDef={}></FiltersBarProvider>
5+
}

0 commit comments

Comments
 (0)