Skip to content

Commit 94ea3f5

Browse files
committed
changing context exports
1 parent f537079 commit 94ea3f5

File tree

3 files changed

+34
-31
lines changed

3 files changed

+34
-31
lines changed

src/helpers/context-const.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from "react";
2+
export interface iKWIZFluentContext {
3+
/**
4+
* Where the portal children are mounted on DOM
5+
*
6+
* @default a new element on document.body without any styling
7+
*/
8+
mountNode?: HTMLElement | null | {
9+
element?: HTMLElement | null;
10+
className?: string;
11+
}
12+
/**
13+
* Controls the colors and borders of the input.
14+
*
15+
* @default 'underline'
16+
*/
17+
inputAppearance?: 'outline' | 'underline' | 'filled-darker' | 'filled-lighter';
18+
19+
/**
20+
* A button can be rounded, circular, or square.
21+
*
22+
* @default 'rounded'
23+
*/
24+
buttonShape?: 'rounded' | 'circular' | 'square';
25+
}
26+
27+
//create context
28+
export const KWIZFluentContext = React.createContext<iKWIZFluentContext>(null);
Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,7 @@
11
import { makeStyles } from "@fluentui/react-components";
2-
import { useEffect, useState } from "react";
3-
4-
export interface iKWIZFluentContext {
5-
/**
6-
* Where the portal children are mounted on DOM
7-
*
8-
* @default a new element on document.body without any styling
9-
*/
10-
mountNode?: HTMLElement | null | {
11-
element?: HTMLElement | null;
12-
className?: string;
13-
}
14-
/**
15-
* Controls the colors and borders of the input.
16-
*
17-
* @default 'underline'
18-
*/
19-
inputAppearance?: 'outline' | 'underline' | 'filled-darker' | 'filled-lighter';
20-
21-
/**
22-
* A button can be rounded, circular, or square.
23-
*
24-
* @default 'rounded'
25-
*/
26-
buttonShape?: 'rounded' | 'circular' | 'square';
27-
}
2+
import React, { PropsWithChildren, useEffect, useState } from "react";
3+
import { iKWIZFluentContext, KWIZFluentContext } from "./context-const";
4+
export type { iKWIZFluentContext } from "./context-const";
285

296
const useContextStyles = makeStyles({
307
root: {
@@ -33,6 +10,7 @@ const useContextStyles = makeStyles({
3310
}
3411
},
3512
})
13+
3614
export function useKWIZFluentContextProvider(options: {
3715
root?: React.MutableRefObject<HTMLDivElement>;
3816
ctx?: iKWIZFluentContext;
@@ -49,5 +27,5 @@ export function useKWIZFluentContextProvider(options: {
4927
mountNode: options.root.current
5028
});
5129
}, [options.root]);
52-
return kwizFluentContext;
30+
return (props: PropsWithChildren) => <KWIZFluentContext.Provider value={kwizFluentContext}>{props.children}</KWIZFluentContext.Provider>;
5331
}

src/helpers/context-internal.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { isNullOrUndefined } from "@kwiz/common";
22
import React from "react";
3-
import { iKWIZFluentContext } from "./context-export";
3+
import { KWIZFluentContext } from "./context-const";
44

5-
6-
//create context
7-
export const KWIZFluentContext = React.createContext<iKWIZFluentContext>(null);
85
//use context from within controls
96
export function useKWIZFluentContext() {
107
let ctx = React.useContext(KWIZFluentContext) || {};

0 commit comments

Comments
 (0)