@atlaskit/storybook-addon-design-system 0.3.3 → 0.3.4

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,5 +1,11 @@
1
1
  # @atlaskit/storybook-addon-design-system
2
2
 
3
+ ## 0.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`43464a5fb17`](https://bitbucket.org/atlassian/atlassian-frontend/commits/43464a5fb17) - Update split and stack theme settings to use tilde selectors
8
+
3
9
  ## 0.3.3
4
10
 
5
11
  ### Patch Changes
@@ -56,8 +56,12 @@ var stackColumnStyles = {
56
56
  * .ads-theme-override, for split and stack views.
57
57
  */
58
58
 
59
- var hackThemeOverrideOnStyleElement = function hackThemeOverrideOnStyleElement(style, theme) {
60
- style.innerText = style.textContent.replace("html[data-theme=\"".concat(theme, "\"]"), "html[data-theme=\"".concat(theme, "\"],.ads-theme-override[data-theme=\"").concat(theme, "\"]"));
59
+ var hackThemeOverrideOnStyleElement = function hackThemeOverrideOnStyleElement(style) {
60
+ var regex = /html\[(data-theme.?=)"(light|dark)"\](\s{)/i;
61
+
62
+ if (regex.test(style.innerText)) {
63
+ style.innerText = style.textContent.replace(regex, "html[$1\"$2\"], .ads-theme-override[$1\"$2\"]$3");
64
+ }
61
65
  };
62
66
 
63
67
  var withDesignTokens = (0, _addons.makeDecorator)({
@@ -67,13 +71,8 @@ var withDesignTokens = (0, _addons.makeDecorator)({
67
71
  var theme = context.globals.adsTheme; // eslint-disable-next-line react-hooks/rules-of-hooks
68
72
 
69
73
  (0, _addons.useEffect)(function () {
70
- var adsThemes = ['light', 'dark'];
71
74
  document.querySelectorAll('style').forEach(function (el) {
72
- adsThemes.forEach(function (adsTheme) {
73
- if (el.innerText.includes("html[data-theme=\"".concat(adsTheme, "\"] {"))) {
74
- hackThemeOverrideOnStyleElement(el, adsTheme);
75
- }
76
- });
75
+ hackThemeOverrideOnStyleElement(el);
77
76
  });
78
77
  }, [context.id]); // eslint-disable-next-line react-hooks/rules-of-hooks
79
78
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/storybook-addon-design-system",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "sideEffects": false
5
5
  }
@@ -29,8 +29,12 @@ const stackColumnStyles = {
29
29
  * .ads-theme-override, for split and stack views.
30
30
  */
31
31
 
32
- const hackThemeOverrideOnStyleElement = (style, theme) => {
33
- style.innerText = style.textContent.replace(`html[data-theme="${theme}"]`, `html[data-theme="${theme}"],.ads-theme-override[data-theme="${theme}"]`);
32
+ const hackThemeOverrideOnStyleElement = style => {
33
+ const regex = /html\[(data-theme.?=)"(light|dark)"\](\s{)/i;
34
+
35
+ if (regex.test(style.innerText)) {
36
+ style.innerText = style.textContent.replace(regex, `html[$1"$2"], .ads-theme-override[$1"$2"]$3`);
37
+ }
34
38
  };
35
39
 
36
40
  const withDesignTokens = makeDecorator({
@@ -40,13 +44,8 @@ const withDesignTokens = makeDecorator({
40
44
  const theme = context.globals.adsTheme; // eslint-disable-next-line react-hooks/rules-of-hooks
41
45
 
42
46
  useEffect(() => {
43
- const adsThemes = ['light', 'dark'];
44
47
  document.querySelectorAll('style').forEach(el => {
45
- adsThemes.forEach(adsTheme => {
46
- if (el.innerText.includes(`html[data-theme="${adsTheme}"] {`)) {
47
- hackThemeOverrideOnStyleElement(el, adsTheme);
48
- }
49
- });
48
+ hackThemeOverrideOnStyleElement(el);
50
49
  });
51
50
  }, [context.id]); // eslint-disable-next-line react-hooks/rules-of-hooks
52
51
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/storybook-addon-design-system",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "sideEffects": false
5
5
  }
@@ -35,8 +35,12 @@ var stackColumnStyles = {
35
35
  * .ads-theme-override, for split and stack views.
36
36
  */
37
37
 
38
- var hackThemeOverrideOnStyleElement = function hackThemeOverrideOnStyleElement(style, theme) {
39
- style.innerText = style.textContent.replace("html[data-theme=\"".concat(theme, "\"]"), "html[data-theme=\"".concat(theme, "\"],.ads-theme-override[data-theme=\"").concat(theme, "\"]"));
38
+ var hackThemeOverrideOnStyleElement = function hackThemeOverrideOnStyleElement(style) {
39
+ var regex = /html\[(data-theme.?=)"(light|dark)"\](\s{)/i;
40
+
41
+ if (regex.test(style.innerText)) {
42
+ style.innerText = style.textContent.replace(regex, "html[$1\"$2\"], .ads-theme-override[$1\"$2\"]$3");
43
+ }
40
44
  };
41
45
 
42
46
  var withDesignTokens = makeDecorator({
@@ -46,13 +50,8 @@ var withDesignTokens = makeDecorator({
46
50
  var theme = context.globals.adsTheme; // eslint-disable-next-line react-hooks/rules-of-hooks
47
51
 
48
52
  useEffect(function () {
49
- var adsThemes = ['light', 'dark'];
50
53
  document.querySelectorAll('style').forEach(function (el) {
51
- adsThemes.forEach(function (adsTheme) {
52
- if (el.innerText.includes("html[data-theme=\"".concat(adsTheme, "\"] {"))) {
53
- hackThemeOverrideOnStyleElement(el, adsTheme);
54
- }
55
- });
54
+ hackThemeOverrideOnStyleElement(el);
56
55
  });
57
56
  }, [context.id]); // eslint-disable-next-line react-hooks/rules-of-hooks
58
57
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/storybook-addon-design-system",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/storybook-addon-design-system",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Design token storybook addon",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {