@dr.pogodin/react-utils 1.25.6 → 1.26.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.
Files changed (290) hide show
  1. package/babel.config.js +3 -1
  2. package/bin/build.js +18 -4
  3. package/build/development/client/getInj.js +9 -8
  4. package/build/development/client/getInj.js.map +1 -1
  5. package/build/development/client/index.js +6 -3
  6. package/build/development/client/index.js.map +1 -1
  7. package/build/development/client/init.js +4 -0
  8. package/build/development/client/init.js.map +1 -1
  9. package/build/development/index.js +166 -38
  10. package/build/development/index.js.map +1 -1
  11. package/build/development/server/Cache.js +13 -13
  12. package/build/development/server/Cache.js.map +1 -1
  13. package/build/development/server/index.js +16 -23
  14. package/build/development/server/index.js.map +1 -1
  15. package/build/development/server/renderer.js +56 -43
  16. package/build/development/server/renderer.js.map +1 -1
  17. package/build/development/server/server.js +9 -5
  18. package/build/development/server/server.js.map +1 -1
  19. package/build/development/server/utils/errors.js +12 -9
  20. package/build/development/server/utils/errors.js.map +1 -1
  21. package/build/development/server/utils/index.js +2 -2
  22. package/build/development/server/utils/index.js.map +1 -1
  23. package/build/development/shared/components/Button/index.js +7 -5
  24. package/build/development/shared/components/Button/index.js.map +1 -1
  25. package/build/development/shared/components/Checkbox/index.js +24 -26
  26. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  27. package/build/development/shared/components/Dropdown/index.js +24 -17
  28. package/build/development/shared/components/Dropdown/index.js.map +1 -1
  29. package/build/development/shared/components/GenericLink/index.js +44 -37
  30. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  31. package/build/development/shared/components/Input/index.js +7 -7
  32. package/build/development/shared/components/Input/index.js.map +1 -1
  33. package/build/development/shared/components/Link.js +10 -9
  34. package/build/development/shared/components/Link.js.map +1 -1
  35. package/build/development/shared/components/MetaTags.js +22 -18
  36. package/build/development/shared/components/MetaTags.js.map +1 -1
  37. package/build/development/shared/components/Modal/index.js +16 -16
  38. package/build/development/shared/components/Modal/index.js.map +1 -1
  39. package/build/development/shared/components/NavLink.js +10 -9
  40. package/build/development/shared/components/NavLink.js.map +1 -1
  41. package/build/development/shared/components/PageLayout/index.js +16 -18
  42. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  43. package/build/development/shared/components/ScalableRect/index.js +27 -7
  44. package/build/development/shared/components/ScalableRect/index.js.map +1 -1
  45. package/build/development/shared/components/Throbber/index.js +14 -22
  46. package/build/development/shared/components/Throbber/index.js.map +1 -1
  47. package/build/development/shared/components/WithTooltip/Tooltip.js +19 -21
  48. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  49. package/build/development/shared/components/WithTooltip/index.js +11 -10
  50. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  51. package/build/development/shared/components/YouTubeVideo/index.js +15 -13
  52. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  53. package/build/development/shared/components/index.js +2 -2
  54. package/build/development/shared/components/index.js.map +1 -1
  55. package/build/development/shared/utils/config.js.map +1 -1
  56. package/build/development/shared/utils/globalState.js +15 -0
  57. package/build/development/shared/utils/globalState.js.map +1 -0
  58. package/build/development/shared/utils/index.js +13 -10
  59. package/build/development/shared/utils/index.js.map +1 -1
  60. package/build/development/shared/utils/isomorphy/buildInfo.js +7 -3
  61. package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
  62. package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
  63. package/build/development/shared/utils/isomorphy/index.js.map +1 -1
  64. package/build/development/shared/utils/jest/E2eSsrEnv.js +35 -28
  65. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  66. package/build/development/shared/utils/jest/global.js +17 -0
  67. package/build/development/shared/utils/jest/global.js.map +1 -0
  68. package/build/development/shared/utils/jest/index.js +17 -9
  69. package/build/development/shared/utils/jest/index.js.map +1 -1
  70. package/build/development/shared/utils/splitComponent.js +25 -34
  71. package/build/development/shared/utils/splitComponent.js.map +1 -1
  72. package/build/development/shared/utils/time.js +16 -12
  73. package/build/development/shared/utils/time.js.map +1 -1
  74. package/build/development/shared/utils/webpack.js +3 -3
  75. package/build/development/shared/utils/webpack.js.map +1 -1
  76. package/build/development/web.bundle.js +92 -82
  77. package/build/production/client/getInj.js +1 -1
  78. package/build/production/client/getInj.js.map +1 -1
  79. package/build/production/client/index.js +4 -4
  80. package/build/production/client/index.js.map +1 -1
  81. package/build/production/client/init.js +3 -1
  82. package/build/production/client/init.js.map +1 -1
  83. package/build/production/index.js +1 -1
  84. package/build/production/index.js.map +1 -1
  85. package/build/production/server/Cache.js +7 -8
  86. package/build/production/server/Cache.js.map +1 -1
  87. package/build/production/server/index.js +5 -4
  88. package/build/production/server/index.js.map +1 -1
  89. package/build/production/server/renderer.js +32 -30
  90. package/build/production/server/renderer.js.map +1 -1
  91. package/build/production/server/server.js +7 -5
  92. package/build/production/server/server.js.map +1 -1
  93. package/build/production/server/utils/errors.js +9 -10
  94. package/build/production/server/utils/errors.js.map +1 -1
  95. package/build/production/server/utils/index.js +1 -1
  96. package/build/production/server/utils/index.js.map +1 -1
  97. package/build/production/shared/components/Button/index.js +3 -3
  98. package/build/production/shared/components/Button/index.js.map +1 -1
  99. package/build/production/shared/components/Checkbox/index.js +11 -11
  100. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  101. package/build/production/shared/components/Dropdown/index.js +11 -11
  102. package/build/production/shared/components/Dropdown/index.js.map +1 -1
  103. package/build/production/shared/components/GenericLink/index.js +25 -20
  104. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  105. package/build/production/shared/components/Input/index.js +7 -7
  106. package/build/production/shared/components/Input/index.js.map +1 -1
  107. package/build/production/shared/components/Link.js +2 -2
  108. package/build/production/shared/components/Link.js.map +1 -1
  109. package/build/production/shared/components/MetaTags.js +10 -10
  110. package/build/production/shared/components/MetaTags.js.map +1 -1
  111. package/build/production/shared/components/Modal/index.js +2 -2
  112. package/build/production/shared/components/Modal/index.js.map +1 -1
  113. package/build/production/shared/components/NavLink.js +1 -1
  114. package/build/production/shared/components/NavLink.js.map +1 -1
  115. package/build/production/shared/components/PageLayout/index.js +2 -2
  116. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  117. package/build/production/shared/components/ScalableRect/index.js +7 -3
  118. package/build/production/shared/components/ScalableRect/index.js.map +1 -1
  119. package/build/production/shared/components/Throbber/index.js +2 -2
  120. package/build/production/shared/components/Throbber/index.js.map +1 -1
  121. package/build/production/shared/components/WithTooltip/Tooltip.js +13 -13
  122. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  123. package/build/production/shared/components/WithTooltip/index.js +3 -3
  124. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  125. package/build/production/shared/components/YouTubeVideo/index.js +7 -7
  126. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  127. package/build/production/shared/components/index.js +1 -1
  128. package/build/production/shared/components/index.js.map +1 -1
  129. package/build/production/shared/utils/config.js.map +1 -1
  130. package/build/production/shared/utils/globalState.js +3 -0
  131. package/build/production/shared/utils/globalState.js.map +1 -0
  132. package/build/production/shared/utils/index.js +2 -2
  133. package/build/production/shared/utils/index.js.map +1 -1
  134. package/build/production/shared/utils/isomorphy/buildInfo.js +7 -4
  135. package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
  136. package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
  137. package/build/production/shared/utils/isomorphy/index.js.map +1 -1
  138. package/build/production/shared/utils/jest/E2eSsrEnv.js +9 -9
  139. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  140. package/build/production/shared/utils/jest/global.js +2 -0
  141. package/build/production/shared/utils/jest/global.js.map +1 -0
  142. package/build/production/shared/utils/jest/index.js +5 -5
  143. package/build/production/shared/utils/jest/index.js.map +1 -1
  144. package/build/production/shared/utils/splitComponent.js +16 -16
  145. package/build/production/shared/utils/splitComponent.js.map +1 -1
  146. package/build/production/shared/utils/time.js +12 -8
  147. package/build/production/shared/utils/time.js.map +1 -1
  148. package/build/production/shared/utils/webpack.js +3 -3
  149. package/build/production/shared/utils/webpack.js.map +1 -1
  150. package/build/production/web.bundle.js +1 -1
  151. package/build/production/web.bundle.js.map +1 -1
  152. package/build/types-code/client/getInj.d.ts +3 -0
  153. package/build/types-code/client/index.d.ts +11 -0
  154. package/build/types-code/client/init.d.ts +9 -0
  155. package/build/types-code/index.d.ts +10 -0
  156. package/build/types-code/server/Cache.d.ts +37 -0
  157. package/build/types-code/server/index.d.ts +145 -0
  158. package/build/types-code/server/renderer.d.ts +106 -0
  159. package/build/types-code/server/server.d.ts +41 -0
  160. package/build/types-code/server/utils/errors.d.ts +104 -0
  161. package/build/types-code/server/utils/index.d.ts +1 -0
  162. package/build/types-code/shared/components/Button/index.d.ts +27 -0
  163. package/build/types-code/shared/components/Checkbox/index.d.ts +21 -0
  164. package/build/types-code/shared/components/Dropdown/index.d.ts +23 -0
  165. package/build/types-code/shared/components/GenericLink/index.d.ts +61 -0
  166. package/build/types-code/shared/components/Input/index.d.ts +11 -0
  167. package/build/types-code/shared/components/Link.d.ts +12 -0
  168. package/build/types-code/shared/components/MetaTags.d.ts +68 -0
  169. package/build/types-code/shared/components/Modal/index.d.ts +26 -0
  170. package/build/types-code/shared/components/NavLink.d.ts +5 -0
  171. package/build/types-code/shared/components/PageLayout/index.d.ts +16 -0
  172. package/build/types-code/shared/components/ScalableRect/index.d.ts +19 -0
  173. package/build/types-code/shared/components/Throbber/index.d.ts +9 -0
  174. package/build/types-code/shared/components/WithTooltip/Tooltip.d.ts +23 -0
  175. package/build/types-code/shared/components/WithTooltip/index.d.ts +17 -0
  176. package/build/types-code/shared/components/YouTubeVideo/index.d.ts +13 -0
  177. package/build/types-code/shared/components/index.d.ts +16 -0
  178. package/build/types-code/shared/utils/config.d.ts +2 -0
  179. package/build/types-code/shared/utils/globalState.d.ts +20 -0
  180. package/build/types-code/shared/utils/index.d.ts +52 -0
  181. package/build/types-code/shared/utils/isomorphy/buildInfo.d.ts +23 -0
  182. package/build/types-code/shared/utils/isomorphy/environment-check.d.ts +11 -0
  183. package/build/types-code/shared/utils/isomorphy/index.d.ts +20 -0
  184. package/build/types-code/shared/utils/jest/E2eSsrEnv.d.ts +31 -0
  185. package/build/types-code/shared/utils/jest/global.d.ts +12 -0
  186. package/build/types-code/shared/utils/jest/index.d.ts +85 -0
  187. package/build/types-code/shared/utils/splitComponent.d.ts +41 -0
  188. package/build/types-code/shared/utils/time.d.ts +62 -0
  189. package/build/types-code/shared/utils/webpack.d.ts +18 -0
  190. package/build/types-scss/__tests__/js/config/publicPath support/__assets__/style.scss.d.ts +1 -0
  191. package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/MockPackageA/TestComponent/style.scss.d.ts +1 -0
  192. package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/MockPackageB/TestComponent/style.scss.d.ts +1 -0
  193. package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/style.scss.d.ts +1 -0
  194. package/build/types-scss/__tests__/js/shared/components/NavLink/styles.scss.d.ts +1 -0
  195. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentA/style.scss.d.ts +1 -0
  196. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentB/style.scss.d.ts +1 -0
  197. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentC/style.scss.d.ts +1 -0
  198. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/style.scss.d.ts +1 -0
  199. package/build/types-scss/__tests__/ts/config/publicPath support/__assets__/style.scss.d.ts +1 -0
  200. package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/MockPackageA/TestComponent/style.scss.d.ts +1 -0
  201. package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/MockPackageB/TestComponent/style.scss.d.ts +1 -0
  202. package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/style.scss.d.ts +1 -0
  203. package/build/types-scss/__tests__/ts/shared/components/NavLink/styles.scss.d.ts +1 -0
  204. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentA/style.scss.d.ts +1 -0
  205. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentB/style.scss.d.ts +1 -0
  206. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentC/style.scss.d.ts +1 -0
  207. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/style.scss.d.ts +1 -0
  208. package/build/types-scss/src/shared/components/Button/style.scss.d.ts +6 -0
  209. package/build/types-scss/src/shared/components/Checkbox/theme.scss.d.ts +6 -0
  210. package/build/types-scss/src/shared/components/Dropdown/theme.scss.d.ts +9 -0
  211. package/build/types-scss/src/shared/components/GenericLink/style.scss.d.ts +1 -0
  212. package/build/types-scss/src/shared/components/Input/theme.scss.d.ts +6 -0
  213. package/build/types-scss/src/shared/components/Modal/base-theme.scss.d.ts +5 -0
  214. package/build/types-scss/src/shared/components/PageLayout/base-theme.scss.d.ts +6 -0
  215. package/build/types-scss/src/shared/components/ScalableRect/style.scss.d.ts +2 -0
  216. package/build/types-scss/src/shared/components/Throbber/theme.scss.d.ts +6 -0
  217. package/build/types-scss/src/shared/components/WithTooltip/default-theme.scss.d.ts +7 -0
  218. package/build/types-scss/src/shared/components/YouTubeVideo/base.scss.d.ts +5 -0
  219. package/build/types-scss/src/shared/components/YouTubeVideo/throbber.scss.d.ts +4 -0
  220. package/config/eslint/jest.json +3 -2
  221. package/config/eslint/typescript.js +34 -0
  222. package/config/jest/default.js +3 -3
  223. package/package.json +74 -32
  224. package/src/client/getInj.ts +43 -0
  225. package/src/client/index.tsx +40 -0
  226. package/src/client/init.ts +47 -0
  227. package/src/index.ts +58 -0
  228. package/src/server/Cache.ts +68 -0
  229. package/src/server/index.ts +230 -0
  230. package/src/server/renderer.tsx +604 -0
  231. package/src/server/server.ts +309 -0
  232. package/src/server/utils/errors.ts +135 -0
  233. package/src/server/utils/index.ts +3 -0
  234. package/src/shared/components/Button/index.tsx +146 -0
  235. package/src/shared/components/Button/style.scss +53 -0
  236. package/src/shared/components/Checkbox/index.tsx +71 -0
  237. package/src/shared/components/Checkbox/theme.scss +43 -0
  238. package/src/shared/components/Dropdown/index.tsx +144 -0
  239. package/src/shared/components/Dropdown/theme.scss +63 -0
  240. package/src/shared/components/GenericLink/index.tsx +157 -0
  241. package/src/shared/components/GenericLink/style.scss +3 -0
  242. package/src/shared/components/Input/index.tsx +59 -0
  243. package/src/shared/components/Input/theme.scss +27 -0
  244. package/src/shared/components/Link.tsx +21 -0
  245. package/src/shared/components/MetaTags.tsx +170 -0
  246. package/src/shared/components/Modal/base-theme.scss +38 -0
  247. package/src/shared/components/Modal/index.tsx +144 -0
  248. package/src/shared/components/Modal/styles.scss +5 -0
  249. package/src/shared/components/NavLink.tsx +13 -0
  250. package/src/shared/components/PageLayout/base-theme.scss +30 -0
  251. package/src/shared/components/PageLayout/index.tsx +76 -0
  252. package/src/shared/components/ScalableRect/index.tsx +84 -0
  253. package/src/shared/components/ScalableRect/style.scss +10 -0
  254. package/src/shared/components/Throbber/index.tsx +43 -0
  255. package/src/shared/components/Throbber/theme.scss +26 -0
  256. package/src/shared/components/WithTooltip/Tooltip.tsx +353 -0
  257. package/src/shared/components/WithTooltip/default-theme.scss +36 -0
  258. package/src/shared/components/WithTooltip/index.tsx +204 -0
  259. package/src/shared/components/YouTubeVideo/base.scss +13 -0
  260. package/src/shared/components/YouTubeVideo/index.tsx +96 -0
  261. package/src/shared/components/YouTubeVideo/throbber.scss +11 -0
  262. package/src/shared/components/index.ts +17 -0
  263. package/src/shared/utils/config.ts +21 -0
  264. package/src/shared/utils/globalState.ts +29 -0
  265. package/src/shared/utils/index.ts +105 -0
  266. package/src/shared/utils/isomorphy/buildInfo.ts +54 -0
  267. package/src/shared/utils/isomorphy/environment-check.ts +18 -0
  268. package/src/shared/utils/isomorphy/index.ts +38 -0
  269. package/src/shared/utils/jest/E2eSsrEnv.ts +250 -0
  270. package/src/shared/utils/jest/global.ts +19 -0
  271. package/src/shared/utils/jest/index.tsx +157 -0
  272. package/src/shared/utils/splitComponent.tsx +255 -0
  273. package/src/shared/utils/time.ts +118 -0
  274. package/src/shared/utils/webpack.ts +45 -0
  275. package/src/styles/_global/reset.css +52 -0
  276. package/src/styles/global.scss +11 -0
  277. package/tsconfig.configs.json +18 -0
  278. package/tsconfig.json +27 -0
  279. package/tsconfig.types.json +53 -0
  280. package/typed-scss-modules.config.ts +9 -0
  281. package/types.d.ts +37 -0
  282. package/{webpack.config.js → webpack.config.ts} +7 -3
  283. package/config/babel/node-ssr.js +0 -85
  284. package/config/babel/webpack.js +0 -123
  285. package/config/webpack/app-base.js +0 -330
  286. package/config/webpack/app-development.js +0 -80
  287. package/config/webpack/app-production.js +0 -60
  288. package/config/webpack/lib-base.js +0 -155
  289. package/config/webpack/lib-development.js +0 -45
  290. package/config/webpack/lib-production.js +0 -44
