@nextui-org/react 1.0.2-alpha.1 → 1.0.2-alpha.2

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <p align="center">
2
2
  <a href="https://nextui.org">
3
- <img width="20%" src="https://raw.githubusercontent.com/jrgarciadev/nextui/main/packages/docs/public/isotipo.png" alt="nextui" />
3
+ <img width="20%" src="https://raw.githubusercontent.com/jrgarciadev/nextui/main/apps/docs/public/isotipo.png" alt="nextui" />
4
4
  <h1 align="center">NextUI</h1>
5
5
  </a>
6
6
  </p>
@@ -71,6 +71,15 @@ import Button from '@nextui-org/react/button';
71
71
  const Component = () => <Button>Click me</Button>;
72
72
  ```
73
73
 
74
+ ### Communnity
75
+
76
+ We're excited to see the community adopt NextUI, raise issues, and provide feedback.
77
+ Whether it's a feature request, bug report, or a project to showcase, please get involved!
78
+
79
+ - [Discord](https://discord.gg/9b6yyZKmH4)
80
+ - [Twitter](https://twitter.com/getnextui)
81
+ - [GitHub Discussions](https://github.com/nextui-org/nextui/discussions)
82
+
74
83
  ## Contributing
75
84
 
76
85
  Contributions are always welcome!
@@ -55,10 +55,11 @@ const ThemeProvider = ({
55
55
  const providerValue = (0, _react.useMemo)(() => {
56
56
  const themeTokens = isBrowser ? (0, _utils.getDocumentCSSTokens)() : {};
57
57
  const theme = (0, _deepMerge.default)((0, _object.copyObject)(_themeContext.defaultContext.theme), themeTokens);
58
+ const themeName = (0, _utils.getThemeName)(currentTheme);
58
59
  return {
59
60
  theme,
60
- type: currentTheme,
61
- isDark: currentTheme === 'dark'
61
+ type: themeName,
62
+ isDark: themeName === 'dark'
62
63
  };
63
64
  }, [currentTheme, isBrowser]);
64
65
  (0, _react.useEffect)(() => {
@@ -90,14 +91,20 @@ const ThemeProvider = ({
90
91
  });
91
92
  return () => observer.disconnect();
92
93
  }, []);
94
+ (0, _react.useEffect)(() => {
95
+ if (!isBrowser || !userTheme) {
96
+ return;
97
+ }
98
+
99
+ if (userTheme != null && userTheme.className) {
100
+ (0, _utils.changeTheme)(userTheme.className);
101
+ changeCurrentTheme((0, _utils.getThemeName)(userTheme.className));
102
+ }
103
+ }, [isBrowser, userTheme]);
93
104
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ssrProvider.SsrProvider, {
94
105
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_themeContext.default.Provider, {
95
106
  value: providerValue,
96
- children: [!disableBaseline && /*#__PURE__*/(0, _jsxRuntime.jsx)(_cssBaseline.default, {}), userTheme ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
97
- id: "__nextui",
98
- className: userTheme,
99
- children: children
100
- }) : children]
107
+ children: [!disableBaseline && /*#__PURE__*/(0, _jsxRuntime.jsx)(_cssBaseline.default, {}), children]
101
108
  })
102
109
  });
103
110
  };
@@ -12,4 +12,5 @@ export declare const getDocumentCSSTokens: () => {
12
12
  * Returns active theme according to the given document
13
13
  */
14
14
  export declare const getDocumentTheme: (el: HTMLElement) => string;
15
+ export declare const getThemeName: (theme: ThemeType | string) => string;
15
16
  export declare const changeTheme: (theme: ThemeType | string) => void;
@@ -3,7 +3,7 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  exports.__esModule = true;
6
- exports.getTokenValue = exports.getDocumentTheme = exports.getDocumentCSSTokens = exports.changeTheme = void 0;
6
+ exports.getTokenValue = exports.getThemeName = exports.getDocumentTheme = exports.getDocumentCSSTokens = exports.changeTheme = void 0;
7
7
 
8
8
  var _common = _interopRequireDefault(require("./common"));
9
9
 
@@ -89,6 +89,16 @@ const getDocumentTheme = el => {
89
89
 
90
90
  exports.getDocumentTheme = getDocumentTheme;
91
91
 
92
+ const getThemeName = theme => {
93
+ if (typeof theme === 'string') {
94
+ return theme != null && theme.includes('-theme') ? theme == null ? void 0 : theme.replace('-theme', '') : theme;
95
+ }
96
+
97
+ return theme;
98
+ };
99
+
100
+ exports.getThemeName = getThemeName;
101
+
92
102
  const changeTheme = theme => {
93
103
  var _el$getAttribute2, _el$getAttribute3;
94
104
 
@@ -96,7 +106,7 @@ const changeTheme = theme => {
96
106
  const el = document.documentElement;
97
107
  const prevClasses = (el == null ? void 0 : (_el$getAttribute2 = el.getAttribute('class')) == null ? void 0 : _el$getAttribute2.split(' ').filter(cls => !cls.includes('theme') && !cls.includes('light') && !cls.includes('dark'))) || [];
98
108
  const prevStyles = (el == null ? void 0 : (_el$getAttribute3 = el.getAttribute('style')) == null ? void 0 : _el$getAttribute3.split(';').filter(stl => !stl.includes('color-scheme')).map(el => `${el};`)) || [];
99
- el == null ? void 0 : el.setAttribute('class', (0, _clsx.default)(prevClasses, `${theme}-theme`));
109
+ el == null ? void 0 : el.setAttribute('class', (0, _clsx.default)(prevClasses, `${getThemeName(theme)}-theme`));
100
110
  el == null ? void 0 : el.setAttribute('style', (0, _clsx.default)(prevStyles, `color-scheme: ${theme};`));
101
111
  };
102
112
 
@@ -73,6 +73,7 @@ const StyledTooltipContent = (0, _stitches.styled)('div', {
73
73
  },
74
74
  invert: {
75
75
  $$tooltipColor: '$colors$foreground',
76
+ $$tooltipTextColor: '$colors$background',
76
77
  bg: '$$tooltipColor'
77
78
  }
78
79
  },
@@ -121,14 +122,7 @@ const StyledTooltipContent = (0, _stitches.styled)('div', {
121
122
  }
122
123
  }
123
124
  },
124
- compoundVariants: [// color='invert' && contentColor='default'
125
- {
126
- color: 'invert',
127
- contentColor: 'default',
128
- css: {
129
- $$tooltipTextColor: '$colors$white'
130
- }
131
- }, // color='primary' && contentColor='default'
125
+ compoundVariants: [// color='primary' && contentColor='default'
132
126
  {
133
127
  color: 'primary',
134
128
  contentColor: 'default',
@@ -55,10 +55,11 @@ const ThemeProvider = ({
55
55
  const providerValue = (0, _react.useMemo)(() => {
56
56
  const themeTokens = isBrowser ? (0, _utils.getDocumentCSSTokens)() : {};
57
57
  const theme = (0, _deepMerge.default)((0, _object.copyObject)(_themeContext.defaultContext.theme), themeTokens);
58
+ const themeName = (0, _utils.getThemeName)(currentTheme);
58
59
  return {
59
60
  theme,
60
- type: currentTheme,
61
- isDark: currentTheme === 'dark'
61
+ type: themeName,
62
+ isDark: themeName === 'dark'
62
63
  };
63
64
  }, [currentTheme, isBrowser]);
64
65
  (0, _react.useEffect)(() => {
@@ -90,14 +91,20 @@ const ThemeProvider = ({
90
91
  });
91
92
  return () => observer.disconnect();
92
93
  }, []);
94
+ (0, _react.useEffect)(() => {
95
+ if (!isBrowser || !userTheme) {
96
+ return;
97
+ }
98
+
99
+ if (userTheme != null && userTheme.className) {
100
+ (0, _utils.changeTheme)(userTheme.className);
101
+ changeCurrentTheme((0, _utils.getThemeName)(userTheme.className));
102
+ }
103
+ }, [isBrowser, userTheme]);
93
104
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ssrProvider.SsrProvider, {
94
105
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_themeContext.default.Provider, {
95
106
  value: providerValue,
96
- children: [!disableBaseline && /*#__PURE__*/(0, _jsxRuntime.jsx)(_cssBaseline.default, {}), userTheme ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
97
- id: "__nextui",
98
- className: userTheme,
99
- children: children
100
- }) : children]
107
+ children: [!disableBaseline && /*#__PURE__*/(0, _jsxRuntime.jsx)(_cssBaseline.default, {}), children]
101
108
  })
102
109
  });
103
110
  };
@@ -12,4 +12,5 @@ export declare const getDocumentCSSTokens: () => {
12
12
  * Returns active theme according to the given document
13
13
  */
14
14
  export declare const getDocumentTheme: (el: HTMLElement) => string;
15
+ export declare const getThemeName: (theme: ThemeType | string) => string;
15
16
  export declare const changeTheme: (theme: ThemeType | string) => void;
@@ -3,7 +3,7 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  exports.__esModule = true;
6
- exports.getTokenValue = exports.getDocumentTheme = exports.getDocumentCSSTokens = exports.changeTheme = void 0;
6
+ exports.getTokenValue = exports.getThemeName = exports.getDocumentTheme = exports.getDocumentCSSTokens = exports.changeTheme = void 0;
7
7
 
8
8
  var _common = _interopRequireDefault(require("./common"));
9
9
 
@@ -89,6 +89,16 @@ const getDocumentTheme = el => {
89
89
 
90
90
  exports.getDocumentTheme = getDocumentTheme;
91
91
 
92
+ const getThemeName = theme => {
93
+ if (typeof theme === 'string') {
94
+ return theme != null && theme.includes('-theme') ? theme == null ? void 0 : theme.replace('-theme', '') : theme;
95
+ }
96
+
97
+ return theme;
98
+ };
99
+
100
+ exports.getThemeName = getThemeName;
101
+
92
102
  const changeTheme = theme => {
93
103
  var _el$getAttribute2, _el$getAttribute3;
94
104
 
@@ -96,7 +106,7 @@ const changeTheme = theme => {
96
106
  const el = document.documentElement;
97
107
  const prevClasses = (el == null ? void 0 : (_el$getAttribute2 = el.getAttribute('class')) == null ? void 0 : _el$getAttribute2.split(' ').filter(cls => !cls.includes('theme') && !cls.includes('light') && !cls.includes('dark'))) || [];
98
108
  const prevStyles = (el == null ? void 0 : (_el$getAttribute3 = el.getAttribute('style')) == null ? void 0 : _el$getAttribute3.split(';').filter(stl => !stl.includes('color-scheme')).map(el => `${el};`)) || [];
99
- el == null ? void 0 : el.setAttribute('class', (0, _clsx.default)(prevClasses, `${theme}-theme`));
109
+ el == null ? void 0 : el.setAttribute('class', (0, _clsx.default)(prevClasses, `${getThemeName(theme)}-theme`));
100
110
  el == null ? void 0 : el.setAttribute('style', (0, _clsx.default)(prevStyles, `color-scheme: ${theme};`));
101
111
  };
102
112
 
@@ -73,6 +73,7 @@ const StyledTooltipContent = (0, _stitches.styled)('div', {
73
73
  },
74
74
  invert: {
75
75
  $$tooltipColor: '$colors$foreground',
76
+ $$tooltipTextColor: '$colors$background',
76
77
  bg: '$$tooltipColor'
77
78
  }
78
79
  },
@@ -121,14 +122,7 @@ const StyledTooltipContent = (0, _stitches.styled)('div', {
121
122
  }
122
123
  }
123
124
  },
124
- compoundVariants: [// color='invert' && contentColor='default'
125
- {
126
- color: 'invert',
127
- contentColor: 'default',
128
- css: {
129
- $$tooltipTextColor: '$colors$white'
130
- }
131
- }, // color='primary' && contentColor='default'
125
+ compoundVariants: [// color='primary' && contentColor='default'
132
126
  {
133
127
  color: 'primary',
134
128
  contentColor: 'default',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextui-org/react",
3
- "version": "1.0.2-alpha.1",
3
+ "version": "1.0.2-alpha.2",
4
4
  "license": "MIT",
5
5
  "description": "🚀 Beautiful and modern React UI library.",
6
6
  "homepage": "https://nextui.org",