@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.
- package/dist/cjs/{c/BlogContext → a/AppContext}/Context.js +0 -0
- package/dist/cjs/{c/SiteFooter/common/Section/Section.js → a/AppContext/ContextProvider.js} +50 -49
- package/dist/cjs/{c/BlogContext → a/AppContext}/index.js +13 -5
- package/dist/cjs/{c/BlogContext/useBlog.js → a/AppContext/useApp.js} +0 -0
- package/dist/cjs/a/AppContext/useTheme.js +45 -0
- package/dist/cjs/a/index.js +8 -8
- package/dist/cjs/b/Page/common/PageHelmet/PageHelmet.js +1 -1
- package/dist/cjs/b/SocialMediaButton/SocialMediaButton.js +4 -4
- package/dist/cjs/b/ThemeSelector/ThemeSelector.js +1 -1
- package/dist/cjs/c/SocialMediaShareButton/SocialMediaShareButton.js +10 -4
- package/dist/es/{c/BlogContext → a/AppContext}/Context.js +0 -0
- package/dist/es/a/AppContext/ContextProvider.js +78 -0
- package/dist/es/a/AppContext/index.js +5 -0
- package/dist/es/{c/BlogContext/useBlog.js → a/AppContext/useApp.js} +0 -0
- package/dist/es/a/AppContext/useTheme.js +34 -0
- package/dist/es/a/index.js +1 -1
- package/dist/es/b/Page/common/PageHelmet/PageHelmet.js +2 -2
- package/dist/es/b/SocialMediaButton/SocialMediaButton.js +5 -5
- package/dist/es/b/ThemeSelector/ThemeSelector.js +2 -2
- package/dist/es/c/SocialMediaShareButton/SocialMediaShareButton.js +10 -4
- package/package.json +1 -1
- package/src/__snapshots__/Storyshots.test.js.snap +4 -4
- package/src/stories/a/{SiteContext.stories.jsx → AppContext.stories.jsx} +8 -8
- package/src/stories/b/SocialMediaButton.stories.jsx +6 -6
- package/src/stories/b/ThemeSelector.stories.jsx +5 -5
- package/src/stories/c/ContentSlides.stories.jsx +6 -6
- package/src/ui/a/{SiteContext → AppContext}/Context.js +0 -0
- package/src/ui/a/{SiteContext → AppContext}/ContextProvider.jsx +8 -7
- package/src/ui/a/AppContext/index.js +5 -0
- package/src/ui/a/{SiteContext/useSite.js → AppContext/useApp.js} +0 -0
- package/src/ui/a/{SiteContext → AppContext}/useTheme.js +0 -0
- package/src/ui/a/index.js +4 -4
- package/src/ui/b/Page/common/PageHelmet/PageHelmet.jsx +2 -2
- package/src/ui/b/SocialMediaButton/SocialMediaButton.jsx +4 -4
- package/src/ui/b/ThemeSelector/ThemeSelector.jsx +2 -2
- package/src/ui/c/SocialMediaShareButton/SocialMediaShareButton.jsx +11 -3
- package/dist/cjs/a/GradientBackground/GradientBackground.js +0 -140
- package/dist/cjs/a/GradientBackground/index.js +0 -15
- package/dist/cjs/a/GradientBackground/styles.scss +0 -191
- package/dist/cjs/a/Popover/common/Divider/Divider.js +0 -67
- package/dist/cjs/a/Popover/common/Divider/index.js +0 -15
- package/dist/cjs/a/Popover/common/Item/Item.js +0 -67
- package/dist/cjs/a/Popover/common/Item/index.js +0 -15
- package/dist/cjs/a/Popover/common/index.js +0 -21
- package/dist/cjs/c/AcceptCookies/AcceptCookies.js +0 -134
- package/dist/cjs/c/AcceptCookies/index.js +0 -15
- package/dist/cjs/c/AcceptCookies/styles.scss +0 -49
- package/dist/cjs/c/BlogCategoryButton/BlogCategoryButton.js +0 -95
- package/dist/cjs/c/BlogCategoryButton/index.js +0 -15
- package/dist/cjs/c/BlogContext/BlogContextProvider.js +0 -63
- package/dist/cjs/c/BlogContext/ContextProvider.js +0 -63
- package/dist/cjs/c/BlogPost/BlogPost.js +0 -147
- package/dist/cjs/c/BlogPost/index.js +0 -15
- package/dist/cjs/c/BlogPost/styles.scss +0 -33
- package/dist/cjs/c/BlogPostsList/BlogPostsList.js +0 -73
- package/dist/cjs/c/BlogPostsList/common/Card/Card.js +0 -170
- package/dist/cjs/c/BlogPostsList/common/Card/index.js +0 -15
- package/dist/cjs/c/BlogPostsList/common/index.js +0 -13
- package/dist/cjs/c/BlogPostsList/index.js +0 -15
- package/dist/cjs/c/BlogPostsList/styles.scss +0 -72
- package/dist/cjs/c/SiteFooter/SiteFooter.js +0 -73
- package/dist/cjs/c/SiteFooter/common/Section/index.js +0 -15
- package/dist/cjs/c/SiteFooter/common/index.js +0 -13
- package/dist/cjs/c/SiteFooter/index.js +0 -15
- package/dist/cjs/c/SiteFooter/styles.scss +0 -34
- package/dist/cjs/c/SiteHeaderCTA/SiteHeaderCTA.js +0 -108
- package/dist/cjs/c/SiteHeaderCTA/index.js +0 -15
- package/dist/cjs/c/SiteHeaderCTA/styles.scss +0 -44
- package/dist/cjs/c/SiteMission/SiteMission.js +0 -113
- package/dist/cjs/c/SiteMission/index.js +0 -15
- package/dist/cjs/c/SiteMission/styles.scss +0 -30
- package/dist/cjs/c/SiteNavigation/SiteNavigation.js +0 -130
- package/dist/cjs/c/SiteNavigation/index.js +0 -15
- package/dist/cjs/c/SiteNavigation/styles.scss +0 -118
- package/dist/cjs/c/SiteOnboardingStep/SiteOnboardingStep.js +0 -98
- package/dist/cjs/c/SiteOnboardingStep/index.js +0 -15
- package/dist/cjs/c/SiteOnboardingStep/styles.scss +0 -51
- package/dist/cjs/c/SitePricing/SitePricing.js +0 -108
- package/dist/cjs/c/SitePricing/index.js +0 -15
- package/dist/cjs/c/SitePricing/styles.scss +0 -73
- package/dist/cjs/c/SiteServices/SiteServices.js +0 -211
- package/dist/cjs/c/SiteServices/index.js +0 -15
- package/dist/cjs/c/SiteServices/styles.scss +0 -138
- package/dist/cjs/c/TeamGallery/TeamGallery.js +0 -80
- package/dist/cjs/c/TeamGallery/common/PersonCard/PersonCard.js +0 -84
- package/dist/cjs/c/TeamGallery/common/PersonCard/index.js +0 -15
- package/dist/cjs/c/TeamGallery/common/index.js +0 -13
- package/dist/cjs/c/TeamGallery/index.js +0 -15
- package/dist/cjs/c/TeamGallery/styles.scss +0 -100
- package/dist/cjs/c/Testimonials/Testimonials.js +0 -119
- package/dist/cjs/c/Testimonials/index.js +0 -15
- package/dist/cjs/c/Testimonials/styles.scss +0 -112
- package/dist/cjs/experimental/GradientBackground/GradientBackground.js +0 -98
- package/dist/cjs/experimental/GradientBackground/index.js +0 -15
- package/dist/cjs/experimental/GradientBackground/styles.scss +0 -64
- package/dist/cjs/experimental/index.js +0 -13
- package/dist/cjs/f/fields/CheckboxInput/CheckboxInput.js +0 -105
- package/dist/cjs/f/fields/CheckboxInput/index.js +0 -15
- package/dist/cjs/f/fields/CheckboxInput/styles.scss +0 -28
- package/dist/cjs/f/fields/QuerySelect/styles.scss +0 -21
- package/dist/cjs/f/fields/RadioInput/RadioInput.js +0 -110
- package/dist/cjs/f/fields/RadioInput/index.js +0 -15
- package/dist/cjs/f/fields/RadioInput/styles.scss +0 -26
- package/dist/cjs/f/fields/TaskRecommendation/TaskRecommendation.js +0 -129
- package/dist/cjs/f/fields/TaskRecommendation/index.js +0 -15
- package/dist/cjs/f/fields/TaskRecommendation/styles.scss +0 -37
- package/dist/cjs/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +0 -131
- package/dist/cjs/f/fields/TaskRecommendationInput/index.js +0 -15
- package/dist/cjs/f/fields/TaskRecommendationInput/styles.scss +0 -41
- package/dist/cjs/f/fields/TextArea/TextArea.js +0 -141
- package/dist/cjs/f/fields/TextArea/index.js +0 -15
- package/dist/cjs/f/fields/TextArea/styles.scss +0 -19
- package/dist/cjs/test/QueryLoader/styles.scss +0 -9
- package/dist/es/a/GradientBackground/GradientBackground.js +0 -118
- package/dist/es/a/GradientBackground/index.js +0 -2
- package/dist/es/a/GradientBackground/styles.scss +0 -191
- package/dist/es/a/Popover/common/Divider/Divider.js +0 -47
- package/dist/es/a/Popover/common/Divider/index.js +0 -2
- package/dist/es/a/Popover/common/Item/Item.js +0 -47
- package/dist/es/a/Popover/common/Item/index.js +0 -2
- package/dist/es/a/Popover/common/index.js +0 -2
- package/dist/es/c/AcceptCookies/AcceptCookies.js +0 -117
- package/dist/es/c/AcceptCookies/index.js +0 -2
- package/dist/es/c/AcceptCookies/styles.scss +0 -49
- package/dist/es/c/BlogCategoryButton/BlogCategoryButton.js +0 -68
- package/dist/es/c/BlogCategoryButton/index.js +0 -2
- package/dist/es/c/BlogContext/BlogContextProvider.js +0 -45
- package/dist/es/c/BlogContext/ContextProvider.js +0 -45
- package/dist/es/c/BlogContext/index.js +0 -4
- package/dist/es/c/BlogPost/BlogPost.js +0 -128
- package/dist/es/c/BlogPost/index.js +0 -2
- package/dist/es/c/BlogPost/styles.scss +0 -33
- package/dist/es/c/BlogPostsList/BlogPostsList.js +0 -56
- package/dist/es/c/BlogPostsList/common/Card/Card.js +0 -143
- package/dist/es/c/BlogPostsList/common/Card/index.js +0 -2
- package/dist/es/c/BlogPostsList/common/index.js +0 -1
- package/dist/es/c/BlogPostsList/index.js +0 -2
- package/dist/es/c/BlogPostsList/styles.scss +0 -72
- package/dist/es/c/SiteFooter/SiteFooter.js +0 -56
- package/dist/es/c/SiteFooter/common/Section/Section.js +0 -73
- package/dist/es/c/SiteFooter/common/Section/index.js +0 -2
- package/dist/es/c/SiteFooter/common/index.js +0 -1
- package/dist/es/c/SiteFooter/index.js +0 -2
- package/dist/es/c/SiteFooter/styles.scss +0 -34
- package/dist/es/c/SiteHeaderCTA/SiteHeaderCTA.js +0 -92
- package/dist/es/c/SiteHeaderCTA/index.js +0 -2
- package/dist/es/c/SiteHeaderCTA/styles.scss +0 -44
- package/dist/es/c/SiteMission/SiteMission.js +0 -96
- package/dist/es/c/SiteMission/index.js +0 -2
- package/dist/es/c/SiteMission/styles.scss +0 -30
- package/dist/es/c/SiteNavigation/SiteNavigation.js +0 -111
- package/dist/es/c/SiteNavigation/index.js +0 -2
- package/dist/es/c/SiteNavigation/styles.scss +0 -118
- package/dist/es/c/SiteOnboardingStep/SiteOnboardingStep.js +0 -81
- package/dist/es/c/SiteOnboardingStep/index.js +0 -2
- package/dist/es/c/SiteOnboardingStep/styles.scss +0 -51
- package/dist/es/c/SitePricing/SitePricing.js +0 -91
- package/dist/es/c/SitePricing/index.js +0 -2
- package/dist/es/c/SitePricing/styles.scss +0 -73
- package/dist/es/c/SiteServices/SiteServices.js +0 -195
- package/dist/es/c/SiteServices/index.js +0 -2
- package/dist/es/c/SiteServices/styles.scss +0 -138
- package/dist/es/c/TeamGallery/TeamGallery.js +0 -64
- package/dist/es/c/TeamGallery/common/PersonCard/PersonCard.js +0 -64
- package/dist/es/c/TeamGallery/common/PersonCard/index.js +0 -2
- package/dist/es/c/TeamGallery/common/index.js +0 -1
- package/dist/es/c/TeamGallery/index.js +0 -2
- package/dist/es/c/TeamGallery/styles.scss +0 -100
- package/dist/es/c/Testimonials/Testimonials.js +0 -99
- package/dist/es/c/Testimonials/index.js +0 -2
- package/dist/es/c/Testimonials/styles.scss +0 -112
- package/dist/es/experimental/GradientBackground/GradientBackground.js +0 -76
- package/dist/es/experimental/GradientBackground/index.js +0 -2
- package/dist/es/experimental/GradientBackground/styles.scss +0 -64
- package/dist/es/experimental/index.js +0 -1
- package/dist/es/f/fields/CheckboxInput/CheckboxInput.js +0 -85
- package/dist/es/f/fields/CheckboxInput/index.js +0 -2
- package/dist/es/f/fields/CheckboxInput/styles.scss +0 -28
- package/dist/es/f/fields/QuerySelect/styles.scss +0 -21
- package/dist/es/f/fields/RadioInput/RadioInput.js +0 -90
- package/dist/es/f/fields/RadioInput/index.js +0 -2
- package/dist/es/f/fields/RadioInput/styles.scss +0 -26
- package/dist/es/f/fields/TaskRecommendation/TaskRecommendation.js +0 -111
- package/dist/es/f/fields/TaskRecommendation/index.js +0 -2
- package/dist/es/f/fields/TaskRecommendation/styles.scss +0 -37
- package/dist/es/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +0 -111
- package/dist/es/f/fields/TaskRecommendationInput/index.js +0 -2
- package/dist/es/f/fields/TaskRecommendationInput/styles.scss +0 -41
- package/dist/es/f/fields/TextArea/TextArea.js +0 -124
- package/dist/es/f/fields/TextArea/index.js +0 -2
- package/dist/es/f/fields/TextArea/styles.scss +0 -19
- package/dist/es/test/QueryLoader/styles.scss +0 -9
- package/src/ui/a/SiteContext/index.js +0 -5
|
File without changes
|
|
@@ -9,9 +9,9 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _useTheme = _interopRequireDefault(require("./useTheme"));
|
|
13
13
|
|
|
14
|
-
var
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
+
initialTheme,
|
|
44
|
+
config,
|
|
45
|
+
initialState // ...otherProps
|
|
43
46
|
|
|
44
47
|
} = _ref;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
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
|
-
|
|
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
|
-
*
|
|
60
|
+
* The children JSX
|
|
73
61
|
*/
|
|
74
|
-
|
|
62
|
+
children: _propTypes.default.node,
|
|
75
63
|
|
|
76
64
|
/**
|
|
77
|
-
*
|
|
65
|
+
* The initial theme for the website. If undefined, fallbacks on system preference.
|
|
78
66
|
*/
|
|
79
|
-
|
|
67
|
+
initialTheme: _propTypes.default.string,
|
|
80
68
|
|
|
81
69
|
/**
|
|
82
|
-
*
|
|
70
|
+
* A dictionnary containing settings and preferences to be used application-wide
|
|
83
71
|
*/
|
|
84
|
-
|
|
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
|
-
*
|
|
88
|
+
* Application context initial state
|
|
88
89
|
*/
|
|
89
|
-
|
|
90
|
+
initialState: _propTypes.default.objectOf(_propTypes.default.string)
|
|
90
91
|
};
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
AppContextProvider.defaultProps = {
|
|
93
|
+
initialState: {}
|
|
93
94
|
};
|
|
94
|
-
var _default =
|
|
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, "
|
|
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, "
|
|
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, "
|
|
18
|
+
Object.defineProperty(exports, "useApp", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function get() {
|
|
21
|
-
return
|
|
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
|
|
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 }; }
|
|
File without changes
|
|
@@ -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;
|
package/dist/cjs/a/index.js
CHANGED
|
@@ -21,28 +21,28 @@ Object.defineProperty(exports, "IconList", {
|
|
|
21
21
|
return _IconList.IconList;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "AppContext", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function get() {
|
|
27
|
-
return
|
|
27
|
+
return _AppContext.AppContext;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "AppContextProvider", {
|
|
31
31
|
enumerable: true,
|
|
32
32
|
get: function get() {
|
|
33
|
-
return
|
|
33
|
+
return _AppContext.AppContextProvider;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
Object.defineProperty(exports, "
|
|
36
|
+
Object.defineProperty(exports, "useApp", {
|
|
37
37
|
enumerable: true,
|
|
38
38
|
get: function get() {
|
|
39
|
-
return
|
|
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
|
|
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
|
|
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.
|
|
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 `
|
|
54
|
+
* This components needs to be wrapped within a `AppContextProvider`.
|
|
55
55
|
*/
|
|
56
56
|
|
|
57
57
|
var SocialMediaButton = _ref => {
|
|
58
|
-
var
|
|
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
|
|
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 || (
|
|
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,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
|
|
42
|
-
|
|
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
|
|
50
|
+
link: "https://www.facebook.com/sharer/sharer.php?u=".concat(link) // link: `https://www.facebook.com/sharer/sharer.php?u=${link}"e=${title}`,
|
|
51
|
+
|
|
47
52
|
},
|
|
48
53
|
twitter: {
|
|
49
54
|
icon: 't',
|
|
50
|
-
link: "https://twitter.com/intent/tweet?
|
|
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", {
|
|
File without changes
|
|
@@ -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;
|
|
File without changes
|
|
@@ -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
|
+
});
|
package/dist/es/a/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { SVG } from "./SVG";
|
|
2
2
|
export { DashboardNavbar } from "./DashboardNavbar";
|
|
3
3
|
export { IconList } from "./IconList";
|
|
4
|
-
export {
|
|
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 {
|
|
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 =
|
|
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 {
|
|
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 `
|
|
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
|
|
47
|
+
var _applicationContext$S;
|
|
48
48
|
|
|
49
|
-
const
|
|
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 || (
|
|
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 {
|
|
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
|
-
} =
|
|
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
|
|
27
|
-
|
|
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}"e=${title}
|
|
35
|
+
link: `https://www.facebook.com/sharer/sharer.php?u=${link}` // link: `https://www.facebook.com/sharer/sharer.php?u=${link}"e=${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
|
@@ -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
|
|
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?
|
|
10210
|
+
href="https://twitter.com/intent/tweet?url=http://localhost/#/welcome"
|
|
10211
10211
|
rel="noreferrer"
|
|
10212
10212
|
target="_blank"
|
|
10213
10213
|
>
|