@instructure/ui-billboard 11.6.0 → 11.6.1-snapshot-129

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 (56) hide show
  1. package/CHANGELOG.md +33 -280
  2. package/es/Billboard/{index.js → v1/index.js} +3 -3
  3. package/es/Billboard/v2/index.js +188 -0
  4. package/es/Billboard/v2/props.js +26 -0
  5. package/es/Billboard/v2/styles.js +169 -0
  6. package/es/{index.js → exports/a.js} +1 -1
  7. package/{src/index.ts → es/exports/b.js} +1 -2
  8. package/lib/Billboard/{index.js → v1/index.js} +7 -7
  9. package/lib/Billboard/v2/index.js +195 -0
  10. package/lib/Billboard/v2/props.js +31 -0
  11. package/lib/Billboard/v2/styles.js +175 -0
  12. package/lib/{index.js → exports/a.js} +2 -2
  13. package/lib/exports/b.js +12 -0
  14. package/package.json +41 -19
  15. package/src/Billboard/{index.tsx → v1/index.tsx} +4 -4
  16. package/src/Billboard/{props.ts → v1/props.ts} +1 -1
  17. package/src/Billboard/v2/README.md +95 -0
  18. package/src/Billboard/v2/index.tsx +202 -0
  19. package/src/Billboard/v2/props.ts +128 -0
  20. package/src/Billboard/v2/styles.ts +158 -0
  21. package/src/exports/a.ts +25 -0
  22. package/src/exports/b.ts +25 -0
  23. package/tsconfig.build.tsbuildinfo +1 -1
  24. package/types/Billboard/{index.d.ts → v1/index.d.ts} +1 -1
  25. package/types/Billboard/v1/index.d.ts.map +1 -0
  26. package/types/Billboard/{props.d.ts → v1/props.d.ts} +1 -1
  27. package/types/Billboard/v1/props.d.ts.map +1 -0
  28. package/types/Billboard/v1/styles.d.ts.map +1 -0
  29. package/types/Billboard/v1/theme.d.ts.map +1 -0
  30. package/types/Billboard/v2/index.d.ts +58 -0
  31. package/types/Billboard/v2/index.d.ts.map +1 -0
  32. package/types/Billboard/v2/props.d.ts +74 -0
  33. package/types/Billboard/v2/props.d.ts.map +1 -0
  34. package/types/Billboard/v2/styles.d.ts +15 -0
  35. package/types/Billboard/v2/styles.d.ts.map +1 -0
  36. package/types/exports/a.d.ts +3 -0
  37. package/types/exports/a.d.ts.map +1 -0
  38. package/types/exports/b.d.ts +3 -0
  39. package/types/exports/b.d.ts.map +1 -0
  40. package/types/Billboard/index.d.ts.map +0 -1
  41. package/types/Billboard/props.d.ts.map +0 -1
  42. package/types/Billboard/styles.d.ts.map +0 -1
  43. package/types/Billboard/theme.d.ts.map +0 -1
  44. package/types/index.d.ts +0 -3
  45. package/types/index.d.ts.map +0 -1
  46. /package/es/Billboard/{props.js → v1/props.js} +0 -0
  47. /package/es/Billboard/{styles.js → v1/styles.js} +0 -0
  48. /package/es/Billboard/{theme.js → v1/theme.js} +0 -0
  49. /package/lib/Billboard/{props.js → v1/props.js} +0 -0
  50. /package/lib/Billboard/{styles.js → v1/styles.js} +0 -0
  51. /package/lib/Billboard/{theme.js → v1/theme.js} +0 -0
  52. /package/src/Billboard/{README.md → v1/README.md} +0 -0
  53. /package/src/Billboard/{styles.ts → v1/styles.ts} +0 -0
  54. /package/src/Billboard/{theme.ts → v1/theme.ts} +0 -0
  55. /package/types/Billboard/{styles.d.ts → v1/styles.d.ts} +0 -0
  56. /package/types/Billboard/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,188 @@
