mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-02 13:00:58 +08:00

* feat: add list and table views for logs * chore: some of the changes are updated * chore: some of the refactoring is done * chore: px to updated to rem * chore: constant is moved to local storage * refactor: some of the refactoring is updated * chore: some of the changes are updated * fix: resize log table issue * chore: logs is updated * chore: resize header is updated * chore: font observer is added in package json and hook is added for same * chore: no logs text is updated * chore: no logs text is updated * chore: updated some feedback in raw logs line * chore: types is added --------- Co-authored-by: Palash Gupta <palashgdev@gmail.com> Co-authored-by: Pranay Prateek <pranay@signoz.io> Co-authored-by: Vishal Sharma <makeavish786@gmail.com> Co-authored-by: Chintan Sudani <csudani7@gmail.com>
70 lines
1.3 KiB
TypeScript
70 lines
1.3 KiB
TypeScript
import FontFaceObserver from 'fontfaceobserver';
|
|
import { useEffect, useState } from 'react';
|
|
|
|
export interface FontFace {
|
|
family: string;
|
|
weight?:
|
|
| `light`
|
|
| `normal`
|
|
| `bold`
|
|
| `bolder`
|
|
| `100`
|
|
| `200`
|
|
| `300`
|
|
| `400`
|
|
| `500`
|
|
| `600`
|
|
| `700`
|
|
| `800`
|
|
| `900`;
|
|
style?: `normal` | `italic` | `oblique`;
|
|
stretch?:
|
|
| `normal`
|
|
| `ultra-condensed`
|
|
| `extra-condensed`
|
|
| `condensed`
|
|
| `semi-condensed`
|
|
| `semi-expanded`
|
|
| `expanded`
|
|
| `extra-expanded`
|
|
| `ultra-expanded`;
|
|
}
|
|
|
|
export interface Options {
|
|
testString?: string;
|
|
timeout?: number;
|
|
}
|
|
|
|
export interface Config {
|
|
showErrors: boolean;
|
|
}
|
|
|
|
function useFontFaceObserver(
|
|
fontFaces: FontFace[] = [],
|
|
isEnabled = true,
|
|
{ testString, timeout }: Options = {},
|
|
{ showErrors }: Config = { showErrors: false },
|
|
): boolean {
|
|
const [isResolved, setIsResolved] = useState(false);
|
|
const fontFacesString = JSON.stringify(fontFaces);
|
|
|
|
useEffect(() => {
|
|
if (isEnabled) {
|
|
const promises = JSON.parse(fontFacesString).map(
|
|
({ family, weight, style, stretch }: FontFace) =>
|
|
new FontFaceObserver(family, {
|
|
weight,
|
|
style,
|
|
stretch,
|
|
}).load(testString, timeout),
|
|
);
|
|
|
|
Promise.all(promises).then(() => setIsResolved(true));
|
|
}
|
|
}, [fontFacesString, testString, timeout, showErrors, isEnabled]);
|
|
|
|
return isResolved;
|
|
}
|
|
|
|
export default useFontFaceObserver;
|