@mindlogic-ai/logician-ui 2.0.0-alpha.2 → 2.0.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindlogic-ai/logician-ui",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.3",
4
4
  "description": "A comprehensive React design system built on Chakra UI",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -0,0 +1,71 @@
1
+ import React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { LogicianProvider } from "./LogicianProvider";
4
+ import { Button } from "../Button";
5
+ import { H1, Text } from "../Typography";
6
+ import { Box, VStack } from "@chakra-ui/react";
7
+
8
+ const meta: Meta<typeof LogicianProvider> = {
9
+ title: "Setup/LogicianProvider",
10
+ component: LogicianProvider,
11
+ parameters: { disableLogicianProvider: true },
12
+ };
13
+
14
+ export default meta;
15
+ type Story = StoryObj<typeof LogicianProvider>;
16
+
17
+ const SampleContent = () => (
18
+ <VStack spacing={6} p={8} align="start">
19
+ <H1 size="lg">Logician Design System</H1>
20
+ <Text fontSize="p">
21
+ This is a sample application wrapped in LogicianProvider. The provider
22
+ automatically applies the Logician theme to all Chakra UI components.
23
+ </Text>
24
+ <Box>
25
+ <Button variant="primary" mr={4}>
26
+ Primary Button
27
+ </Button>
28
+ <Button variant="secondary">Secondary Button</Button>
29
+ </Box>
30
+ <Text fontSize="subtitle" color="gray.1200">
31
+ This text uses the custom font sizes and colors from the Logician theme.
32
+ </Text>
33
+ </VStack>
34
+ );
35
+
36
+ export const Default: Story = {
37
+ render: () => (
38
+ <LogicianProvider>
39
+ <SampleContent />
40
+ </LogicianProvider>
41
+ ),
42
+ };
43
+
44
+ export const WithCustomTheme: Story = {
45
+ render: () => {
46
+ const customTheme = {
47
+ colors: {
48
+ primary: {
49
+ light: "purple.300",
50
+ main: "purple.500",
51
+ dark: "purple.700",
52
+ },
53
+ },
54
+ semanticTokens: {
55
+ colors: {
56
+ primary: {
57
+ light: "purple.300",
58
+ main: "purple.500",
59
+ dark: "purple.700",
60
+ },
61
+ },
62
+ },
63
+ };
64
+
65
+ return (
66
+ <LogicianProvider theme={customTheme}>
67
+ <SampleContent />
68
+ </LogicianProvider>
69
+ );
70
+ },
71
+ };
@@ -0,0 +1,82 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ import { ChakraProvider, ChakraProviderProps } from '@chakra-ui/react';
4
+
5
+ import theme from '../../theme';
6
+
7
+ /**
8
+ * Deep merge utility function that recursively merges objects
9
+ */
10
+ function deepMerge<T extends Record<string, any>>(
11
+ target: T,
12
+ source: Partial<T>
13
+ ): T {
14
+ const result = { ...target };
15
+
16
+ for (const key in source) {
17
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
18
+ const sourceValue = source[key];
19
+ const targetValue = result[key];
20
+
21
+ if (
22
+ sourceValue &&
23
+ typeof sourceValue === 'object' &&
24
+ !Array.isArray(sourceValue) &&
25
+ targetValue &&
26
+ typeof targetValue === 'object' &&
27
+ !Array.isArray(targetValue)
28
+ ) {
29
+ // Recursively merge nested objects
30
+ result[key] = deepMerge(targetValue, sourceValue);
31
+ } else {
32
+ // Override primitive values, arrays, or null/undefined
33
+ result[key] = sourceValue;
34
+ }
35
+ }
36
+ }
37
+
38
+ return result;
39
+ }
40
+
41
+ export interface LogicianProviderProps
42
+ extends Omit<ChakraProviderProps, 'theme'> {
43
+ /**
44
+ * Custom theme to override the default Logician theme
45
+ */
46
+ theme?: ChakraProviderProps['theme'];
47
+ }
48
+
49
+ /**
50
+ * LogicianProvider component that wraps ChakraProvider with the LogicianUI design system theme.
51
+ *
52
+ * This provider should be placed at the root of your application to provide
53
+ * the Logician design system theme and styling to all child components.
54
+ *
55
+ * @example
56
+ * ```tsx
57
+ * import { LogicianProvider } from '@mindlogic/logician-ui';
58
+ *
59
+ * function App() {
60
+ * return (
61
+ * <LogicianProvider>
62
+ * <YourApp />
63
+ * </LogicianProvider>
64
+ * );
65
+ * }
66
+ * ```
67
+ */
68
+ export const LogicianProvider: React.FC<LogicianProviderProps> = ({
69
+ children,
70
+ theme: customTheme,
71
+ ...rest
72
+ }) => {
73
+ const mergedTheme = customTheme ? deepMerge(theme, customTheme) : theme;
74
+
75
+ return (
76
+ <ChakraProvider theme={mergedTheme} {...rest}>
77
+ {children}
78
+ </ChakraProvider>
79
+ );
80
+ };
81
+
82
+ LogicianProvider.displayName = 'LogicianProvider';
@@ -0,0 +1 @@
1
+ export * from './LogicianProvider';