@inventreedb/ui 0.2.0 → 0.2.1
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { MantineSize } from '@mantine/core';
|
|
1
|
+
import { MantineSize, MantineTheme } from '@mantine/core';
|
|
2
2
|
import { JSX } from 'react';
|
|
3
|
-
export declare function StylishText({ children, size }: Readonly<{
|
|
3
|
+
export declare function StylishText({ children, theme, size }: Readonly<{
|
|
4
4
|
children: JSX.Element | string;
|
|
5
|
+
theme?: MantineTheme;
|
|
5
6
|
size?: MantineSize;
|
|
6
7
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,12 +4,19 @@ import { Text } from "../node_modules/@mantine/core/esm/components/Text/Text.js"
|
|
|
4
4
|
import { useMantineTheme } from "../node_modules/@mantine/core/esm/core/MantineProvider/MantineThemeProvider/MantineThemeProvider.js";
|
|
5
5
|
import { getThemeColor } from "../node_modules/@mantine/core/esm/core/MantineProvider/color-functions/get-theme-color/get-theme-color.js";
|
|
6
6
|
import { darken } from "../node_modules/@mantine/core/esm/core/MantineProvider/color-functions/darken/darken.js";
|
|
7
|
-
const useThematicGradient = (
|
|
8
|
-
|
|
7
|
+
const useThematicGradient = ({
|
|
8
|
+
suppliedTheme
|
|
9
|
+
}) => {
|
|
10
|
+
const theme = useMemo(() => {
|
|
11
|
+
if (suppliedTheme && suppliedTheme != void 0) {
|
|
12
|
+
return suppliedTheme;
|
|
13
|
+
}
|
|
14
|
+
return useMantineTheme();
|
|
15
|
+
}, [suppliedTheme, useMantineTheme]);
|
|
9
16
|
const primary = useMemo(() => {
|
|
10
17
|
return getThemeColor(theme.primaryColor, theme);
|
|
11
18
|
}, [theme]);
|
|
12
|
-
const secondary = useMemo(() => darken(primary, 0.
|
|
19
|
+
const secondary = useMemo(() => darken(primary, 0.25), [primary]);
|
|
13
20
|
return useMemo(() => {
|
|
14
21
|
return {
|
|
15
22
|
primary,
|
|
@@ -19,12 +26,15 @@ const useThematicGradient = () => {
|
|
|
19
26
|
};
|
|
20
27
|
function StylishText({
|
|
21
28
|
children,
|
|
29
|
+
theme,
|
|
22
30
|
size
|
|
23
31
|
}) {
|
|
24
32
|
const {
|
|
25
33
|
primary,
|
|
26
34
|
secondary
|
|
27
|
-
} = useThematicGradient(
|
|
35
|
+
} = useThematicGradient({
|
|
36
|
+
suppliedTheme: theme
|
|
37
|
+
});
|
|
28
38
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fw: 700, size: size ?? "xl", variant: "gradient", gradient: {
|
|
29
39
|
from: primary.toString(),
|
|
30
40
|
to: secondary.toString()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StylishText.js","sources":["../../lib/components/StylishText.tsx"],"sourcesContent":["import {\n type MantineSize,\n Text,\n darken,\n getThemeColor,\n useMantineTheme\n} from '@mantine/core';\nimport { useMemo } from 'react';\nimport type { JSX } from 'react';\n\n// Hook that memoizes the gradient color based on the primary color of the theme\nconst useThematicGradient = () => {\n const theme = useMantineTheme();\n\n const primary = useMemo(() => {\n return getThemeColor(theme.primaryColor, theme);\n }, [theme]);\n\n const secondary = useMemo(() => darken(primary, 0.
|
|
1
|
+
{"version":3,"file":"StylishText.js","sources":["../../lib/components/StylishText.tsx"],"sourcesContent":["import {\n type MantineSize,\n MantineTheme,\n Text,\n darken,\n getThemeColor,\n useMantineTheme\n} from '@mantine/core';\nimport { useMemo } from 'react';\nimport type { JSX } from 'react';\n\n// Hook that memoizes the gradient color based on the primary color of the theme\nconst useThematicGradient = ({\n suppliedTheme,\n}: {\n suppliedTheme?: MantineTheme;\n}) => {\n\n const theme = useMemo(() => {\n if (suppliedTheme && suppliedTheme != undefined) {\n return suppliedTheme;\n }\n\n return useMantineTheme();\n }, [suppliedTheme, useMantineTheme]);\n\n const primary = useMemo(() => {\n return getThemeColor(theme.primaryColor, theme);\n }, [theme]);\n\n const secondary = useMemo(() => darken(primary, 0.25), [primary]);\n\n return useMemo(() => {\n return { primary, secondary };\n }, [primary, secondary]);\n};\n\n// A stylish text component that uses the primary color of the theme\nexport function StylishText({\n children,\n theme,\n size\n}: Readonly<{\n children: JSX.Element | string;\n theme?: MantineTheme;\n size?: MantineSize;\n}>) {\n const { primary, secondary } = useThematicGradient({ suppliedTheme: theme });\n\n return (\n <Text\n fw={700}\n size={size ?? 'xl'}\n variant='gradient'\n gradient={{ from: primary.toString(), to: secondary.toString() }}\n >\n {children}\n </Text>\n );\n}\n"],"names":["useThematicGradient","suppliedTheme","theme","useMemo","undefined","useMantineTheme","primary","getThemeColor","primaryColor","secondary","darken","StylishText","children","size","jsx","from","toString","to"],"mappings":";;;;;;AAYA,MAAMA,sBAAsBA,CAAC;AAAA,EAC3BC;AAGF,MAAM;AAEEC,QAAAA,QAAQC,QAAQ,MAAM;AACtBF,QAAAA,iBAAiBA,iBAAiBG,QAAW;AACxCH,aAAAA;AAAAA,IAAAA;AAGT,WAAOI,gBAAgB;AAAA,EAAA,GACtB,CAACJ,eAAeI,eAAe,CAAC;AAE7BC,QAAAA,UAAUH,QAAQ,MAAM;AACrBI,WAAAA,cAAcL,MAAMM,cAAcN,KAAK;AAAA,EAAA,GAC7C,CAACA,KAAK,CAAC;AAEJO,QAAAA,YAAYN,QAAQ,MAAMO,OAAOJ,SAAS,IAAI,GAAG,CAACA,OAAO,CAAC;AAEhE,SAAOH,QAAQ,MAAM;AACZ,WAAA;AAAA,MAAEG;AAAAA,MAASG;AAAAA,IAAU;AAAA,EAAA,GAC3B,CAACH,SAASG,SAAS,CAAC;AACzB;AAGO,SAASE,YAAY;AAAA,EAC1BC;AAAAA,EACAV;AAAAA,EACAW;AAKD,GAAG;AACI,QAAA;AAAA,IAAEP;AAAAA,IAASG;AAAAA,MAAcT,oBAAoB;AAAA,IAAEC,eAAeC;AAAAA,EAAAA,CAAO;AAGzE,SAAAY,sCAAC,QACC,IAAI,KACJ,MAAMD,QAAQ,MACd,SAAQ,YACR,UAAU;AAAA,IAAEE,MAAMT,QAAQU,SAAS;AAAA,IAAGC,IAAIR,UAAUO,SAAS;AAAA,KAE5DJ,SACH,CAAA;AAEJ;"}
|
package/dist/types/Plugins.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type MantineSize,
|
|
3
|
+
type MantineTheme,
|
|
3
4
|
Text,
|
|
4
5
|
darken,
|
|
5
6
|
getThemeColor,
|
|
@@ -9,14 +10,24 @@ import { useMemo } from 'react';
|
|
|
9
10
|
import type { JSX } from 'react';
|
|
10
11
|
|
|
11
12
|
// Hook that memoizes the gradient color based on the primary color of the theme
|
|
12
|
-
const useThematicGradient = (
|
|
13
|
-
|
|
13
|
+
const useThematicGradient = ({
|
|
14
|
+
suppliedTheme
|
|
15
|
+
}: {
|
|
16
|
+
suppliedTheme?: MantineTheme;
|
|
17
|
+
}) => {
|
|
18
|
+
const theme = useMemo(() => {
|
|
19
|
+
if (suppliedTheme && suppliedTheme != undefined) {
|
|
20
|
+
return suppliedTheme;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return useMantineTheme();
|
|
24
|
+
}, [suppliedTheme, useMantineTheme]);
|
|
14
25
|
|
|
15
26
|
const primary = useMemo(() => {
|
|
16
27
|
return getThemeColor(theme.primaryColor, theme);
|
|
17
28
|
}, [theme]);
|
|
18
29
|
|
|
19
|
-
const secondary = useMemo(() => darken(primary, 0.
|
|
30
|
+
const secondary = useMemo(() => darken(primary, 0.25), [primary]);
|
|
20
31
|
|
|
21
32
|
return useMemo(() => {
|
|
22
33
|
return { primary, secondary };
|
|
@@ -26,12 +37,14 @@ const useThematicGradient = () => {
|
|
|
26
37
|
// A stylish text component that uses the primary color of the theme
|
|
27
38
|
export function StylishText({
|
|
28
39
|
children,
|
|
40
|
+
theme,
|
|
29
41
|
size
|
|
30
42
|
}: Readonly<{
|
|
31
43
|
children: JSX.Element | string;
|
|
44
|
+
theme?: MantineTheme;
|
|
32
45
|
size?: MantineSize;
|
|
33
46
|
}>) {
|
|
34
|
-
const { primary, secondary } = useThematicGradient();
|
|
47
|
+
const { primary, secondary } = useThematicGradient({ suppliedTheme: theme });
|
|
35
48
|
|
|
36
49
|
return (
|
|
37
50
|
<Text
|