@pie-lib/render-ui 4.15.10-next.1 → 4.15.10-next.1639

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 (58) hide show
  1. package/CHANGELOG.json +1 -937
  2. package/CHANGELOG.md +183 -21
  3. package/NEXT.CHANGELOG.json +1 -0
  4. package/lib/append-css-rules.js +88 -0
  5. package/lib/append-css-rules.js.map +1 -0
  6. package/lib/assets/enableAudioAutoplayImage.js +9 -0
  7. package/lib/assets/enableAudioAutoplayImage.js.map +1 -0
  8. package/lib/collapsible/index.js +2 -1
  9. package/lib/collapsible/index.js.map +1 -1
  10. package/lib/color.js +189 -2
  11. package/lib/color.js.map +1 -1
  12. package/lib/feedback.js +0 -1
  13. package/lib/feedback.js.map +1 -1
  14. package/lib/has-media.js +27 -0
  15. package/lib/has-media.js.map +1 -0
  16. package/lib/has-text.js +6 -2
  17. package/lib/has-text.js.map +1 -1
  18. package/lib/html-and-math.js +0 -16
  19. package/lib/html-and-math.js.map +1 -1
  20. package/lib/index.js +32 -0
  21. package/lib/index.js.map +1 -1
  22. package/lib/preview-layout.js +16 -4
  23. package/lib/preview-layout.js.map +1 -1
  24. package/lib/preview-prompt.js +156 -41
  25. package/lib/preview-prompt.js.map +1 -1
  26. package/lib/ui-layout.js +122 -0
  27. package/lib/ui-layout.js.map +1 -0
  28. package/package.json +7 -4
  29. package/src/__tests__/__snapshots__/html-and-math.test.js.snap +11 -0
  30. package/src/__tests__/__snapshots__/preview-prompt.test.jsx.snap +37 -0
  31. package/src/__tests__/__snapshots__/purpose.test.jsx.snap +42 -0
  32. package/src/__tests__/__snapshots__/readable.test.jsx.snap +64 -0
  33. package/src/__tests__/__snapshots__/response-indicators.test.jsx.snap +27 -0
  34. package/src/__tests__/color.test.js +12 -0
  35. package/src/__tests__/has-media.test.js +20 -0
  36. package/src/__tests__/has-text.test.js +21 -0
  37. package/src/__tests__/html-and-math.test.js +24 -0
  38. package/src/__tests__/preview-prompt.test.jsx +56 -0
  39. package/src/__tests__/purpose.test.jsx +47 -0
  40. package/src/__tests__/readable.test.jsx +64 -0
  41. package/src/__tests__/response-indicators.test.jsx +16 -0
  42. package/src/__tests__/ui-layout.test.jsx +34 -0
  43. package/src/__tests__/withUndoReset.test.jsx +254 -0
  44. package/src/append-css-rules.js +51 -0
  45. package/src/assets/enableAudioAutoplayImage.js +1 -0
  46. package/src/collapsible/__tests__/__snapshots__/index.test.jsx.snap +18 -0
  47. package/src/collapsible/__tests__/index.test.jsx +13 -0
  48. package/src/collapsible/index.jsx +1 -0
  49. package/src/color.js +66 -0
  50. package/src/feedback.jsx +0 -1
  51. package/src/has-media.js +16 -0
  52. package/src/has-text.js +6 -2
  53. package/src/html-and-math.js +0 -13
  54. package/src/index.js +8 -0
  55. package/src/preview-layout.jsx +14 -3
  56. package/src/preview-prompt.jsx +150 -26
  57. package/src/ui-layout.jsx +66 -0
  58. package/README.md +0 -33
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import { withStyles } from '@material-ui/core/styles';
3
+ import PropTypes from 'prop-types';
4
+ import classNames from 'classnames';
5
+ import AppendCSSRules from './append-css-rules';
6
+
7
+ class UiLayout extends AppendCSSRules {
8
+ static propTypes = {
9
+ classes: PropTypes.object,
10
+ className: PropTypes.string,
11
+ children: PropTypes.array,
12
+ extraCSSRules: PropTypes.shape({
13
+ names: PropTypes.arrayOf(PropTypes.string),
14
+ rules: PropTypes.string,
15
+ }),
16
+ fontSizeFactor: PropTypes.number,
17
+ };
18
+
19
+ static defaultProps = {
20
+ extraCSSRules: {},
21
+ fontSizeFactor: 1,
22
+ };
23
+
24
+ constructor(props) {
25
+ super(props);
26
+ this.classesSheet = document.createElement('style');
27
+ }
28
+
29
+ computeStyle(fontSizeFactor) {
30
+ const getFontSize = (element) => parseFloat(getComputedStyle(element).fontSize);
31
+
32
+ const rootFontSize = getFontSize(document.documentElement);
33
+ const bodyFontSize = getFontSize(document.body);
34
+ const effectiveFontSize = Math.max(rootFontSize, bodyFontSize);
35
+
36
+ return fontSizeFactor !== 1 ? { fontSize: `${effectiveFontSize * fontSizeFactor}px` } : null;
37
+ }
38
+
39
+ render() {
40
+ const { children, className, classes, fontSizeFactor, ...rest } = this.props;
41
+
42
+ const finalClass = classNames(className, classes.extraCSSRules, classes.uiLayoutContainer);
43
+ const { extraCSSRules, ...restProps } = rest;
44
+ const style = this.computeStyle(fontSizeFactor);
45
+
46
+ return (
47
+ <div className={finalClass} {...restProps} {...(style && { style })}>
48
+ {children}
49
+ </div>
50
+ );
51
+ }
52
+ }
53
+
54
+ const styles = {
55
+ extraCSSRules: {},
56
+ // need this because some browsers set their own style on table
57
+ uiLayoutContainer: {
58
+ '& table, th, td': {
59
+ fontSize: 'inherit' /* Ensure table elements inherit font size */,
60
+ },
61
+ },
62
+ };
63
+
64
+ const Styled = withStyles(styles)(UiLayout);
65
+
66
+ export default Styled;
package/README.md DELETED
@@ -1,33 +0,0 @@
1
- # @pie-lib/render-ui
2
-
3
- Some shared ui components for player rendering that are so small that they don't warrant their own package..
4
-
5
- ## install
6
-
7
- ```
8
- npm install
9
- ```
10
-
11
- ## demo
12
-
13
- ```
14
- cd demo
15
- ../node_modules/.bin/webpack-dev-server --hot --inline
16
- ```
17
-
18
- go to http://localhost:8080
19
-
20
- # colors
21
-
22
- This package contains a color module that defines the css custom properties that all pie elements should use. It loosely follows the material design naming scheme with a few additions.
23
-
24
- | name | description | fallback |
25
- | ---------------------- | --------------------------------------- | ------------------ |
26
- | `--pie-text` | the color of the text | defaults.TEXT |
27
- | `--pie-primary` | the primary fill color | defaults.PRIMARY |
28
- | `--pie-primary-text` | the color of primary text | `--pie-text` |
29
- | `--pie-secondary` | the secondary fill color | defaults.SECONDARY |
30
- | `--pie-secondary-text` | the color of secondary text | `--pie-text` |
31
- | `--pie-correct` | the fill color for correct ui widgets | defaults.CORRECT |
32
- | `--pie-incorrect` | the fill color for incorrect ui widgets | defaults.INCORRECT |
33
- | `--pie-disabled` | the disabled color | defaults.DISABLED |