-
Notifications
You must be signed in to change notification settings - Fork 59
/
makeResetStyles.ts
29 lines (24 loc) · 985 Bytes
/
makeResetStyles.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { makeResetStyles as vanillaMakeResetStyles } from '@griffel/core';
import type { GriffelResetStyle } from '@griffel/core';
import { insertionFactory } from './insertionFactory';
import { useRenderer } from './RendererContext';
import { useTextDirection } from './TextDirectionContext';
import { isInsideComponent } from './utils/isInsideComponent';
export function makeResetStyles(styles: GriffelResetStyle) {
const getStyles = vanillaMakeResetStyles(styles, insertionFactory);
if (process.env.NODE_ENV !== 'production') {
if (isInsideComponent()) {
throw new Error(
[
"makeResetStyles(): this function cannot be called in component's scope.",
'All makeResetStyles() calls should be top level i.e. in a root scope of a file.',
].join(' '),
);
}
}
return function useClassName(): string {
const dir = useTextDirection();
const renderer = useRenderer();
return getStyles({ dir, renderer });
};
}