@khanacademy/perseus 20.2.0 → 20.3.1

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/index.css CHANGED
@@ -2363,7 +2363,7 @@ img.zoom-img {
2363
2363
  }
2364
2364
  .framework-perseus .perseus-renderer > .paragraph > ul:not(.perseus-widget-radio),
2365
2365
  .framework-perseus .perseus-renderer > .paragraph > ol {
2366
- margin: -11px 0px 22px 0px;
2366
+ margin: 0px 0px 22px 0px;
2367
2367
  }
2368
2368
  .framework-perseus .paragraph ul:not(.perseus-widget-radio, .indicatorContainer) {
2369
2369
  padding-left: 35px;
package/dist/index.js CHANGED
@@ -29,6 +29,8 @@ var Button = require('@khanacademy/wonder-blocks-button');
29
29
  var wonderBlocksLayout = require('@khanacademy/wonder-blocks-layout');
30
30
  var Banner = require('@khanacademy/wonder-blocks-banner');
31
31
  var wonderBlocksDropdown = require('@khanacademy/wonder-blocks-dropdown');
32
+ var caretDown = require('@phosphor-icons/core/assets/regular/caret-down.svg');
33
+ var caretUp = require('@phosphor-icons/core/assets/regular/caret-up.svg');
32
34
  var debounce$1 = require('lodash.debounce');
33
35
  var mafs = require('mafs');
34
36
  var wonderBlocksIcon = require('@khanacademy/wonder-blocks-icon');
@@ -79,6 +81,8 @@ var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
79
81
  var SimpleMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(SimpleMarkdown);
80
82
  var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
81
83
  var Banner__default = /*#__PURE__*/_interopDefaultLegacy(Banner);
84
+ var caretDown__default = /*#__PURE__*/_interopDefaultLegacy(caretDown);
85
+ var caretUp__default = /*#__PURE__*/_interopDefaultLegacy(caretUp);
82
86
  var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce$1);
83
87
  var questionIcon__default = /*#__PURE__*/_interopDefaultLegacy(questionIcon);
84
88
  var createReactClass__default = /*#__PURE__*/_interopDefaultLegacy(createReactClass);
@@ -25010,57 +25014,42 @@ class Explanation extends React__namespace.Component {
25010
25014
  this.props.trackInteraction();
25011
25015
  };
