@splunk/themes 0.23.0 → 0.25.0

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/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  Change Log
2
2
  ============
3
3
 
4
+ 0.25.0 - June 4, 2025
5
+ ----------
6
+ New Features:
7
+ * `@splunk/themes/storybook-addon-splunk-themes` now supports disabling 'both' option via `disableDualTheme` story param (SUI-7702).
8
+
9
+ 0.24.0 - May 6, 2025
10
+ ----------
11
+ Bug Fixes:
12
+ * Added `main` and `types` properties to package.json (SUI-7464).
13
+
4
14
  0.23.0 - February 5, 2025
5
15
  ----------
6
16
  Bug Fixes:
package/package.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "name": "@splunk/themes",
3
- "version": "0.23.0",
3
+ "version": "0.25.0",
4
4
  "description": "Theme variables and mixins for the Splunk design language",
5
+ "main": "./index.js",
6
+ "types": "./types/index.d.ts",
5
7
  "scripts": {
6
8
  "babel": "babel src -d . --ignore src/babel-plugin-base64-png,src/tests --ignore \"**/docs\" --extensions .js,.ts,.tsx",
7
9
  "build": "cross-env NODE_ENV=production yarn babel && yarn types:build",
@@ -37,22 +37,32 @@ var SplunkThemesTool = /*#__PURE__*/(0, _react.memo)(function () {
37
37
  globals = _useGlobals2[0],
38
38
  updateGlobals = _useGlobals2[1];
39
39
  var params = (0, _managerApi.useParameter)(_constants.PARAM_KEY, {});
40
+ var disableDualTheme = (0, _managerApi.useParameter)(_constants.DISABLE_DUAL_THEME_KEY, false);
40
41
  var globalsTheme = globals[_constants.PARAM_KEY] || undefined;
41
42
  var currentTheme = (0, _util.normalizeThemeOptions)(params, globalsTheme);
42
43
  var updateTheme = (0, _react.useCallback)(function (newTheme) {
43
44
  var mergedTheme = (0, _util.getMergedTheme)(globalsTheme, newTheme);
44
45
  updateGlobals(_defineProperty({}, _constants.PARAM_KEY, mergedTheme));
45
46
  }, [globalsTheme, updateGlobals]);
47
+ (0, _react.useEffect)(function () {
48
+ if (disableDualTheme) {
49
+ // eslint-disable-next-line no-console
50
+ console.warn("This story has 'disableDualTheme' set to 'true', so 'both' option will not show in theme dropdown.");
51
+ }
52
+ }, [disableDualTheme]);
46
53
  return /*#__PURE__*/_react["default"].createElement(_components.WithTooltip, {
47
54
  placement: "top",
48
55
  trigger: "click",
49
56
  tooltip: function tooltip() {
50
57
  return Object.keys(_themeOptions.themeOptions).map(function (themeOptionKey) {
51
58
  var themeOptionValues = _themeOptions.themeOptions[themeOptionKey];
59
+
60
+ // if story is passing disableDualTheme: true, don't display 'both' option in theme picker
61
+ var dualThemeOptions = disableDualTheme ? [] : ['both'];
52
62
  return /*#__PURE__*/_react["default"].createElement(_react.Fragment, {
53
63
  key: themeOptionKey
54
64
  }, /*#__PURE__*/_react["default"].createElement(_themes.TooltipSectionTitle, null, themeOptionValues.name), /*#__PURE__*/_react["default"].createElement(_components.TooltipLinkList, {
55
- links: [].concat(_toConsumableArray(themeOptionValues.values), ['both']).map(function (themeValue) {
65
+ links: [].concat(_toConsumableArray(themeOptionValues.values), dualThemeOptions).map(function (themeValue) {
56
66
  var active = currentTheme[themeOptionKey] === themeValue;
57
67
  return {
58
68
  active: active,
@@ -3,11 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.CHANGED = exports.SET = exports.CONFIGURE = exports.UPDATE = exports.PARAM_KEY = exports.ADDON_ID = void 0;
6
+ exports.CHANGED = exports.SET = exports.CONFIGURE = exports.UPDATE = exports.DISABLE_DUAL_THEME_KEY = exports.PARAM_KEY = exports.ADDON_ID = void 0;
7
7
  var ADDON_ID = '@splunk/themes';
8
8
  exports.ADDON_ID = ADDON_ID;
9
9
  var PARAM_KEY = 'splunkThemes';
10
10
  exports.PARAM_KEY = PARAM_KEY;
11
+ var DISABLE_DUAL_THEME_KEY = 'disableDualTheme';
12
+ exports.DISABLE_DUAL_THEME_KEY = DISABLE_DUAL_THEME_KEY;
11
13
  var UPDATE = "".concat(ADDON_ID, "/update");
12
14
  exports.UPDATE = UPDATE;
13
15
  var CONFIGURE = "".concat(ADDON_ID, "/configure");
@@ -87,7 +87,7 @@ var WithSplunkTheme = function WithSplunkTheme(Story, context) {
87
87
  return true;
88
88
  }));
89
89
  var themeProviderProps = _objectSpread({}, cleanedThemeProviderProps);
90
- if (dualThemeOption != null && currentTheme[dualThemeOption] === 'both') {
90
+ if (!parameters.disableDualTheme && dualThemeOption != null && currentTheme[dualThemeOption] === 'both') {
91
91
  return /*#__PURE__*/_react["default"].createElement(DualStory, {
92
92
  context: context,
93
93
  themeOption: dualThemeOption,
@@ -1,5 +1,6 @@
1
1
  export declare const ADDON_ID = "@splunk/themes";
2
2
  export declare const PARAM_KEY = "splunkThemes";
3
+ export declare const DISABLE_DUAL_THEME_KEY = "disableDualTheme";
3
4
  export declare const UPDATE: string;
4
5
  export declare const CONFIGURE: string;
5
6
  export declare const SET: string;