@pareto-engineering/design-system 2.0.0-alpha.50 → 2.0.0-alpha.53

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.
Files changed (193) hide show
  1. package/dist/cjs/{c/BlogContext → a/AppContext}/Context.js +0 -0
  2. package/dist/cjs/{c/SiteFooter/common/Section/Section.js → a/AppContext/ContextProvider.js} +50 -49
  3. package/dist/cjs/{c/BlogContext → a/AppContext}/index.js +13 -5
  4. package/dist/cjs/{c/BlogContext/useBlog.js → a/AppContext/useApp.js} +0 -0
  5. package/dist/cjs/a/AppContext/useTheme.js +45 -0
  6. package/dist/cjs/a/index.js +8 -8
  7. package/dist/cjs/b/Page/common/PageHelmet/PageHelmet.js +1 -1
  8. package/dist/cjs/b/SocialMediaButton/SocialMediaButton.js +4 -4
  9. package/dist/cjs/b/ThemeSelector/ThemeSelector.js +1 -1
  10. package/dist/cjs/c/SocialMediaShareButton/SocialMediaShareButton.js +10 -4
  11. package/dist/es/{c/BlogContext → a/AppContext}/Context.js +0 -0
  12. package/dist/es/a/AppContext/ContextProvider.js +78 -0
  13. package/dist/es/a/AppContext/index.js +5 -0
  14. package/dist/es/{c/BlogContext/useBlog.js → a/AppContext/useApp.js} +0 -0
  15. package/dist/es/a/AppContext/useTheme.js +34 -0
  16. package/dist/es/a/index.js +1 -1
  17. package/dist/es/b/Page/common/PageHelmet/PageHelmet.js +2 -2
  18. package/dist/es/b/SocialMediaButton/SocialMediaButton.js +5 -5
  19. package/dist/es/b/ThemeSelector/ThemeSelector.js +2 -2
  20. package/dist/es/c/SocialMediaShareButton/SocialMediaShareButton.js +10 -4
  21. package/package.json +1 -1
  22. package/src/__snapshots__/Storyshots.test.js.snap +4 -4
  23. package/src/stories/a/{SiteContext.stories.jsx → AppContext.stories.jsx} +8 -8
  24. package/src/stories/b/SocialMediaButton.stories.jsx +6 -6
  25. package/src/stories/b/ThemeSelector.stories.jsx +5 -5
  26. package/src/stories/c/ContentSlides.stories.jsx +6 -6
  27. package/src/ui/a/{SiteContext → AppContext}/Context.js +0 -0
  28. package/src/ui/a/{SiteContext → AppContext}/ContextProvider.jsx +8 -7
  29. package/src/ui/a/AppContext/index.js +5 -0
  30. package/src/ui/a/{SiteContext/useSite.js → AppContext/useApp.js} +0 -0
  31. package/src/ui/a/{SiteContext → AppContext}/useTheme.js +0 -0
  32. package/src/ui/a/index.js +4 -4
  33. package/src/ui/b/Page/common/PageHelmet/PageHelmet.jsx +2 -2
  34. package/src/ui/b/SocialMediaButton/SocialMediaButton.jsx +4 -4
  35. package/src/ui/b/ThemeSelector/ThemeSelector.jsx +2 -2
  36. package/src/ui/c/SocialMediaShareButton/SocialMediaShareButton.jsx +11 -3
  37. package/dist/cjs/a/GradientBackground/GradientBackground.js +0 -140
  38. package/dist/cjs/a/GradientBackground/index.js +0 -15
  39. package/dist/cjs/a/GradientBackground/styles.scss +0 -191
  40. package/dist/cjs/a/Popover/common/Divider/Divider.js +0 -67
  41. package/dist/cjs/a/Popover/common/Divider/index.js +0 -15
  42. package/dist/cjs/a/Popover/common/Item/Item.js +0 -67
  43. package/dist/cjs/a/Popover/common/Item/index.js +0 -15
  44. package/dist/cjs/a/Popover/common/index.js +0 -21
  45. package/dist/cjs/c/AcceptCookies/AcceptCookies.js +0 -134
  46. package/dist/cjs/c/AcceptCookies/index.js +0 -15
  47. package/dist/cjs/c/AcceptCookies/styles.scss +0 -49
  48. package/dist/cjs/c/BlogCategoryButton/BlogCategoryButton.js +0 -95
  49. package/dist/cjs/c/BlogCategoryButton/index.js +0 -15
  50. package/dist/cjs/c/BlogContext/BlogContextProvider.js +0 -63
  51. package/dist/cjs/c/BlogContext/ContextProvider.js +0 -63
  52. package/dist/cjs/c/BlogPost/BlogPost.js +0 -147
  53. package/dist/cjs/c/BlogPost/index.js +0 -15
  54. package/dist/cjs/c/BlogPost/styles.scss +0 -33
  55. package/dist/cjs/c/BlogPostsList/BlogPostsList.js +0 -73
  56. package/dist/cjs/c/BlogPostsList/common/Card/Card.js +0 -170
  57. package/dist/cjs/c/BlogPostsList/common/Card/index.js +0 -15
  58. package/dist/cjs/c/BlogPostsList/common/index.js +0 -13
  59. package/dist/cjs/c/BlogPostsList/index.js +0 -15
  60. package/dist/cjs/c/BlogPostsList/styles.scss +0 -72
  61. package/dist/cjs/c/SiteFooter/SiteFooter.js +0 -73
  62. package/dist/cjs/c/SiteFooter/common/Section/index.js +0 -15
  63. package/dist/cjs/c/SiteFooter/common/index.js +0 -13
  64. package/dist/cjs/c/SiteFooter/index.js +0 -15
  65. package/dist/cjs/c/SiteFooter/styles.scss +0 -34
  66. package/dist/cjs/c/SiteHeaderCTA/SiteHeaderCTA.js +0 -108
  67. package/dist/cjs/c/SiteHeaderCTA/index.js +0 -15
  68. package/dist/cjs/c/SiteHeaderCTA/styles.scss +0 -44
  69. package/dist/cjs/c/SiteMission/SiteMission.js +0 -113
  70. package/dist/cjs/c/SiteMission/index.js +0 -15
  71. package/dist/cjs/c/SiteMission/styles.scss +0 -30
  72. package/dist/cjs/c/SiteNavigation/SiteNavigation.js +0 -130
  73. package/dist/cjs/c/SiteNavigation/index.js +0 -15
  74. package/dist/cjs/c/SiteNavigation/styles.scss +0 -118
  75. package/dist/cjs/c/SiteOnboardingStep/SiteOnboardingStep.js +0 -98
  76. package/dist/cjs/c/SiteOnboardingStep/index.js +0 -15
  77. package/dist/cjs/c/SiteOnboardingStep/styles.scss +0 -51
  78. package/dist/cjs/c/SitePricing/SitePricing.js +0 -108
  79. package/dist/cjs/c/SitePricing/index.js +0 -15
  80. package/dist/cjs/c/SitePricing/styles.scss +0 -73
  81. package/dist/cjs/c/SiteServices/SiteServices.js +0 -211
  82. package/dist/cjs/c/SiteServices/index.js +0 -15
  83. package/dist/cjs/c/SiteServices/styles.scss +0 -138
  84. package/dist/cjs/c/TeamGallery/TeamGallery.js +0 -80
  85. package/dist/cjs/c/TeamGallery/common/PersonCard/PersonCard.js +0 -84
  86. package/dist/cjs/c/TeamGallery/common/PersonCard/index.js +0 -15
  87. package/dist/cjs/c/TeamGallery/common/index.js +0 -13
  88. package/dist/cjs/c/TeamGallery/index.js +0 -15
  89. package/dist/cjs/c/TeamGallery/styles.scss +0 -100
  90. package/dist/cjs/c/Testimonials/Testimonials.js +0 -119
  91. package/dist/cjs/c/Testimonials/index.js +0 -15
  92. package/dist/cjs/c/Testimonials/styles.scss +0 -112
  93. package/dist/cjs/experimental/GradientBackground/GradientBackground.js +0 -98
  94. package/dist/cjs/experimental/GradientBackground/index.js +0 -15
  95. package/dist/cjs/experimental/GradientBackground/styles.scss +0 -64
  96. package/dist/cjs/experimental/index.js +0 -13
  97. package/dist/cjs/f/fields/CheckboxInput/CheckboxInput.js +0 -105
  98. package/dist/cjs/f/fields/CheckboxInput/index.js +0 -15
  99. package/dist/cjs/f/fields/CheckboxInput/styles.scss +0 -28
  100. package/dist/cjs/f/fields/QuerySelect/styles.scss +0 -21
  101. package/dist/cjs/f/fields/RadioInput/RadioInput.js +0 -110
  102. package/dist/cjs/f/fields/RadioInput/index.js +0 -15
  103. package/dist/cjs/f/fields/RadioInput/styles.scss +0 -26
  104. package/dist/cjs/f/fields/TaskRecommendation/TaskRecommendation.js +0 -129
  105. package/dist/cjs/f/fields/TaskRecommendation/index.js +0 -15
  106. package/dist/cjs/f/fields/TaskRecommendation/styles.scss +0 -37
  107. package/dist/cjs/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +0 -131
  108. package/dist/cjs/f/fields/TaskRecommendationInput/index.js +0 -15
  109. package/dist/cjs/f/fields/TaskRecommendationInput/styles.scss +0 -41
  110. package/dist/cjs/f/fields/TextArea/TextArea.js +0 -141
  111. package/dist/cjs/f/fields/TextArea/index.js +0 -15
  112. package/dist/cjs/f/fields/TextArea/styles.scss +0 -19
  113. package/dist/cjs/test/QueryLoader/styles.scss +0 -9
  114. package/dist/es/a/GradientBackground/GradientBackground.js +0 -118
  115. package/dist/es/a/GradientBackground/index.js +0 -2
  116. package/dist/es/a/GradientBackground/styles.scss +0 -191
  117. package/dist/es/a/Popover/common/Divider/Divider.js +0 -47
  118. package/dist/es/a/Popover/common/Divider/index.js +0 -2
  119. package/dist/es/a/Popover/common/Item/Item.js +0 -47
  120. package/dist/es/a/Popover/common/Item/index.js +0 -2
  121. package/dist/es/a/Popover/common/index.js +0 -2
  122. package/dist/es/c/AcceptCookies/AcceptCookies.js +0 -117
  123. package/dist/es/c/AcceptCookies/index.js +0 -2
  124. package/dist/es/c/AcceptCookies/styles.scss +0 -49
  125. package/dist/es/c/BlogCategoryButton/BlogCategoryButton.js +0 -68
  126. package/dist/es/c/BlogCategoryButton/index.js +0 -2
  127. package/dist/es/c/BlogContext/BlogContextProvider.js +0 -45
  128. package/dist/es/c/BlogContext/ContextProvider.js +0 -45
  129. package/dist/es/c/BlogContext/index.js +0 -4
  130. package/dist/es/c/BlogPost/BlogPost.js +0 -128
  131. package/dist/es/c/BlogPost/index.js +0 -2
  132. package/dist/es/c/BlogPost/styles.scss +0 -33
  133. package/dist/es/c/BlogPostsList/BlogPostsList.js +0 -56
  134. package/dist/es/c/BlogPostsList/common/Card/Card.js +0 -143
  135. package/dist/es/c/BlogPostsList/common/Card/index.js +0 -2
  136. package/dist/es/c/BlogPostsList/common/index.js +0 -1
  137. package/dist/es/c/BlogPostsList/index.js +0 -2
  138. package/dist/es/c/BlogPostsList/styles.scss +0 -72
  139. package/dist/es/c/SiteFooter/SiteFooter.js +0 -56
  140. package/dist/es/c/SiteFooter/common/Section/Section.js +0 -73
  141. package/dist/es/c/SiteFooter/common/Section/index.js +0 -2
  142. package/dist/es/c/SiteFooter/common/index.js +0 -1
  143. package/dist/es/c/SiteFooter/index.js +0 -2
  144. package/dist/es/c/SiteFooter/styles.scss +0 -34
  145. package/dist/es/c/SiteHeaderCTA/SiteHeaderCTA.js +0 -92
  146. package/dist/es/c/SiteHeaderCTA/index.js +0 -2
  147. package/dist/es/c/SiteHeaderCTA/styles.scss +0 -44
  148. package/dist/es/c/SiteMission/SiteMission.js +0 -96
  149. package/dist/es/c/SiteMission/index.js +0 -2
  150. package/dist/es/c/SiteMission/styles.scss +0 -30
  151. package/dist/es/c/SiteNavigation/SiteNavigation.js +0 -111
  152. package/dist/es/c/SiteNavigation/index.js +0 -2
  153. package/dist/es/c/SiteNavigation/styles.scss +0 -118
  154. package/dist/es/c/SiteOnboardingStep/SiteOnboardingStep.js +0 -81
  155. package/dist/es/c/SiteOnboardingStep/index.js +0 -2
  156. package/dist/es/c/SiteOnboardingStep/styles.scss +0 -51
  157. package/dist/es/c/SitePricing/SitePricing.js +0 -91
  158. package/dist/es/c/SitePricing/index.js +0 -2
  159. package/dist/es/c/SitePricing/styles.scss +0 -73
  160. package/dist/es/c/SiteServices/SiteServices.js +0 -195
  161. package/dist/es/c/SiteServices/index.js +0 -2
  162. package/dist/es/c/SiteServices/styles.scss +0 -138
  163. package/dist/es/c/TeamGallery/TeamGallery.js +0 -64
  164. package/dist/es/c/TeamGallery/common/PersonCard/PersonCard.js +0 -64
  165. package/dist/es/c/TeamGallery/common/PersonCard/index.js +0 -2
  166. package/dist/es/c/TeamGallery/common/index.js +0 -1
  167. package/dist/es/c/TeamGallery/index.js +0 -2
  168. package/dist/es/c/TeamGallery/styles.scss +0 -100
  169. package/dist/es/c/Testimonials/Testimonials.js +0 -99
  170. package/dist/es/c/Testimonials/index.js +0 -2
  171. package/dist/es/c/Testimonials/styles.scss +0 -112
  172. package/dist/es/experimental/GradientBackground/GradientBackground.js +0 -76
  173. package/dist/es/experimental/GradientBackground/index.js +0 -2
  174. package/dist/es/experimental/GradientBackground/styles.scss +0 -64
  175. package/dist/es/experimental/index.js +0 -1
  176. package/dist/es/f/fields/CheckboxInput/CheckboxInput.js +0 -85
  177. package/dist/es/f/fields/CheckboxInput/index.js +0 -2
  178. package/dist/es/f/fields/CheckboxInput/styles.scss +0 -28
  179. package/dist/es/f/fields/QuerySelect/styles.scss +0 -21
  180. package/dist/es/f/fields/RadioInput/RadioInput.js +0 -90
  181. package/dist/es/f/fields/RadioInput/index.js +0 -2
  182. package/dist/es/f/fields/RadioInput/styles.scss +0 -26
  183. package/dist/es/f/fields/TaskRecommendation/TaskRecommendation.js +0 -111
  184. package/dist/es/f/fields/TaskRecommendation/index.js +0 -2
  185. package/dist/es/f/fields/TaskRecommendation/styles.scss +0 -37
  186. package/dist/es/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +0 -111
  187. package/dist/es/f/fields/TaskRecommendationInput/index.js +0 -2
  188. package/dist/es/f/fields/TaskRecommendationInput/styles.scss +0 -41
  189. package/dist/es/f/fields/TextArea/TextArea.js +0 -124
  190. package/dist/es/f/fields/TextArea/index.js +0 -2
  191. package/dist/es/f/fields/TextArea/styles.scss +0 -19
  192. package/dist/es/test/QueryLoader/styles.scss +0 -9
  193. package/src/ui/a/SiteContext/index.js +0 -5