25012
25016
  render() {
25013
- const {
25014
- isArticle,
25015
- isMobile
25016
- } = this.props.apiOptions;
25017
25017
  const promptText = this.state.expanded ? this.props.hidePrompt : this.props.showPrompt;
25018
- let promptContainer;
25019
-
25020
- // TODO(diedra): This isn't a valid href;
25021
- // change this to a button that looks like a link.
25022
- const href = "javascript:void(0)";
25023
- const onClick = this._onClick;
25024
- if (isMobile) {
25025
- promptContainer = /*#__PURE__*/React__namespace.createElement("div", {
25026
- className: aphrodite.css(styles$p.linkContainer)
25027
- }, /*#__PURE__*/React__namespace.createElement("a", {
25028
- className: aphrodite.css(styles$p.mobileExplanationLink),
25029
- href: href,
25030
- onClick: onClick,
25031
- role: "button",
25032
- "aria-expanded": this.state.expanded
25033
- }, promptText), this.state.expanded && /*#__PURE__*/React__namespace.createElement("svg", {
25034
- className: aphrodite.css(styles$p.disclosureArrow)
25035
- }, /*#__PURE__*/React__namespace.createElement("polygon", {
25036
- style: {
25037
- fill: backgroundColor
25038
- },
25039
- points: `0,${arrowHeight} ` + `${arrowWidth},${arrowHeight} ` + `${arrowWidth / 2},0`
25040
- })));
25041
- } else {
25042
- const viewStyling = isArticle ? [styles$p.explanationLink, styles$p.articleLink] : [styles$p.explanationLink, styles$p.exerciseLink];
25043
- promptContainer = /*#__PURE__*/React__namespace.createElement(Clickable__default["default"], {
25044
- onClick: onClick,
25045
- "aria-expanded": this.state.expanded
25046
- }, () => /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
25047
- style: viewStyling
25048
- }, `[${promptText}]`));
25049
- }
25050
- const expandedStyle = isMobile ? styles$p.contentExpandedMobile : styles$p.contentExpanded;
25051
- return /*#__PURE__*/React__namespace.createElement("div", {
25052
- className: aphrodite.css(styles$p.container)
25053
- }, promptContainer, this.state.expanded && /*#__PURE__*/React__namespace.createElement("div", {
25054
- className: aphrodite.css(styles$p.content, isMobile && styles$p.contentMobile, this.state.expanded && expandedStyle)
25055
- // eslint-disable-next-line react/no-string-refs
25056
- ,
25057
- ref: "content"
25018
+ const caretIcon = this.state.expanded ? caretUp__default["default"] : caretDown__default["default"];
25019
+ const allowTransition = window.matchMedia("(prefers-reduced-motion: no-preference)").matches;
25020
+
25021
+ // Special styling is needed to fit the button in a block of text without throwing off the line spacing.
25022
+ // While the button is not normally included in a block of text, it needs to be able to accommodate such a case.
25023
+ const buttonStyleOverrides = {
25024
+ height: "22px",
25025
+ marginLeft: "-2px",
25026
+ padding: "0 2px"
25027
+ };
25028
+ const contentStyling = [styles$p.content, this.state.expanded ? styles$p.contentExpanded : styles$p.contentCollapsed, allowTransition && (this.state.expanded ? styles$p.transitionExpanded : styles$p.transitionCollapsed)];
25029
+ return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.UniqueIDProvider, {
25030
+ mockOnFirstRender: false,
25031
+ scope: "explanation-widget"
25032
+ }, ids => /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(Button__default["default"], {
25033
+ "aria-expanded": this.state.expanded,
25034
+ "aria-controls": ids.get("content"),
25035
+ endIcon: caretIcon,
25036
+ kind: "tertiary",
25037
+ onClick: this._onClick,
25038
+ size: "large",
25039
+ style: buttonStyleOverrides
25040
+ }, promptText), /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
25041
+ id: ids.get("content"),
25042
+ style: contentStyling,
25043
+ "aria-hidden": !this.state.expanded,
25044
+ testId: "content-container"
25045
+ }, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
25046
+ style: styles$p.contentWrapper
25058
25047
  }, /*#__PURE__*/React__namespace.createElement(Renderer, {
25059
25048
  apiOptions: this.props.apiOptions,
25060
25049
  content: this.props.explanation,
25061
25050
  widgets: this.props.widgets,
25062
25051
  linterContext: this.props.linterContext
25063
- })));
25052
+ })))));
25064
25053
  }
