@m4l/graphics 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +4 -0
- package/index.js +3 -3
- package/package.json +1 -1
- package/theme/palette.d.ts +1 -0
- package/theme/shadows.d.ts +1 -1
- package/utils/getColorPresets.d.ts +2 -1
- package/utils/getFontValue.d.ts +1 -1
- package/utils/index.js +25 -3
package/index.d.ts
CHANGED
|
@@ -6,5 +6,9 @@ export type { GradientsPaletteOptions } from './theme/palette';
|
|
|
6
6
|
export type { ChartPaletteOptions } from './theme/palette';
|
|
7
7
|
export type { GridPaletteOptions } from './theme/palette';
|
|
8
8
|
export { defaultThemeOptions } from './theme/defaultThemeOptions';
|
|
9
|
+
export { shadows, customShadows } from './theme/shadows';
|
|
10
|
+
export { palette, type ColorSchema } from './theme/palette';
|
|
11
|
+
export { getColorPresets, colorPresets, defaultPreset } from './utils/getColorPresets';
|
|
12
|
+
export { getFontValue as GetFontValue } from './utils/getFontValue';
|
|
9
13
|
export { default as fnComponentsOverrides } from './theme/overrides';
|
|
10
14
|
export type { HostThemeType } from './types';
|
package/index.js
CHANGED
|
@@ -6,6 +6,9 @@ export { u as useIsMountedRef, a as useOffSetTop } from "./hooks/index.js";
|
|
|
6
6
|
export { u as useLocales } from "./hooks/useLocales/index.js";
|
|
7
7
|
export { u as useHostTheme } from "./hooks/useHostTheme/index.js";
|
|
8
8
|
export { d as defaultThemeOptions } from "./theme/defaultThemeOptions.js";
|
|
9
|
+
export { c as customShadows, s as shadows } from "./theme/shadows.js";
|
|
10
|
+
export { p as palette } from "./theme/palette.js";
|
|
11
|
+
export { a as GetFontValue, c as colorPresets, d as defaultPreset, g as getColorPresets } from "./utils/index.js";
|
|
9
12
|
export { f as fnComponentsOverrides } from "./theme/overrides.js";
|
|
10
13
|
import "@mui/material/styles";
|
|
11
14
|
import "@mui/material";
|
|
@@ -19,6 +22,3 @@ import "date-fns/locale/en-US";
|
|
|
19
22
|
import "@m4l/core";
|
|
20
23
|
import "@mui/material/useMediaQuery";
|
|
21
24
|
import "./theme/typography.js";
|
|
22
|
-
import "./utils/index.js";
|
|
23
|
-
import "./theme/palette.js";
|
|
24
|
-
import "./theme/shadows.js";
|
package/package.json
CHANGED
package/theme/palette.d.ts
CHANGED
package/theme/shadows.d.ts
CHANGED
|
@@ -146,7 +146,7 @@ export declare const redPreset: {
|
|
|
146
146
|
darker: string;
|
|
147
147
|
contrastText: string;
|
|
148
148
|
};
|
|
149
|
-
export
|
|
149
|
+
export declare function getColorPresets(presetsKey: ThemeColorPresets): {
|
|
150
150
|
LightSelected: string;
|
|
151
151
|
LightSelectedHover: string;
|
|
152
152
|
DarkSelected: string;
|
|
@@ -167,3 +167,4 @@ export default function getColorPresets(presetsKey: ThemeColorPresets): {
|
|
|
167
167
|
darker: string;
|
|
168
168
|
contrastText: string;
|
|
169
169
|
};
|
|
170
|
+
export default getColorPresets;
|
package/utils/getFontValue.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare function responsiveFontSizes({ sm, md, lg }: {
|
|
|
16
16
|
fontSize: string;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function getFontValue(variant: Variant): {
|
|
20
20
|
fontSize: number;
|
|
21
21
|
lineHeight: number;
|
|
22
22
|
fontWeight: import("csstype").Property.FontWeight | undefined;
|
package/utils/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import "@mui/material/styles";
|
|
2
|
-
import "
|
|
1
|
+
import { useTheme } from "@mui/material/styles";
|
|
2
|
+
import { u as useResponsive } from "../hooks/useResponsive/index.js";
|
|
3
3
|
import { p as palette } from "../theme/palette.js";
|
|
4
|
+
function remToPx(value) {
|
|
5
|
+
return Math.round(parseFloat(value) * 16);
|
|
6
|
+
}
|
|
4
7
|
function pxToRem(value) {
|
|
5
8
|
return `${value / 16}rem`;
|
|
6
9
|
}
|
|
@@ -17,6 +20,25 @@ function responsiveFontSizes({ sm, md, lg }) {
|
|
|
17
20
|
}
|
|
18
21
|
};
|
|
19
22
|
}
|
|
23
|
+
function useWidth() {
|
|
24
|
+
const theme = useTheme();
|
|
25
|
+
const keys = [...theme.breakpoints.keys].reverse();
|
|
26
|
+
return keys.reduce((output, key) => {
|
|
27
|
+
const matches = useResponsive("up", key);
|
|
28
|
+
return !output && matches ? key : output;
|
|
29
|
+
}, null) || "xs";
|
|
30
|
+
}
|
|
31
|
+
function getFontValue(variant) {
|
|
32
|
+
const theme = useTheme();
|
|
33
|
+
const breakpoints = useWidth();
|
|
34
|
+
const key = theme.breakpoints.up(breakpoints === "xl" ? "lg" : breakpoints);
|
|
35
|
+
const hasResponsive = variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "h5" || variant === "h6";
|
|
36
|
+
const getFont = hasResponsive && theme.typography[variant][key] ? theme.typography[variant][key] : theme.typography[variant];
|
|
37
|
+
const fontSize = remToPx(getFont.fontSize);
|
|
38
|
+
const lineHeight = Number(theme.typography[variant].lineHeight) * fontSize;
|
|
39
|
+
const { fontWeight, letterSpacing } = theme.typography[variant];
|
|
40
|
+
return { fontSize, lineHeight, fontWeight, letterSpacing };
|
|
41
|
+
}
|
|
20
42
|
const colorPresets = [
|
|
21
43
|
{
|
|
22
44
|
name: "default",
|
|
@@ -88,4 +110,4 @@ function getColorPresets(presetsKey) {
|
|
|
88
110
|
default: defaultPreset
|
|
89
111
|
}[presetsKey];
|
|
90
112
|
}
|
|
91
|
-
export { getColorPresets as g, pxToRem as p, responsiveFontSizes as r };
|
|
113
|
+
export { getFontValue as a, colorPresets as c, defaultPreset as d, getColorPresets as g, pxToRem as p, responsiveFontSizes as r };
|