@@ -0,0 +1,170 @@
1
+ import PT from 'prop-types';
2
+ import { type ReactNode, createContext, useMemo } from 'react';
3
+ import { Helmet } from 'react-helmet';
4
+
5
+ type PropsT = {
6
+ children?: ReactNode;
7
+ description: string;
8
+ image?: string;
9
+ siteName?: string;
10
+ socialDescription?: string;
11
+ socialTitle?: string;
12
+ title: string;
13
+ url?: string;
14
+ };
15
+
16
+ const Context = createContext<PropsT>({
17
+ description: '',
18
+ title: '',
19
+ });
20
+
21
+ /**
22
+ * The `<MetaTags>` component is an auxiliary wrapper around `react-helmet`,
23
+ * which helps to inject meta tags (page title, a brief content description,
24
+ * and social media thumbnails) into generated pages.
25
+ *
26
+ * When `<MetaTags>` are nested within the app's component tree, meta tags
27
+ * content injected by components encountered down the tree overrides tags
28
+ * injected by previously encountered `<MetaTags>` components.
29
+ *
30
+ * **Children:** `<MetaTags>` children, if any, are rendered at the component's
31
+ * location. The context passes down all meta tag properties of parent
32
+ * `<MetaTag>` instances. These properties can fetched within children
33
+ * hierarchy in the following way, thus facilitating tags modification by
34
+ * children:
35
+ * ```jsx
36
+ * import { useContext } from 'react';
37
+ * import { MetaTags } from '@dr.pogodin/react-utils';
38
+ * export default function SampleComponent() {
39
+ * const { title, description, ...rest } = useContext(MetaTags.Context);
40
+ * // Do something with these props here, e.g. prefix the page title with
41
+ * // the component name:
42
+ * return (
43
+ * <MetaTags title={`Sample component - ${title}`} />
44
+ * );
45
+ * }
46
+ * ```
47
+ * @param [props]
48
+ * @param [props.description] Page description to use in
49
+ * the `description` meta tag, and as a default description of Open Graph Tags.
50
+ * @param [props.image] The absolute URL of thumbnail image to use
51
+ * in Open Graph Tags (`twitter:image`, and `og:image`). By default these tags
52
+ * are not injected.
53
+ *
54
+ * **BEWARE:** It must be a complete, absolute URL, including the correct
55
+ * website domain and HTTP schema.
56
+ *
57
+ * @param [props.siteName]: The site name to use in `twitter:site`,
58
+ * and `og:sitename` tags. By default these tags are not injected.
59
+ *
60
+ * @param [props.socialDescription] The site description to use in
61
+ * `twitter:description` and `og:description` meta tags. By default the value of
62
+ * `description` prop is used.
63
+ * @param [props.socialTitle] The page title to use in
64
+ * `twitter:title`, `og:title`, and `og:image:alt` tags. By default the value of
65
+ * `title` prop is used. Also the `og:image:alt` tag is only injected if `image`
66
+ * prop is present.
67
+ *
68
+ * @param props.title: The page name to use in the `<title>` tag.
69
+ * It is also used as the default value of `socialTitle` prop.
70
+ *
71
+ * @param [props.url] The page URL to use in `og:url` tag.
72
+ * By default the tag is not injected.
73
+ */
74
+ const MetaTags: React.FunctionComponent<PropsT> & {
75
+ Context: React.Context<PropsT>;
76
+ } = ({
77
+ children,
78
+ description,
79
+ image,
80
+ siteName,
81
+ socialDescription,
82
+ socialTitle,
83
+ title,
84
+ url,
85
+ }) => {
86
+ const socTitle = socialTitle || title;
87
+ const socDesc = socialDescription || description;
88
+
89
+ const context = useMemo(() => ({
90
+ description,
91
+ image,
92
+ siteName,
93
+ socialDescription,
94
+ socialTitle,
95
+ title,
96
+ url,
97
+ }), [
98
+ description,
99
+ image,
100
+ siteName,
101
+ socialDescription,
102
+ socialTitle,
103
+ title,
104
+ url,
105
+ ]);
106
+
107
+ return (
108
+ <>
109
+ <Helmet>
110
+ {/* General tags. */}
111
+ <title>
112
+ {title}
113
+ </title>
114
+ <meta name="description" content={description} />
115
+
116
+ {/* Twitter cards. */}
117
+ <meta name="twitter:card" content="summary_large_image" />
118
+ <meta name="twitter:title" content={socTitle} />
119
+ <meta name="twitter:description" content={socDesc} />
120
+ { image ? <meta name="twitter:image" content={image} /> : null }
121
+ {
122
+ siteName ? (
123
+ <meta name="twitter:site" content={`@${siteName}`} />
124
+ ) : null
125
+ }
126
+
127
+ {/* Open Graph data. */}
128
+ <meta name="og:title" content={socTitle} />
129
+ { image ? <meta name="og:image" content={image} /> : null }
130
+ { image ? <meta name="og:image:alt" content={socTitle} /> : null }
131
+ <meta name="og:description" content={socDesc} />
132
+ {
133
+ siteName ? (<meta name="og:sitename" content={siteName} />) : null
134
+ }
135
+ { url ? (<meta name="og:url" content={url} />) : null }
136
+ </Helmet>
137
+ {
138
+ children ? (
139
+ <Context.Provider value={context}>
140
+ {children}
141
+ </Context.Provider>
142
+ ) : null
143
+ }
144
+ </>
145
+ );
146
+ };
147
+
148
+ MetaTags.Context = Context;
149
+
150
+ MetaTags.defaultProps = {
151
+ children: null,
152
+ image: '',
153
+ siteName: '',
154
+ socialDescription: '',
155
+ socialTitle: '',
156
+ url: '',
157
+ };
158
+
159
+ MetaTags.propTypes = {
160
+ children: PT.node,
161
+ description: PT.string.isRequired,
162
+ image: PT.string,
163
+ siteName: PT.string,
164
+ socialDescription: PT.string,
165
+ socialTitle: PT.string,
166
+ title: PT.string.isRequired,
167
+ url: PT.string,
168
+ };
169
+
170
+ export default MetaTags;
@@ -0,0 +1,38 @@
1
+ @import "styles/mixins";
2
+
3
+ *,
4
+ .context,
5
+ .ad.hoc {
6
+ &.overlay {
7
+ background: #eee;
8
+ height: 100%;
9
+ left: 0;
10
+ opacity: 0.8;
11
+ position: fixed;
12
+ top: 0;
13
+ width: 100%;
14
+ z-index: 998;
15
+
16
+ &:focus { outline: none; }
17
+ }
18
+
19
+ &.container {
20
+ background: #fff;
21
+ box-shadow: 0 0 14px 1px rgba(38 38 40 / 15%);
22
+ border-radius: 4;
23
+ max-height: 95vh;
24
+ max-width: $screen-md;
25
+ overflow: hidden;
26
+ padding: 0.6em 1.2em;
27
+ width: 480px;
28
+ position: fixed;
29
+ top: 50%;
30
+ left: 50%;
31
+ transform: translate(-50%, -50%);
32
+ z-index: 999;
33
+
34
+ @include xs-to-lg {
35
+ max-width: 95vw;
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,144 @@
1
+ /* global document */
2
+
3
+ import { noop } from 'lodash';
4
+
5
+ import {
6
+ type ReactNode,
7
+ useEffect,
8
+ useMemo,
9
+ useRef,
10
+ useState,
11
+ } from 'react';
12
+
13
+ import ReactDom from 'react-dom';
14
+ import PT from 'prop-types';
15
+ import themed, { type Theme } from '@dr.pogodin/react-themes';
16
+
17
+ import baseTheme from './base-theme.scss';
18
+ import './styles.scss';
19
+
20
+ type PropsT = {
21
+ children?: ReactNode;
22
+ onCancel?: () => void;
23
+ theme: Theme & {
24
+ container?: string;
25
+ overlay?: string;
26
+ };
27
+ };
28
+
29
+ /**
30
+ * The `<Modal>` component implements a simple themeable modal window, wrapped
31
+ * into the default theme. `<BaseModal>` exposes the base non-themed component.
32
+ * **Children:** Component children are rendered as the modal content.
33
+ * @param {object} props Component properties. Beside props documented below,
34
+ * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties) are supported as well.
35
+ * @param {function} [props.onCancel] The callback to trigger when user
36
+ * clicks outside the modal, or presses Escape. It is expected to hide the
37
+ * modal.
38
+ * @param {ModalTheme} [props.theme] _Ad hoc_ theme.
39
+ */
40
+ const BaseModal: React.FunctionComponent<PropsT> = ({
41
+ children,
42
+ onCancel,
43
+ theme,
44
+ }) => {
45
+ const containerRef = useRef<HTMLDivElement | null>(null);
46
+ const overlayRef = useRef<HTMLDivElement | null>(null);
47
+ const [portal, setPortal] = useState<HTMLDivElement>();
48
+
49
+ useEffect(() => {
50
+ const p = document.createElement('div');
51
+ document.body.classList.add('scrolling-disabled-by-modal');
52
+ document.body.appendChild(p);
53
+ setPortal(p);
54
+ return () => {
55
+ document.body.classList.remove('scrolling-disabled-by-modal');
56
+ document.body.removeChild(p);
57
+ };
58
+ }, []);
59
+
60
+ const focusLast = useMemo(() => (
61
+ <div
62
+ onFocus={() => {
63
+ const elems = containerRef.current?.querySelectorAll('*') as NodeListOf<HTMLElement>;
64
+ for (let i = elems.length - 1; i >= 0; --i) {
65
+ elems[i].focus();
66
+ if (document.activeElement === elems[i]) return;
67
+ }
68
+ overlayRef.current?.focus();
69
+ }}
70
+ /* eslint-disable jsx-a11y/no-noninteractive-tabindex */
71
+ tabIndex={0}
72
+ /* eslint-enable jsx-a11y/no-noninteractive-tabindex */
73
+ />
74
+ ), []);
75
+
76
+ return portal ? ReactDom.createPortal(
77
+ (
78
+ <>
79
+ {focusLast}
80
+ <div
81
+ aria-label="Cancel"
82
+ className={theme.overlay}
83
+ onClick={() => onCancel && onCancel()}
84
+ onKeyDown={(e) => {
85
+ if (e.key === 'Escape' && onCancel) onCancel();
86
+ }}
87
+ ref={(node) => {
88
+ if (node && node !== overlayRef.current) {
89
+ overlayRef.current = node;
90
+ node.focus();
91
+ }
92
+ }}
93
+ role="button"
94
+ tabIndex={0}
95
+ />
96
+ <div
97
+ aria-modal="true"
98
+ className={theme.container}
99
+ onWheel={(event) => event.stopPropagation()}
100
+ ref={containerRef}
101
+ role="dialog"
102
+ >
103
+ {children}
104
+ </div>
105
+ <div
106
+ onFocus={() => {
107
+ overlayRef.current?.focus();
108
+ }}
109
+ /* eslint-disable jsx-a11y/no-noninteractive-tabindex */
110
+ tabIndex={0}
111
+ /* eslint-enable jsx-a11y/no-noninteractive-tabindex */
112
+ />
113
+ {focusLast}
114
+ </>
115
+ ),
116
+ portal,
117
+ ) : null;
118
+ };
119
+
120
+ const ThemedModal = themed(
121
+ BaseModal,
122
+ 'Modal',
123
+ [
124
+ 'container',
125
+ 'overlay',
126
+ ],
127
+ baseTheme,
128
+ );
129
+
130
+ BaseModal.propTypes = {
131
+ onCancel: PT.func,
132
+ children: PT.node,
133
+ theme: ThemedModal.themeType.isRequired,
134
+ };
135
+
136
+ BaseModal.defaultProps = {
137
+ onCancel: noop,
138
+ children: null,
139
+ };
140
+
141
+ export default ThemedModal;
142
+
143
+ /* Non-themed version of the Modal. */
144
+ export { BaseModal };
@@ -0,0 +1,5 @@
1
+ :global {
2
+ body.scrolling-disabled-by-modal {
3
+ overflow: hidden;
4
+ }
5
+ }
@@ -0,0 +1,13 @@
1
+ import { NavLink as RrNavLink } from 'react-router-dom';
2
+
3
+ import GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';
4
+
5
+ type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'>;
6
+
7
+ const NavLink: React.FunctionComponent<PropsT> = (props) => (
8
+ /* eslint-disable react/jsx-props-no-spreading */
9
+ <GenericLink {...props} routerLinkType={RrNavLink} />
10
+ /* eslint-enable react/jsx-props-no-spreading */
11
+ );
12
+
13
+ export default NavLink;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Base theme: symmetric 3-columns layout, with the center column occupying all
3
+ * screen up to mid screen size. For larger screen sizes the main column is
4
+ * limited by the mid screen size, and the free space is filled with side
5
+ * columns on left and right.
6
+ */
7
+
8
+ @import "styles/mixins";
9
+
10
+ *,
11
+ .context,
12
+ .ad.hoc {
13
+ &.container {
14
+ display: flex;
15
+ min-height: 100vh;
16
+ overflow: hidden;
17
+ width: 100%;
18
+ }
19
+
20
+ &.mainPanel {
21
+ overflow: hidden;
22
+ padding: 1.2em;
23
+ width: $screen-md;
24
+ }
25
+
26
+ &.sidePanel {
27
+ flex: 1;
28
+ overflow: hidden;
29
+ }
30
+ }
@@ -0,0 +1,76 @@
1
+ import PT from 'prop-types';
2
+ import type { ReactNode } from 'react';
3
+
4
+ import themed, { type Theme } from '@dr.pogodin/react-themes';
5
+
6
+ import baseTheme from './base-theme.scss';
7
+
8
+ type PropsT = {
9
+ children?: ReactNode;
10
+ leftSidePanelContent?: ReactNode;
11
+ rightSidePanelContent?: ReactNode;
12
+ theme: Theme & {
13
+ container?: string;
14
+ mainPanel?: string;
15
+ sidePanel?: string;
16
+ leftSidePanel?: string;
17
+ rightSidePanel?: string;
18
+ };
19
+ };
20
+
21
+ /**
22
+ * Simple and themeable page layout. It keeps the main content centered in
23
+ * a column of limited width, which fills entire viewport on small screens
24
+ * (under `$screen-md = 1024px` size). At larger screens the column keeps
25
+ * `$screen-md` size, and it is centered at the page, surrounded by side
26
+ * panels, where additional content can be displayed.
27
+ *
28
+ * **Children:** Component children are rendered as the content of main panel.
29
+ * @param {object} [props] Component properties.
30
+ * @param {Node} [props.leftSidePanelContent] The content for left side panel.
31
+ * @param {Node} [props.rightSidePanelContent] The content for right side panel.
32
+ * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.
33
+ * @param {...any} [props....]
34
+ * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
35
+ */
36
+ const PageLayout: React.FunctionComponent<PropsT> = ({
37
+ children,
38
+ leftSidePanelContent,
39
+ rightSidePanelContent,
40
+ theme,
41
+ }) => (
42
+ <div className={theme.container}>
43
+ <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>
44
+ {leftSidePanelContent}
45
+ </div>
46
+ <div className={theme.mainPanel}>
47
+ {children}
48
+ </div>
49
+ <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>
50
+ {rightSidePanelContent}
51
+ </div>
52
+ </div>
53
+ );
54
+
55
+ const ThemedPageLayout = themed(PageLayout, 'PageLayout', [
56
+ 'container',
57
+ 'leftSidePanel',
58
+ 'mainPanel',
59
+ 'rightSidePanel',
60
+ 'sidePanel',
61
+ ], baseTheme);
62
+
63
+ PageLayout.propTypes = {
64
+ children: PT.node,
65
+ leftSidePanelContent: PT.node,
66
+ rightSidePanelContent: PT.node,
67
+ theme: ThemedPageLayout.themeType.isRequired,
68
+ };
69
+
70
+ PageLayout.defaultProps = {
71
+ children: null,
72
+ leftSidePanelContent: null,
73
+ rightSidePanelContent: null,
74
+ };
75
+
76
+ export default ThemedPageLayout;
@@ -0,0 +1,84 @@
1
+ import PT from 'prop-types';
2
+ import { type ReactNode } from 'react';
3
+
4
+ import './style.scss';
5
+
6
+ type PropsT = {
7
+ children?: ReactNode;
8
+ className?: string;
9
+ ratio?: `${number}:${number}`,
10
+ };
11
+
12
+ /**
13
+ * The `<ScalableRect>` component implements container keeping given aspect
14
+ * ratio, while its width is altered.
15
+ *
16
+ * **Children:** Component children are rendered as the component's content.
17
+ * @param {object} props
18
+ * @param {string} [props.className] CSS class for component container.
19
+ * @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,
20
+ * in `W:H` form.
21
+ */
22
+ const ScalableRect: React.FunctionComponent<PropsT> = ({
23
+ children,
24
+ className,
25
+ ratio,
26
+ }) => {
27
+ const aux = ratio!.split(':');
28
+ const paddingBottom = `${(100 * parseFloat(aux[1])) / parseFloat(aux[0])}%`;
29
+
30
+ /* NOTE: In case the following code looks strange to you, mind that we want to
31
+ * allow the user to set custom styles on this component. If user passes in a
32
+ * "className" prop (possibly "styleName", but that one is converted to
33
+ * "className" by Babel just before being passed into this component), it
34
+ * should not interfere with the sizing behavior, thus we need an extra <div>
35
+ * level in this component; however, if user does not need a custom styling,
36
+ * we can save one level of HTML code, so we do it. */
37
+ const rect = (
38
+ <div
39
+ style={{ paddingBottom }}
40
+ styleName="container"
41
+ >
42
+ <div styleName="wrapper">
43
+ {children}
44
+ </div>
45
+ </div>
46
+ );
47
+ return className ? (
48
+ <div className={className}>
49
+ {rect}
50
+ </div>
51
+ ) : rect;
52
+ };
53
+
54
+ ScalableRect.defaultProps = {
55
+ children: null,
56
+ className: undefined,
57
+ ratio: '1:1',
58
+ };
59
+
60
+ ScalableRect.propTypes = {
61
+ children: PT.node,
62
+ className: PT.string,
63
+ ratio: (props, name) => {
64
+ const ratio = props[name];
65
+
66
+ // "ratio" prop is not required (defaults "1:1").
67
+ if (ratio === undefined) return null;
68
+
69
+ // If given, "ratio" must be a string.
70
+ if (typeof ratio !== 'string') {
71
+ return Error('"ratio" prop must be a string');
72
+ }
73
+
74
+ // If given, "ratio" must have "H:W" format.
75
+ if (!ratio.match(/\d\.\d+/)) {
76
+ return Error('"ratio" prop must have "H:W" format');
77
+ }
78
+
79
+ // Everything looks right.
80
+ return null;
81
+ },
82
+ };
83
+
84
+ export default ScalableRect;
@@ -0,0 +1,10 @@
1
+ .container {
2
+ position: relative;
3
+ width: 100%;
4
+ }
5
+
6
+ .wrapper {
7
+ height: 100%;
8
+ position: absolute;
9
+ width: 100%;
10
+ }
@@ -0,0 +1,43 @@
1
+ import themed, { type Theme } from '@dr.pogodin/react-themes';
2
+
3
+ import defaultTheme from './theme.scss';
4
+
5
+ type PropsT = {
6
+ theme: Theme & {
7
+ container?: string;
8
+ circle?: string;
9
+ };
10
+ };
11
+
12
+ /**
13
+ * Throbber is an "action in progress" indicator, which renders
14
+ * three bouncing circles as a simple pending activity indicator,
15
+ * and can be further themed to a certain degree.
16
+ * @param {object} [props] Component properties.
17
+ * @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.
18
+ * @param {...any} [props....]
19
+ * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
20
+ */
21
+ const Throbber: React.FunctionComponent<PropsT> = ({ theme }) => (
22
+ <span className={theme.container} styleName="container">
23
+ <span className={theme.circle} styleName="circle" />
24
+ <span className={theme.circle} styleName="circle" />
25
+ <span className={theme.circle} styleName="circle" />
26
+ </span>
27
+ );
28
+
29
+ const ThemedThrobber = themed(
30
+ Throbber,
31
+ 'Throbber',
32
+ [
33
+ 'circle',
34
+ 'container',
35
+ ],
36
+ defaultTheme,
37
+ );
38
+
39
+ Throbber.propTypes = {
40
+ theme: ThemedThrobber.themeType.isRequired,
41
+ };
42
+
43
+ export default ThemedThrobber;
@@ -0,0 +1,26 @@
1
+ *,
2
+ .context,
3
+ .ad.hoc {
4
+ &.container {
5
+ display: inline-block;
6
+ }
7
+
8
+ &.circle {
9
+ @keyframes bouncing {
10
+ from { top: -0.3em; }
11
+ to { top: 0.3em; }
12
+ }
13
+
14
+ animation: bouncing 0.4s ease-in infinite alternate;
15
+ background: black;
16
+ border-radius: 0.3em;
17
+ display: inline-block;
18
+ height: 0.6em;
19
+ margin: 0 0.1em;
20
+ position: relative;
21
+ width: 0.6em;
22
+
23
+ &:first-child { animation-delay: -0.2s; }
24
+ &:last-child { animation-delay: 0.2s; }
25
+ }
26
+ }