1
+ var _dec, _class, _Billboard;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import { Component } from 'react';
27
+ import { Heading } from '@instructure/ui-heading/latest';
28
+ import { View } from '@instructure/ui-view/latest';
29
+ import { omitProps, callRenderProp, getElementType } from '@instructure/ui-react-utils';
30
+ import { renderIconWithProps } from '@instructure/ui-icons';
31
+ import { withStyle } from '@instructure/emotion';
32
+ import generateStyle from "./styles.js";
33
+ import { allowedProps } from "./props.js";
34
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
35
+ // Map Billboard sizes to icon sizes
36
+ const billboardSizeToIconSize = {
37
+ small: 'illu-sm',
38
+ medium: 'illu-md',
39
+ large: 'illu-lg'
40
+ };
41
+
42
+ /**
43
+ ---
44
+ category: components
45
+ ---
46
+ **/
47
+ let Billboard = (_dec = withStyle(generateStyle), _dec(_class = (_Billboard = class Billboard extends Component {
48
+ constructor(...args) {
49
+ super(...args);
50
+ this.state = {
51
+ isHovered: false,
52
+ isActive: false
53
+ };
54
+ this.ref = null;
55
+ this.handleRef = el => {
56
+ const elementRef = this.props.elementRef;
57
+ this.ref = el;
58
+ if (typeof elementRef === 'function') {
59
+ elementRef(el);
60
+ }
61
+ };
62
+ this.handleMouseEnter = () => {
63
+ this.setState({
64
+ isHovered: true
65
+ });
66
+ };
67
+ this.handleMouseLeave = () => {
68
+ this.setState({
69
+ isHovered: false,
70
+ isActive: false
71
+ });
72
+ };
73
+ this.handleMouseDown = () => {
74
+ this.setState({
75
+ isActive: true
76
+ });
77
+ };
78
+ this.handleMouseUp = () => {
79
+ this.setState({
80
+ isActive: false
81
+ });
82
+ };
83
+ this.handleClick = e => {
84
+ const _this$props = this.props,
85
+ readOnly = _this$props.readOnly,
86
+ onClick = _this$props.onClick;
87
+ if (readOnly) {
88
+ e.preventDefault();
89
+ e.stopPropagation();
90
+ } else if (typeof onClick === 'function') {
91
+ onClick(e);
92
+ }
93
+ };
94
+ }
95
+ componentDidMount() {
96
+ var _this$props$makeStyle, _this$props2;
97
+ (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
98
+ }
99
+ componentDidUpdate() {
100
+ var _this$props$makeStyle2, _this$props3;
101
+ (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
102
+ }
103
+ renderHeading() {
104
+ const _this$props4 = this.props,
105
+ headingLevel = _this$props4.headingLevel,
106
+ headingAs = _this$props4.headingAs,
107
+ heading = _this$props4.heading,
108
+ styles = _this$props4.styles;
109
+ return _jsx("span", {
110
+ css: styles === null || styles === void 0 ? void 0 : styles.heading,
111
+ children: _jsx(Heading, {
112
+ level: headingLevel,
113
+ as: headingAs,
114
+ color: "primary",
115
+ children: heading
116
+ })
117
+ });
118
+ }
119
+ renderHero() {
120
+ const _this$props5 = this.props,
121
+ hero = _this$props5.hero,
122
+ size = _this$props5.size;
123
+ const _this$state = this.state,
124
+ isHovered = _this$state.isHovered,
125
+ isActive = _this$state.isActive;
126
+ if (!hero) return null;
127
+ const iconSize = billboardSizeToIconSize[size];
128
+ // Priority: active > hover > default
129
+ const iconColor = isActive ? 'onColor' : isHovered ? 'infoColor' : 'baseColor';
130
+ return renderIconWithProps(hero, iconSize, iconColor);
131
+ }
132
+ renderContent() {
133
+ const _this$props6 = this.props,
134
+ heading = _this$props6.heading,
135
+ message = _this$props6.message,
136
+ hero = _this$props6.hero,
137
+ styles = _this$props6.styles;
138
+ return _jsxs("span", {
139
+ css: styles === null || styles === void 0 ? void 0 : styles.content,
140
+ children: [hero && _jsx("span", {
141
+ css: styles === null || styles === void 0 ? void 0 : styles.hero,
142
+ children: this.renderHero()
143
+ }), heading && this.renderHeading(), message && _jsx("span", {
144
+ css: styles === null || styles === void 0 ? void 0 : styles.message,
145
+ children: callRenderProp(message)
146
+ })]
147
+ });
148
+ }
149
+ render() {
150
+ const _this$props7 = this.props,
151
+ href = _this$props7.href,
152
+ disabled = _this$props7.disabled,
153
+ readOnly = _this$props7.readOnly,
154
+ margin = _this$props7.margin,
155
+ styles = _this$props7.styles;
156
+ const Element = getElementType(Billboard, this.props);
157
+ return _jsx(View, {
158
+ as: "div",
159
+ margin: margin,
160
+ children: _jsx(View, {
161
+ ...omitProps(this.props, [...Billboard.allowedProps, ...View.allowedProps]),
162
+ type: Element === 'button' ? 'button' : void 0,
163
+ as: Element,
164
+ elementRef: this.handleRef,
165
+ css: styles === null || styles === void 0 ? void 0 : styles.billboard,
166
+ href: href,
167
+ onClick: this.handleClick,
168
+ onMouseEnter: this.handleMouseEnter,
169
+ onMouseLeave: this.handleMouseLeave,
170
+ onMouseDown: this.handleMouseDown,
171
+ onMouseUp: this.handleMouseUp,
172
+ disabled: disabled,
173
+ "aria-disabled": disabled || readOnly ? 'true' : void 0,
174
+ children: this.renderContent()
175
+ })
176
+ });
177
+ }
178
+ }, _Billboard.displayName = "Billboard", _Billboard.componentId = 'Billboard', _Billboard.allowedProps = allowedProps, _Billboard.defaultProps = {
179
+ disabled: false,
180
+ readOnly: false,
181
+ size: 'medium',
182
+ headingAs: 'span',
183
+ headingLevel: 'h1',
184
+ as: 'span',
185
+ elementRef: () => {}
186
+ }, _Billboard)) || _class);
187
+ export default Billboard;
188
+ export { Billboard };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const allowedProps = ['hero', 'size', 'as', 'elementRef', 'heading', 'headingAs', 'headingLevel', 'message', 'onClick', 'href', 'disabled', 'readOnly', 'margin'];
26
+ export { allowedProps };
@@ -0,0 +1,169 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ /**
26
+ * ---
27
+ * private: true
28
+ * ---
29
+ * Generates the style object from the theme and provided additional information
30
+ * @param {Object} componentTheme The theme variable object.
31
+ * @param {Object} props the props of the component, the style is applied to
32
+ * @param {Object} state the state of the component, the style is applied to
33
+ * @return {Object} The final style object, which will be used in the component
34
+ */
35
+ const generateStyle = (componentTheme, props) => {
36
+ const size = props.size,
37
+ href = props.href,
38
+ onClick = props.onClick,
39
+ disabled = props.disabled,
40
+ hero = props.hero,
41
+ heading = props.heading;
42
+ const clickable = href || onClick;
43
+ const sizeVariants = {
44
+ small: {
45
+ billboard: {
46
+ padding: componentTheme.paddingSmall
47
+ },
48
+ hero: {
49
+ fontSize: '3rem'
50
+ },
51
+ message: {
52
+ fontSize: componentTheme.messageFontSizeSmall
53
+ },
54
+ heading: {
55
+ ...(hero && {
56
+ margin: `${componentTheme.mediumMargin} 0 0`
57
+ })
58
+ }
59
+ },
60
+ medium: {
61
+ billboard: {
62
+ padding: componentTheme.paddingMedium
63
+ },
64
+ hero: {
65
+ fontSize: '5rem'
66
+ },
67
+ message: {
68
+ fontSize: componentTheme.messageFontSizeMedium
69
+ },
70
+ heading: {}
71
+ },
72
+ large: {
73
+ billboard: {
74
+ padding: componentTheme.paddingLarge
75
+ },
76
+ hero: {
77
+ fontSize: '10rem'
78
+ },
79
+ message: {
80
+ fontSize: componentTheme.messageFontSizeLarge
81
+ },
82
+ heading: {}
83
+ }
84
+ };
85
+ const clickableVariants = clickable ? {
86
+ appearance: 'none',
87
+ boxSizing: 'border-box',
88
+ cursor: 'pointer',
89
+ userSelect: 'none',
90
+ touchAction: 'manipulation',
91
+ width: '100%',
92
+ margin: '0',
93
+ border: `${componentTheme.buttonBorderWidth} ${componentTheme.buttonBorderStyle} transparent`,
94
+ borderRadius: componentTheme.buttonBorderRadius,
95
+ background: componentTheme.backgroundColor,
96
+ textDecoration: 'none',
97
+ '&:hover': {
98
+ borderStyle: componentTheme.buttonHoverBorderStyle
99
+ },
100
+ '&:hover, &:focus': {
101
+ textDecoration: 'none',
102
+ outline: 'none',
103
+ borderColor: componentTheme.messageColorClickable
104
+ },
105
+ '&:active': {
106
+ background: componentTheme.clickableActiveBg,
107
+ borderColor: componentTheme.messageColorClickable,
108
+ '& [class$=-billboard__hero], & [class$=-billboard__message]': {
109
+ color: componentTheme.clickableActiveText
110
+ }
111
+ }
112
+ } : {
113
+ backgroundColor: componentTheme.backgroundColor
114
+ };
115
+ return {
116
+ billboard: {
117
+ label: 'billboard',
118
+ boxSizing: 'border-box',
119
+ position: 'relative',
120
+ fontFamily: componentTheme.fontFamily,
121
+ marginLeft: 'auto',
122
+ marginRight: 'auto',
123
+ textAlign: 'center',
124
+ display: 'block',
125
+ ...sizeVariants[size].billboard,
126
+ ...clickableVariants,
127
+ ...(disabled && {
128
+ cursor: 'not-allowed',
129
+ pointerEvents: 'none',
130
+ opacity: 0.5
131
+ })
132
+ },
133
+ content: {
134
+ label: 'billboard__content',
135
+ display: 'block'
136
+ },
137
+ hero: {
138
+ label: 'billboard__hero',
139
+ display: 'block',
140
+ ...sizeVariants[size].hero,
141
+ '& > img, & > svg': {
142
+ maxWidth: '100%',
143
+ display: 'block',
144
+ margin: '0 auto'
145
+ },
146
+ '& > img': {
147
+ height: 'auto'
148
+ }
149
+ },
150
+ heading: {
151
+ label: 'billboard__heading',
152
+ display: 'block',
153
+ ...(hero && {
154
+ margin: `${componentTheme.largeMargin} 0 0`
155
+ }),
156
+ ...sizeVariants[size].heading
157
+ },
158
+ message: {
159
+ label: 'billboard__message',
160
+ display: 'block',
161
+ color: clickable ? componentTheme.messageColorClickable : componentTheme.messageColor,
162
+ ...((hero || heading) && {
163
+ margin: `${componentTheme.mediumMargin} 0 0`
164
+ }),
165
+ ...sizeVariants[size].message
166
+ }
167
+ };
168
+ };
169
+ export default generateStyle;
@@ -21,4 +21,4 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- export { Billboard } from "./Billboard/index.js";
24
+ export { Billboard } from "../Billboard/v1/index.js";
@@ -21,5 +21,4 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- export { Billboard } from './Billboard'
25
- export type { BillboardProps } from './Billboard/props'
24
+ export { Billboard } from "../Billboard/v2/index.js";
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = exports.Billboard = void 0;
8
8
  var _react = require("react");
9
- var _Heading = require("@instructure/ui-heading/lib/Heading");
10
- var _View = require("@instructure/ui-view/lib/View");
9
+ var _v11_ = require("@instructure/ui-heading/v11_6");
10
+ var _v11_2 = require("@instructure/ui-view/v11_6");
11
11
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
12
12
  var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
13
13
  var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
@@ -45,7 +45,7 @@ var _dec, _class, _Billboard;
45
45
  category: components
46
46
  ---
47
47
  **/
48
- let Billboard = exports.Billboard = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_Billboard = class Billboard extends _react.Component {
48
+ let Billboard = exports.Billboard = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = (_Billboard = class Billboard extends _react.Component {
49
49
  constructor(...args) {
50
50
  super(...args);
51
51
  this.ref = null;
@@ -84,7 +84,7 @@ let Billboard = exports.Billboard = (_dec = (0, _emotion.withStyle)(_styles.defa
84
84
  styles = _this$props4.styles;
85
85
  return (0, _jsxRuntime.jsx)("span", {
86
86
  css: styles === null || styles === void 0 ? void 0 : styles.heading,
87
- children: (0, _jsxRuntime.jsx)(_Heading.Heading, {
87
+ children: (0, _jsxRuntime.jsx)(_v11_.Heading, {
88
88
  level: headingLevel,
89
89
  as: headingAs,
90
90
  color: "primary",
@@ -136,11 +136,11 @@ let Billboard = exports.Billboard = (_dec = (0, _emotion.withStyle)(_styles.defa
136
136
  margin = _this$props6.margin,
137
137
  styles = _this$props6.styles;
138
138
  const Element = (0, _getElementType.getElementType)(Billboard, this.props);
139
- return (0, _jsxRuntime.jsx)(_View.View, {
139
+ return (0, _jsxRuntime.jsx)(_v11_2.View, {
140
140
  as: "div",
141
141
  margin: margin,
142
- children: (0, _jsxRuntime.jsx)(_View.View, {
143
- ...(0, _omitProps.omitProps)(this.props, [...Billboard.allowedProps, ..._View.View.allowedProps]),
142
+ children: (0, _jsxRuntime.jsx)(_v11_2.View, {
143
+ ...(0, _omitProps.omitProps)(this.props, [...Billboard.allowedProps, ..._v11_2.View.allowedProps]),
144
144
  type: Element === 'button' ? 'button' : void 0,
145
145
  as: Element,
146
146
  elementRef: this.handleRef,
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.Billboard = void 0;
8
+ var _react = require("react");
9
+ var _latest = require("@instructure/ui-heading/latest");
10
+ var _latest2 = require("@instructure/ui-view/latest");
11
+ var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
12
+ var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
13
+ var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
14
+ var _renderIconWithProps = require("@instructure/ui-icons/lib/IconPropsProvider/renderIconWithProps.js");
15
+ var _emotion = require("@instructure/emotion");
16
+ var _styles = _interopRequireDefault(require("./styles"));
17
+ var _props = require("./props");
18
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
19
+ var _dec, _class, _Billboard;
20
+ /*
21
+ * The MIT License (MIT)
22
+ *
23
+ * Copyright (c) 2015 - present Instructure, Inc.
24
+ *
25
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
26
+ * of this software and associated documentation files (the "Software"), to deal
27
+ * in the Software without restriction, including without limitation the rights
28
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
+ * copies of the Software, and to permit persons to whom the Software is
30
+ * furnished to do so, subject to the following conditions:
31
+ *
32
+ * The above copyright notice and this permission notice shall be included in all
33
+ * copies or substantial portions of the Software.
34
+ *
35
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41
+ * SOFTWARE.
42
+ */
43
+ // Map Billboard sizes to icon sizes
44
+ const billboardSizeToIconSize = {
45
+ small: 'illu-sm',
46
+ medium: 'illu-md',
47
+ large: 'illu-lg'
48
+ };
49
+
50
+ /**
51
+ ---
52
+ category: components
53
+ ---
54
+ **/
55
+ let Billboard = exports.Billboard = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = (_Billboard = class Billboard extends _react.Component {
56
+ constructor(...args) {
57
+ super(...args);
58
+ this.state = {
59
+ isHovered: false,
60
+ isActive: false
61
+ };
62
+ this.ref = null;
63
+ this.handleRef = el => {
64
+ const elementRef = this.props.elementRef;
65
+ this.ref = el;
66
+ if (typeof elementRef === 'function') {
67
+ elementRef(el);
68
+ }
69
+ };
70
+ this.handleMouseEnter = () => {
71
+ this.setState({
72
+ isHovered: true
73
+ });
74
+ };
75
+ this.handleMouseLeave = () => {
76
+ this.setState({
77
+ isHovered: false,
78
+ isActive: false
79
+ });
80
+ };
81
+ this.handleMouseDown = () => {
82
+ this.setState({
83
+ isActive: true
84
+ });
85
+ };
86
+ this.handleMouseUp = () => {
87
+ this.setState({
88
+ isActive: false
89
+ });
90
+ };
91
+ this.handleClick = e => {
92
+ const _this$props = this.props,
93
+ readOnly = _this$props.readOnly,
94
+ onClick = _this$props.onClick;
95
+ if (readOnly) {
96
+ e.preventDefault();
97
+ e.stopPropagation();
98
+ } else if (typeof onClick === 'function') {
99
+ onClick(e);
100
+ }
101
+ };
102
+ }
103
+ componentDidMount() {
104
+ var _this$props$makeStyle, _this$props2;
105
+ (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
106
+ }
107
+ componentDidUpdate() {
108
+ var _this$props$makeStyle2, _this$props3;
109
+ (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
110
+ }
111
+ renderHeading() {
112
+ const _this$props4 = this.props,
113
+ headingLevel = _this$props4.headingLevel,
114
+ headingAs = _this$props4.headingAs,
115
+ heading = _this$props4.heading,
116
+ styles = _this$props4.styles;
117
+ return (0, _jsxRuntime.jsx)("span", {
118
+ css: styles === null || styles === void 0 ? void 0 : styles.heading,
119
+ children: (0, _jsxRuntime.jsx)(_latest.Heading, {
120
+ level: headingLevel,
121
+ as: headingAs,
122
+ color: "primary",
123
+ children: heading
124
+ })
125
+ });
126
+ }
127
+ renderHero() {
128
+ const _this$props5 = this.props,
129
+ hero = _this$props5.hero,
130
+ size = _this$props5.size;
131
+ const _this$state = this.state,
132
+ isHovered = _this$state.isHovered,
133
+ isActive = _this$state.isActive;
134
+ if (!hero) return null;
135
+ const iconSize = billboardSizeToIconSize[size];
136
+ // Priority: active > hover > default
137
+ const iconColor = isActive ? 'onColor' : isHovered ? 'infoColor' : 'baseColor';
138
+ return (0, _renderIconWithProps.renderIconWithProps)(hero, iconSize, iconColor);
139
+ }
140
+ renderContent() {
141
+ const _this$props6 = this.props,
142
+ heading = _this$props6.heading,
143
+ message = _this$props6.message,
144
+ hero = _this$props6.hero,
145
+ styles = _this$props6.styles;
146
+ return (0, _jsxRuntime.jsxs)("span", {
147
+ css: styles === null || styles === void 0 ? void 0 : styles.content,
148
+ children: [hero && (0, _jsxRuntime.jsx)("span", {
149
+ css: styles === null || styles === void 0 ? void 0 : styles.hero,
150
+ children: this.renderHero()
151
+ }), heading && this.renderHeading(), message && (0, _jsxRuntime.jsx)("span", {
152
+ css: styles === null || styles === void 0 ? void 0 : styles.message,
153
+ children: (0, _callRenderProp.callRenderProp)(message)
154
+ })]
155
+ });
156
+ }
157
+ render() {
158
+ const _this$props7 = this.props,
159
+ href = _this$props7.href,
160
+ disabled = _this$props7.disabled,
161
+ readOnly = _this$props7.readOnly,
162
+ margin = _this$props7.margin,
163
+ styles = _this$props7.styles;
164
+ const Element = (0, _getElementType.getElementType)(Billboard, this.props);
165
+ return (0, _jsxRuntime.jsx)(_latest2.View, {
166
+ as: "div",
167
+ margin: margin,
168
+ children: (0, _jsxRuntime.jsx)(_latest2.View, {
169
+ ...(0, _omitProps.omitProps)(this.props, [...Billboard.allowedProps, ..._latest2.View.allowedProps]),
170
+ type: Element === 'button' ? 'button' : void 0,
171
+ as: Element,
172
+ elementRef: this.handleRef,
173
+ css: styles === null || styles === void 0 ? void 0 : styles.billboard,
174
+ href: href,
175
+ onClick: this.handleClick,
176
+ onMouseEnter: this.handleMouseEnter,
177
+ onMouseLeave: this.handleMouseLeave,
178
+ onMouseDown: this.handleMouseDown,
179
+ onMouseUp: this.handleMouseUp,
180
+ disabled: disabled,
181
+ "aria-disabled": disabled || readOnly ? 'true' : void 0,
182
+ children: this.renderContent()
183
+ })
184
+ });
185
+ }
186
+ }, _Billboard.displayName = "Billboard", _Billboard.componentId = 'Billboard', _Billboard.allowedProps = _props.allowedProps, _Billboard.defaultProps = {
187
+ disabled: false,
188
+ readOnly: false,
189
+ size: 'medium',
190
+ headingAs: 'span',
191
+ headingLevel: 'h1',
192
+ as: 'span',
193
+ elementRef: () => {}
194
+ }, _Billboard)) || _class);
195
+ var _default = exports.default = Billboard;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowedProps = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ const allowedProps = exports.allowedProps = ['hero', 'size', 'as', 'elementRef', 'heading', 'headingAs', 'headingLevel', 'message', 'onClick', 'href', 'disabled', 'readOnly', 'margin'];