@@ -9,9 +9,9 @@ var React = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _bem = _interopRequireDefault(require("@pareto-engineering/bem"));
12
+ var _useTheme = _interopRequireDefault(require("./useTheme"));
13
13
 
14
- var _b = require("../../../../b");
14
+ var _Context = _interopRequireDefault(require("./Context"));
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
@@ -25,71 +25,72 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
25
25
 
26
26
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
27
 
28
- var baseClassName = _bem.default.base;
29
- console.log(_bem.default);
30
- var componentClassName = _bem.default.elementSection;
31
- /**
32
- * This is the component description.
33
- */
28
+ // Component-level imports
29
+ // Helper Definitions
30
+ var reducer = (state, action) => {
31
+ switch (action.type) {
32
+ case 'UPDATE_STATE':
33
+ return _objectSpread(_objectSpread({}, state), action.payload);
34
34
 
35
- var Section = _ref => {
35
+ default:
36
+ return state;
37
+ }
38
+ };
39
+
40
+ var AppContextProvider = _ref => {
36
41
  var {
37
- id,
38
- className: userClassName,
39
- style,
40
42
  children,
41
- title,
42
- span // ...otherProps
43
+ initialTheme,
44
+ config,
45
+ initialState // ...otherProps
43
46
 
44
47
  } = _ref;
45
- console.log(1);
46
- return /*#__PURE__*/React.createElement("div", {
47
- id: id,
48
- className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
49
- style: _objectSpread({
50
- '--span': span
51
- }, style) // {...otherProps}
52
-
53
- }, title && /*#__PURE__*/React.createElement(_b.Title, {
54
- headingAs: "p",
55
- headingClassName: "h4 c-on-y",
56
- heading: title
57
- }), children);
48
+ var theme = (0, _useTheme.default)(initialTheme);
49
+ var [state, dispatch] = (0, React.useReducer)(reducer, initialState);
50
+ return /*#__PURE__*/React.createElement(_Context.default.Provider, {
51
+ value: _objectSpread(_objectSpread({
52
+ state,
53
+ dispatch
54
+ }, config), theme)
55
+ }, children);
58
56
  };
59
57
 
60
- Section.propTypes = {
61
- /**
62
- * The HTML id for this element
63
- */
64
- id: _propTypes.default.string,
65
-
66
- /**
67
- * The HTML class names for this element
68
- */
69
- className: _propTypes.default.string,
70
-
58
+ AppContextProvider.propTypes = {
71
59
  /**
72
- * The React-written, css properties for this element.
60
+ * The children JSX
73
61
  */
74
- style: _propTypes.default.objectOf(_propTypes.default.string),
62
+ children: _propTypes.default.node,
75
63
 
76
64
  /**
77
- * The children JSX
65
+ * The initial theme for the website. If undefined, fallbacks on system preference.
78
66
  */
79
- children: _propTypes.default.node,
67
+ initialTheme: _propTypes.default.string,
80
68
 
81
69
  /**
82
- * The title of the footer section
70
+ * A dictionnary containing settings and preferences to be used application-wide
83
71
  */
84
- title: _propTypes.default.node,
72
+ config: _propTypes.default.shape({
73
+ APP: _propTypes.default.shape({
74
+ NAME: _propTypes.default.string.isRequired,
75
+ CANONICAL: _propTypes.default.string.isRequired,
76
+ SUPPORT_EMAIL: _propTypes.default.string,
77
+ TITLE_SUFFIX: _propTypes.default.string
78
+ }),
79
+ SOCIAL: _propTypes.default.shape({
80
+ FACEBOOK: _propTypes.default.string,
81
+ INSTAGRAM: _propTypes.default.string,
82
+ YOUTUBE: _propTypes.default.string
83
+ }),
84
+ CONSTANTS: _propTypes.default.shape({})
85
+ }).isRequired,
85
86
 
86
87
  /**
87
- * How many fractional units should the column width be, on desktop
88
+ * Application context initial state
88
89
  */
89
- span: _propTypes.default.number
90
+ initialState: _propTypes.default.objectOf(_propTypes.default.string)
90
91
  };
91
- Section.defaultProps = {
92
- span: 1
92
+ AppContextProvider.defaultProps = {
93
+ initialState: {}
93
94
  };
94
- var _default = Section;
95
+ var _default = AppContextProvider;
95
96
  exports.default = _default;
@@ -3,22 +3,28 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "BlogContext", {
6
+ Object.defineProperty(exports, "AppContext", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
9
  return _Context.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "BlogContextProvider", {
12
+ Object.defineProperty(exports, "AppContextProvider", {
13
13
  enumerable: true,
14
14
  get: function get() {
15
15
  return _ContextProvider.default;
16
16
  }
17
17
  });
18
- Object.defineProperty(exports, "useBlog", {
18
+ Object.defineProperty(exports, "useApp", {
19
19
  enumerable: true,
20
20
  get: function get() {
21
- return _useBlog.default;
21
+ return _useApp.default;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "useTheme", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _useTheme.default;
22
28
  }
23
29
  });
24
30
 
@@ -26,6 +32,8 @@ var _Context = _interopRequireDefault(require("./Context"));
26
32
 
27
33
  var _ContextProvider = _interopRequireDefault(require("./ContextProvider"));
28
34
 
29
- var _useBlog = _interopRequireDefault(require("./useBlog"));
35
+ var _useApp = _interopRequireDefault(require("./useApp"));
36
+
37
+ var _useTheme = _interopRequireDefault(require("./useTheme"));
30
38
 
31
39
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _default = function _default(initialTheme) {
11
+ var storageKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'theme';
12
+ var isClient = typeof window === 'object';
13
+ var [preferredTheme, setPreferredTheme] = (0, _react.useState)(initialTheme);
14
+ var [userTheme, setUserTheme] = (0, _react.useState)();
15
+ (0, _react.useEffect)(() => {
16
+ var storage = window.localStorage;
17
+
18
+ if (isClient) {
19
+ var storedTheme = window.localStorage.getItem(storageKey); // console.log(storedTheme, storedTheme != userTheme)
20
+
21
+ if (storedTheme && storedTheme !== userTheme) {
22
+ // console.warn('Theme load')
23
+ setPreferredTheme(storedTheme);
24
+ setUserTheme(storedTheme);
25
+ } else if (preferredTheme && preferredTheme.length && preferredTheme !== 'system') {
26
+ setUserTheme(preferredTheme);
27
+ storage.setItem(storageKey, preferredTheme); // console.warn('theme change', preferredTheme)
28
+ } else {
29
+ setUserTheme(window.matchMedia('(prefers-color-scheme:dark)').matches ? 'dark' : 'light');
30
+ storage.removeItem(storageKey); // console.warn('theme reset')
31
+ }
32
+ } else {
33
+ setUserTheme('light');
34
+ }
35
+ }, [preferredTheme, isClient]);
36
+ var isTheme = (0, _react.useCallback)(theme => userTheme === theme || undefined, [userTheme]);
37
+ return {
38
+ userTheme,
39
+ preferredTheme,
40
+ setPreferredTheme,
41
+ isTheme
42
+ };
43
+ };
44
+
45
+ exports.default = _default;
@@ -21,28 +21,28 @@ Object.defineProperty(exports, "IconList", {
21
21
  return _IconList.IconList;
22
22
  }
23
23
  });
24
- Object.defineProperty(exports, "SiteContext", {
24
+ Object.defineProperty(exports, "AppContext", {
25
25
  enumerable: true,
26
26
  get: function get() {
27
- return _SiteContext.SiteContext;
27
+ return _AppContext.AppContext;
28
28
  }
29
29
  });
30
- Object.defineProperty(exports, "SiteContextProvider", {
30
+ Object.defineProperty(exports, "AppContextProvider", {
31
31
  enumerable: true,
32
32
  get: function get() {
33
- return _SiteContext.SiteContextProvider;
33
+ return _AppContext.AppContextProvider;
34
34
  }
35
35
  });
36
- Object.defineProperty(exports, "useSite", {
36
+ Object.defineProperty(exports, "useApp", {
37
37
  enumerable: true,
38
38
  get: function get() {
39
- return _SiteContext.useSite;
39
+ return _AppContext.useApp;
40
40
  }
41
41
  });
42
42
  Object.defineProperty(exports, "useTheme", {
43
43
  enumerable: true,
44
44
  get: function get() {
45
- return _SiteContext.useTheme;
45
+ return _AppContext.useTheme;
46
46
  }
47
47
  });
48
48
  Object.defineProperty(exports, "ProgressBar", {
@@ -184,7 +184,7 @@ var _DashboardNavbar = require("./DashboardNavbar");
184
184
 
185
185
  var _IconList = require("./IconList");
186
186
 
187
- var _SiteContext = require("./SiteContext");
187
+ var _AppContext = require("./AppContext");
188
188
 
189
189
  var _ProgressBar = require("./ProgressBar");
190
190
 
@@ -132,7 +132,7 @@ var PageHelmet = _ref => {
132
132
  var props = _extends({}, _ref);
133
133
 
134
134
  // const intl = useIntl()
135
- var context = (0, _a.useSite)();
135
+ var context = (0, _a.useApp)();
136
136
  var HelmetContent = (0, React.useMemo)(() => helmetMap.reduce(
137
137
  /* eslint-disable no-unused-vars -- TODO add test or ssr mode */
138
138
  (a, _ref2) => {
@@ -51,11 +51,11 @@ var defaultsMap = {
51
51
  /**
52
52
  * This is the component description.
53
53
  * This component takes `y` as the default color and `x` as the hover color.
54
- * This components needs to be wrapped within a `SiteContextProvider`.
54
+ * This components needs to be wrapped within a `AppContextProvider`.
55
55
  */
56
56
 
57
57
  var SocialMediaButton = _ref => {
58
- var _siteContext$SOCIAL;
58
+ var _applicationContext$S;
59
59
 
60
60
  var {
61
61
  id,
@@ -69,12 +69,12 @@ var SocialMediaButton = _ref => {
69
69
  } = _ref,
70
70
  otherProps = _objectWithoutProperties(_ref, _excluded);
71
71
 
72
- var siteContext = (0, _a.useSite)();
72
+ var applicationContext = (0, _a.useApp)();
73
73
  (0, React.useLayoutEffect)(() => {
74
74
  Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
75
75
  }, []);
76
76
  var content = type && defaultsMap[type];
77
- var href = link || (siteContext === null || siteContext === void 0 ? void 0 : (_siteContext$SOCIAL = siteContext.SOCIAL) === null || _siteContext$SOCIAL === void 0 ? void 0 : _siteContext$SOCIAL[content.link]);
77
+ var href = link || (applicationContext === null || applicationContext === void 0 ? void 0 : (_applicationContext$S = applicationContext.SOCIAL) === null || _applicationContext$S === void 0 ? void 0 : _applicationContext$S[content.link]);
78
78
  return /*#__PURE__*/React.createElement("a", {
79
79
  href: href,
80
80
  target: "_blank",
@@ -38,7 +38,7 @@ var ThemeSelector = _ref => {
38
38
  var {
39
39
  userTheme,
40
40
  setPreferredTheme
41
- } = (0, _a.useSite)();
41
+ } = (0, _a.useApp)();
42
42
  (0, React.useLayoutEffect)(() => {
43
43
  Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
44
44
  }, []);
@@ -38,16 +38,22 @@ var SocialMediaShareButton = _ref => {
38
38
  Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
39
39
  }, []);
40
40
  var isServer = typeof window === 'undefined';
41
- var title = isServer ? '' : document.title;
42
- var link = isServer ? '' : window.location.href;
41
+ var link = isServer ? '' : window.location.href; // We can pass additional text to the social media share buttons such as the title.
42
+ // See commented code below for an example on how to pass text.
43
+ // It is important we encode the text with the encodeURIComponent function to pass
44
+ // special characters (such as |, &, etc.) properly through the URL.
45
+ // const title = isServer ? '' : encodeURIComponent(document.title)
46
+
43
47
  var defaultsMap = {
44
48
  facebook: {
45
49
  icon: 'f',
46
- link: "https://www.facebook.com/sharer/sharer.php?u=".concat(link, "&quote=").concat(title)
50
+ link: "https://www.facebook.com/sharer/sharer.php?u=".concat(link) // link: `https://www.facebook.com/sharer/sharer.php?u=${link}&quote=${title}`,
51
+
47
52
  },
48
53
  twitter: {
49
54
  icon: 't',
50
- link: "https://twitter.com/intent/tweet?text=".concat(title, "&url=").concat(link)
55
+ link: "https://twitter.com/intent/tweet?url=".concat(link) // link: `https://twitter.com/intent/tweet?text=${title}&url=${link}`,
56
+
51
57
  }
52
58
  };
53
59
  return /*#__PURE__*/React.createElement("a", {
@@ -0,0 +1,78 @@
1
+ /* @pareto-engineering/generator-front 0.2.3 */
2
+ import * as React from 'react';
3
+ import { useReducer } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import useTheme from "./useTheme"; // Package-level Imports
6
+
7
+ import Context from "./Context"; // Component-level imports
8
+ // Helper Definitions
9
+
10
+ const reducer = (state, action) => {
11
+ switch (action.type) {
12
+ case 'UPDATE_STATE':
13
+ return { ...state,
14
+ ...action.payload
15
+ };
16
+
17
+ default:
18
+ return state;
19
+ }
20
+ };
21
+
22
+ const AppContextProvider = ({
23
+ children,
24
+ initialTheme,
25
+ config,
26
+ initialState // ...otherProps
27
+
28
+ }) => {
29
+ const theme = useTheme(initialTheme);
30
+ const [state, dispatch] = useReducer(reducer, initialState);
31
+ return /*#__PURE__*/React.createElement(Context.Provider, {
32
+ value: {
33
+ state,
34
+ dispatch,
35
+ ...config,
36
+ ...theme
37
+ }
38
+ }, children);
39
+ };
40
+
41
+ AppContextProvider.propTypes = {
42
+ /**
43
+ * The children JSX
44
+ */
45
+ children: PropTypes.node,
46
+
47
+ /**
48
+ * The initial theme for the website. If undefined, fallbacks on system preference.
49
+ */
50
+ initialTheme: PropTypes.string,
51
+
52
+ /**
53
+ * A dictionnary containing settings and preferences to be used application-wide
54
+ */
55
+ config: PropTypes.shape({
56
+ APP: PropTypes.shape({
57
+ NAME: PropTypes.string.isRequired,
58
+ CANONICAL: PropTypes.string.isRequired,
59
+ SUPPORT_EMAIL: PropTypes.string,
60
+ TITLE_SUFFIX: PropTypes.string
61
+ }),
62
+ SOCIAL: PropTypes.shape({
63
+ FACEBOOK: PropTypes.string,
64
+ INSTAGRAM: PropTypes.string,
65
+ YOUTUBE: PropTypes.string
66
+ }),
67
+ CONSTANTS: PropTypes.shape({})
68
+ }).isRequired,
69
+
70
+ /**
71
+ * Application context initial state
72
+ */
73
+ initialState: PropTypes.objectOf(PropTypes.string)
74
+ };
75
+ AppContextProvider.defaultProps = {
76
+ initialState: {}
77
+ };
78
+ export default AppContextProvider;
@@ -0,0 +1,5 @@
1
+ /* @pareto-engineering/generator-front 0.2.3 */
2
+ export { default as AppContext } from "./Context";
3
+ export { default as AppContextProvider } from "./ContextProvider";
4
+ export { default as useApp } from "./useApp";
5
+ export { default as useTheme } from "./useTheme";
@@ -0,0 +1,34 @@
1
+ import { useCallback, useState, useEffect } from 'react';
2
+ export default ((initialTheme, storageKey = 'theme') => {
3
+ const isClient = typeof window === 'object';
4
+ const [preferredTheme, setPreferredTheme] = useState(initialTheme);
5
+ const [userTheme, setUserTheme] = useState();
6
+ useEffect(() => {
7
+ const storage = window.localStorage;
8
+
9
+ if (isClient) {
10
+ const storedTheme = window.localStorage.getItem(storageKey); // console.log(storedTheme, storedTheme != userTheme)
11
+
12
+ if (storedTheme && storedTheme !== userTheme) {
13
+ // console.warn('Theme load')
14
+ setPreferredTheme(storedTheme);
15
+ setUserTheme(storedTheme);
16
+ } else if (preferredTheme && preferredTheme.length && preferredTheme !== 'system') {
17
+ setUserTheme(preferredTheme);
18
+ storage.setItem(storageKey, preferredTheme); // console.warn('theme change', preferredTheme)
19
+ } else {
20
+ setUserTheme(window.matchMedia('(prefers-color-scheme:dark)').matches ? 'dark' : 'light');
21
+ storage.removeItem(storageKey); // console.warn('theme reset')
22
+ }
23
+ } else {
24
+ setUserTheme('light');
25
+ }
26
+ }, [preferredTheme, isClient]);
27
+ const isTheme = useCallback(theme => userTheme === theme || undefined, [userTheme]);
28
+ return {
29
+ userTheme,
30
+ preferredTheme,
31
+ setPreferredTheme,
32
+ isTheme
33
+ };
34
+ });
@@ -1,7 +1,7 @@
1
1
  export { SVG } from "./SVG";
2
2
  export { DashboardNavbar } from "./DashboardNavbar";
3
3
  export { IconList } from "./IconList";
4
- export { SiteContext, SiteContextProvider, useSite, useTheme } from "./SiteContext";
4
+ export { AppContext, AppContextProvider, useApp, useTheme } from "./AppContext";
5
5
  export { ProgressBar } from "./ProgressBar";
6
6
  export { TeamInfo } from "./TeamInfo";
7
7
  export { AnimatedCounter } from "./AnimatedCounter";
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { useMemo } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import { Helmet } from 'react-helmet';
6
- import { useSite } from "../../../../a";
6
+ import { useApp } from "../../../../a";
7
7
  const helmetMap = [{
8
8
  variables: ['robots'],
9
9
  render: v => /*#__PURE__*/React.createElement("meta", {
@@ -117,7 +117,7 @@ const helmetMap = [{
117
117
  const PageHelmet = ({ ...props
118
118
  }) => {
119
119
  // const intl = useIntl()
120
- const context = useSite();
120
+ const context = useApp();
121
121
  const HelmetContent = useMemo(() => helmetMap.reduce(
122
122
  /* eslint-disable no-unused-vars -- TODO add test or ssr mode */
123
123
  (a, {
@@ -5,7 +5,7 @@ import * as React from 'react';
5
5
  import { useLayoutEffect } from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import styleNames from '@pareto-engineering/bem';
8
- import { useSite } from "../../a"; // Local Definitions
8
+ import { useApp } from "../../a"; // Local Definitions
9
9
 
10
10
  const baseClassName = styleNames.base;
11
11
  const componentClassName = 'social-media-button';
@@ -30,7 +30,7 @@ const defaultsMap = {
30
30
  /**
31
31
  * This is the component description.
32
32
  * This component takes `y` as the default color and `x` as the hover color.
33
- * This components needs to be wrapped within a `SiteContextProvider`.
33
+ * This components needs to be wrapped within a `AppContextProvider`.
34
34
  */
35
35
 
36
36
  const SocialMediaButton = ({
@@ -44,14 +44,14 @@ const SocialMediaButton = ({
44
44
  isTransparent,
45
45
  ...otherProps
46
46
  }) => {
47
- var _siteContext$SOCIAL;
47
+ var _applicationContext$S;
48
48
 
49
- const siteContext = useSite();
49
+ const applicationContext = useApp();
50
50
  useLayoutEffect(() => {
51
51
  import("./styles.scss");
52
52
  }, []);
53
53
  const content = type && defaultsMap[type];
54
- const href = link || (siteContext === null || siteContext === void 0 ? void 0 : (_siteContext$SOCIAL = siteContext.SOCIAL) === null || _siteContext$SOCIAL === void 0 ? void 0 : _siteContext$SOCIAL[content.link]);
54
+ const href = link || (applicationContext === null || applicationContext === void 0 ? void 0 : (_applicationContext$S = applicationContext.SOCIAL) === null || _applicationContext$S === void 0 ? void 0 : _applicationContext$S[content.link]);
55
55
  return /*#__PURE__*/React.createElement("a", {
56
56
  href: href,
57
57
  target: "_blank",
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { useLayoutEffect, useCallback } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import styleNames from '@pareto-engineering/bem';
6
- import { useSite } from "../../a"; // Local Definitions
6
+ import { useApp } from "../../a"; // Local Definitions
7
7
 
8
8
  const baseClassName = styleNames.base;
9
9
  const componentClassName = 'theme-selector';
@@ -22,7 +22,7 @@ const ThemeSelector = ({
22
22
  const {
23
23
  userTheme,
24
24
  setPreferredTheme
25
- } = useSite();
25
+ } = useApp();
26
26
  useLayoutEffect(() => {
27
27
  import("./styles.scss");
28
28
  }, []);
@@ -23,16 +23,22 @@ const SocialMediaShareButton = ({
23
23
  import("./styles.scss");
24
24
  }, []);
25
25
  const isServer = typeof window === 'undefined';
26
- const title = isServer ? '' : document.title;
27
- const link = isServer ? '' : window.location.href;
26
+ const link = isServer ? '' : window.location.href; // We can pass additional text to the social media share buttons such as the title.
27
+ // See commented code below for an example on how to pass text.
28
+ // It is important we encode the text with the encodeURIComponent function to pass
29
+ // special characters (such as |, &, etc.) properly through the URL.
30
+ // const title = isServer ? '' : encodeURIComponent(document.title)
31
+
28
32
  const defaultsMap = {
29
33
  facebook: {
30
34
  icon: 'f',
31
- link: `https://www.facebook.com/sharer/sharer.php?u=${link}&quote=${title}`
35
+ link: `https://www.facebook.com/sharer/sharer.php?u=${link}` // link: `https://www.facebook.com/sharer/sharer.php?u=${link}&quote=${title}`,
36
+
32
37
  },
33
38
  twitter: {
34
39
  icon: 't',
35
- link: `https://twitter.com/intent/tweet?text=${title}&url=${link}`
40
+ link: `https://twitter.com/intent/tweet?url=${link}` // link: `https://twitter.com/intent/tweet?text=${title}&url=${link}`,
41
+
36
42
  }
37
43
  };
38
44
  return /*#__PURE__*/React.createElement("a", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "2.0.0-alpha.50",
3
+ "version": "2.0.0-alpha.53",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -63,6 +63,8 @@ exports[`Storyshots a/AnimatedCounter Before And After 1`] = `
63
63
  </div>
64
64
  `;
65
65
 
66
+ exports[`Storyshots a/AppContext Base 1`] = `"Sample AppContext"`;
67
+
66
68
  exports[`Storyshots a/BackgroundGradient Base 1`] = `
67
69
  <div
68
70
  className="y-background4"
@@ -2436,8 +2438,6 @@ exports[`Storyshots a/Shapes Triangle 1`] = `
2436
2438
  </div>
2437
2439
  `;
2438
2440
 
2439
- exports[`Storyshots a/SiteContext Base 1`] = `"Sample SiteContext"`;
2440
-
2441
2441
  exports[`Storyshots a/SnapScroller Base 1`] = `
2442
2442
  <div
2443
2443
  className="base snap-scroller u1 pv-u"
@@ -10195,7 +10195,7 @@ exports[`Storyshots c/SocialMediaShareButton Base 1`] = `
10195
10195
  <div>
10196
10196
  <a
10197
10197
  className="base social-media-share-button x-facebook"
10198
- href="https://www.facebook.com/sharer/sharer.php?u=http://localhost/#/welcome&quote="
10198
+ href="https://www.facebook.com/sharer/sharer.php?u=http://localhost/#/welcome"
10199
10199
  rel="noreferrer"
10200
10200
  target="_blank"
10201
10201
  >
@@ -10207,7 +10207,7 @@ exports[`Storyshots c/SocialMediaShareButton Base 1`] = `
10207
10207
  </a>
10208
10208
  <a
10209
10209
  className="base social-media-share-button x-twitter"
10210
- href="https://twitter.com/intent/tweet?text=&url=http://localhost/#/welcome"
10210
+ href="https://twitter.com/intent/tweet?url=http://localhost/#/welcome"
10211
10211
  rel="noreferrer"
10212
10212
  target="_blank"
10213
10213
  >