25065
25054
  getUserInput = () => {
25066
25055
  return {};
@@ -25071,94 +25060,44 @@ class Explanation extends React__namespace.Component {
25071
25060
  }
25072
25061
  const leftBorderSpacing = 23;
25073
25062
  const verticalContentPadding = 10;
25074
- const arrowWidth = 30;
25075
25063
  const arrowHeight = 14;
25076
- const backgroundColor = gray95;
25077
25064
  const styles$p = aphrodite.StyleSheet.create({
25078
- container: {
25079
- display: "inline",
25065
+ content: {
25066
+ borderLeft: "0px solid #ccc",
25067
+ display: "inline-grid",
25080
25068
  position: "relative"
25081
25069
  },
25082
- linkContainer: {
25083
- display: "inline-block"
25084
- },
25085
- explanationLink: {
25086
- fontStyle: "italic",
25087
- color: "#007d96"
25088
- },
25089
- articleLink: {
25090
- // Copied from .body-text in articles.less
25091
- fontSize: 20,
25092
- lineHeight: "30px"
25093
- },
25094
- exerciseLink: {
25095
- // Copied from .legacy-typography in util.less
25096
- fontSize: 14,
25097
- lineHeight: "19.6px"
25098
- },
25099
- mobileExplanationLink: {
25100
- color: kaGreen$1,
25101
- borderBottom: `dashed 1px ${kaGreen$1}`,
25102
- textDecoration: "none",
25103
- // TODO(benkomalo): these should be pulled in from common typography
25104
- // shared files so we have a single place where the type hierarchy is
25105
- // defined; one off font sizes for individual components should be
25106
- // avoided.
25107
- [mediaQueries.xl]: {
25108
- fontSize: 22,
25109
- lineHeight: 1.4
25110
- },
25111
- [mediaQueries.lgOrSmaller]: {
25112
- fontSize: 20,
25113
- lineHeight: 1.5
25114
- },
25115
- [mediaQueries.smOrSmaller]: {
25116
- fontSize: 18,
25117
- lineHeight: 1.2
25118
- }
25119
- },
25120
- content: {
25121
- position: "relative",
25122
- transition: "margin-top 0.1s"
25070
+ contentCollapsed: {
25071
+ gridTemplateColumns: "0fr",
25072
+ gridTemplateRows: "0fr",
25073
+ marginBottom: 0,
25074
+ marginTop: 0,
25075
+ minWidth: "0",
25076
+ paddingBottom: 0,
25077
+ visibility: "hidden"
25123
25078
  },
25124
25079
  contentExpanded: {
25125
- borderLeft: "5px solid #ccc",
25080
+ borderLeftWidth: "5px",
25081
+ gridTemplateColumns: "1fr",
25082
+ gridTemplateRows: "1fr",
25126
25083
  marginLeft: -leftBorderSpacing,
25084
+ minWidth: "100%",
25127
25085
  paddingLeft: leftBorderSpacing,
25128
25086
  paddingBottom: verticalContentPadding,
25087
+ visibility: "visible",
25129
25088
  // Note: we still use arrow height as the vertical margin, even on
25130
25089
  // desktop when there is no arrow, but it's good enough.
25131
25090
  marginBottom: arrowHeight,
25132
25091
  marginTop: arrowHeight
25133
25092
  },
25134
- contentExpandedMobile: {
25135
- boxSizing: "content-box",
25136
- paddingTop: 32,
25137
- paddingBottom: 32,
25138
- marginTop: arrowHeight
25093
+ contentWrapper: {
25094
+ overflow: "hidden"
25139
25095
  },
25140
- contentMobile: {
25141
- background: backgroundColor,
25142
- // TODO(benkomalo): this is to "full bleed" the background.
25143
- // The actual content padding differs depending on the host
25144
- // container, so this needs to be fixed eventually.
25145
- marginLeft: negativePhoneMargin,
25146
- marginRight: negativePhoneMargin,
25147
- paddingLeft: phoneMargin,
25148
- paddingRight: phoneMargin
25149
- },
25150
- disclosureArrow: {
25151
- // HACK - positioning at "bottom: 0", doesn't actually position it to
25152
- // the real bottom, because the container is `inline-block`, and it
25153
- // seems to position it to the baseline? We put in a generous
25154
- // fudge factor to position it down to be flush with the content box
25155
- // below it.
25156
- bottom: -(arrowHeight + 5),
25157
- height: arrowHeight,
25158
- left: "50%",
25159
- marginLeft: -(arrowWidth / 2),
25160
- position: "absolute",
25161
- width: arrowWidth
25096
+ transitionCollapsed: {
25097
+ transition: "all 0.25s step-end, grid-template-rows 0.25s, margin-top 0.25s, margin-bottom 0.25s, padding-bottom 0.25s"
25098
+ },
25099
+ transitionExpanded: {
25100
+ transition: "grid-template-rows 0.5s, margin-top 0.5s, margin-bottom 0.5s, padding-bottom 0.5s"
25162
25101
  }
25163
25102
  });
25164
25103
  var Explanation$1 = {
@@ -41424,7 +41363,7 @@ const init = function (options) {
41424
41363
 
41425
41364
  // This file is processed by a Rollup plugin (replace) to inject the production
41426
41365
  const libName = "@khanacademy/perseus";
41427
- const libVersion = "20.2.0";
41366
+ const libVersion = "20.3.1";
41428
41367
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
41429
41368
 
41430
41369
  const apiVersion = {