@docusaurus/plugin-ideal-image 3.7.0 → 3.8.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 (69) hide show
  1. package/lib/index.js +6 -0
  2. package/lib/theme/IdealImage/index.js +1 -2
  3. package/lib/theme/IdealImageLegacy/LICENSE +20 -0
  4. package/lib/theme/IdealImageLegacy/README.md +13 -0
  5. package/lib/theme/IdealImageLegacy/components/Icon/Download.d.ts +3 -0
  6. package/lib/theme/IdealImageLegacy/components/Icon/Download.js +15 -0
  7. package/lib/theme/IdealImageLegacy/components/Icon/Loading.d.ts +3 -0
  8. package/lib/theme/IdealImageLegacy/components/Icon/Loading.js +15 -0
  9. package/lib/theme/IdealImageLegacy/components/Icon/Offline.d.ts +3 -0
  10. package/lib/theme/IdealImageLegacy/components/Icon/Offline.js +15 -0
  11. package/lib/theme/IdealImageLegacy/components/Icon/Warning.d.ts +3 -0
  12. package/lib/theme/IdealImageLegacy/components/Icon/Warning.js +15 -0
  13. package/lib/theme/IdealImageLegacy/components/Icon/index.d.ts +8 -0
  14. package/lib/theme/IdealImageLegacy/components/Icon/index.js +25 -0
  15. package/lib/theme/IdealImageLegacy/components/IdealImage/index.d.ts +42 -0
  16. package/lib/theme/IdealImageLegacy/components/IdealImage/index.js +352 -0
  17. package/lib/theme/IdealImageLegacy/components/IdealImage/waypoint.d.ts +10 -0
  18. package/lib/theme/IdealImageLegacy/components/IdealImage/waypoint.js +188 -0
  19. package/lib/theme/IdealImageLegacy/components/IdealImageWithDefaults/index.d.ts +33 -0
  20. package/lib/theme/IdealImageLegacy/components/IdealImageWithDefaults/index.js +12 -0
  21. package/lib/theme/IdealImageLegacy/components/Media/index.d.ts +20 -0
  22. package/lib/theme/IdealImageLegacy/components/Media/index.js +169 -0
  23. package/lib/theme/IdealImageLegacy/components/MediaWithDefaults/README.md +89 -0
  24. package/lib/theme/IdealImageLegacy/components/MediaWithDefaults/index.d.ts +33 -0
  25. package/lib/theme/IdealImageLegacy/components/MediaWithDefaults/index.js +12 -0
  26. package/lib/theme/IdealImageLegacy/components/composeStyle.d.ts +5 -0
  27. package/lib/theme/IdealImageLegacy/components/composeStyle.js +37 -0
  28. package/lib/theme/IdealImageLegacy/components/constants.d.ts +22 -0
  29. package/lib/theme/IdealImageLegacy/components/constants.js +24 -0
  30. package/lib/theme/IdealImageLegacy/components/helpers.d.ts +22 -0
  31. package/lib/theme/IdealImageLegacy/components/helpers.js +142 -0
  32. package/lib/theme/IdealImageLegacy/components/icons.d.ts +15 -0
  33. package/lib/theme/IdealImageLegacy/components/icons.js +16 -0
  34. package/lib/theme/IdealImageLegacy/components/loaders.d.ts +4 -0
  35. package/lib/theme/IdealImageLegacy/components/loaders.js +112 -0
  36. package/lib/theme/IdealImageLegacy/components/theme.d.ts +30 -0
  37. package/lib/theme/IdealImageLegacy/components/theme.js +26 -0
  38. package/lib/theme/IdealImageLegacy/components/theme.module.css +35 -0
  39. package/lib/theme/IdealImageLegacy/components/unfetch.d.ts +7 -0
  40. package/lib/theme/IdealImageLegacy/components/unfetch.js +74 -0
  41. package/lib/theme/IdealImageLegacy/index.d.ts +2 -0
  42. package/lib/theme/IdealImageLegacy/index.js +2 -0
  43. package/package.json +8 -10
  44. package/src/index.ts +6 -0
  45. package/src/plugin-ideal-image.d.ts +121 -0
  46. package/src/theme/IdealImage/index.tsx +2 -3
  47. package/src/theme/IdealImageLegacy/LICENSE +20 -0
  48. package/src/theme/IdealImageLegacy/README.md +13 -0
  49. package/src/theme/IdealImageLegacy/components/Icon/Download.js +15 -0
  50. package/src/theme/IdealImageLegacy/components/Icon/Loading.js +15 -0
  51. package/src/theme/IdealImageLegacy/components/Icon/Offline.js +15 -0
  52. package/src/theme/IdealImageLegacy/components/Icon/Warning.js +15 -0
  53. package/src/theme/IdealImageLegacy/components/Icon/index.js +25 -0
  54. package/src/theme/IdealImageLegacy/components/IdealImage/index.js +352 -0
  55. package/src/theme/IdealImageLegacy/components/IdealImage/waypoint.tsx +254 -0
  56. package/src/theme/IdealImageLegacy/components/IdealImageWithDefaults/index.js +12 -0
  57. package/src/theme/IdealImageLegacy/components/Media/index.js +169 -0
  58. package/src/theme/IdealImageLegacy/components/MediaWithDefaults/README.md +89 -0
  59. package/src/theme/IdealImageLegacy/components/MediaWithDefaults/index.js +12 -0
  60. package/src/theme/IdealImageLegacy/components/composeStyle.js +37 -0
  61. package/src/theme/IdealImageLegacy/components/constants.js +24 -0
  62. package/src/theme/IdealImageLegacy/components/helpers.js +142 -0
  63. package/src/theme/IdealImageLegacy/components/icons.js +16 -0
  64. package/src/theme/IdealImageLegacy/components/loaders.js +112 -0
  65. package/src/theme/IdealImageLegacy/components/theme.js +26 -0
  66. package/src/theme/IdealImageLegacy/components/theme.module.css +35 -0
  67. package/src/theme/IdealImageLegacy/components/unfetch.js +74 -0
  68. package/src/theme/IdealImageLegacy/index.tsx +3 -0
  69. package/src/deps.d.ts +0 -124
@@ -0,0 +1,188 @@
1
+ /*
2
+ This is a slimmed down copy of https://github.com/civiccc/react-waypoint
3
+ The MIT License (MIT)
4
+ Copyright (c) 2015 Brigade
5
+ */
6
+ import React, {createRef} from 'react';
7
+ function addEventListener(element, type, listener, options) {
8
+ element.addEventListener(type, listener, options);
9
+ return () => element.removeEventListener(type, listener, options);
10
+ }
11
+ // Because waypoint may fire before the setState() updates due to batching
12
+ // queueMicrotask is a better option than setTimeout() or React.flushSync()
13
+ // See https://github.com/facebook/docusaurus/issues/11018
14
+ // See https://github.com/civiccc/react-waypoint/blob/0905ac5a073131147c96dd0694bd6f1b6ee8bc97/src/onNextTick.js
15
+ function subscribeMicrotask(callback) {
16
+ let subscribed = true;
17
+ queueMicrotask(() => {
18
+ if (subscribed) callback();
19
+ });
20
+ return () => (subscribed = false);
21
+ }
22
+ export function Waypoint(props) {
23
+ return typeof window !== 'undefined' ? (
24
+ <WaypointClient {...props}>{props.children}</WaypointClient>
25
+ ) : (
26
+ props.children
27
+ );
28
+ }
29
+ // TODO maybe replace this with IntersectionObserver later?
30
+ // IntersectionObserver doesn't support the "fast scroll" thing
31
+ // but it's probably not a big deal
32
+ class WaypointClient extends React.Component {
33
+ static defaultProps = {
34
+ topOffset: 0,
35
+ bottomOffset: 0,
36
+ onEnter() {},
37
+ onLeave() {},
38
+ };
39
+ scrollableAncestor;
40
+ previousPosition = null;
41
+ unsubscribe;
42
+ innerRef = createRef();
43
+ componentDidMount() {
44
+ this.scrollableAncestor = findScrollableAncestor(this.innerRef.current);
45
+ const unsubscribeScroll = addEventListener(
46
+ this.scrollableAncestor,
47
+ 'scroll',
48
+ this._handleScroll,
49
+ {passive: true},
50
+ );
51
+ const unsubscribeResize = addEventListener(
52
+ window,
53
+ 'resize',
54
+ this._handleScroll,
55
+ {passive: true},
56
+ );
57
+ const unsubscribeInitialScroll = subscribeMicrotask(() => {
58
+ this._handleScroll();
59
+ });
60
+ this.unsubscribe = () => {
61
+ unsubscribeScroll();
62
+ unsubscribeResize();
63
+ unsubscribeInitialScroll();
64
+ };
65
+ }
66
+ componentDidUpdate() {
67
+ this._handleScroll();
68
+ }
69
+ componentWillUnmount() {
70
+ this.unsubscribe?.();
71
+ }
72
+ _handleScroll = () => {
73
+ const node = this.innerRef.current;
74
+ const {topOffset, bottomOffset, onEnter, onLeave} = this.props;
75
+ const bounds = getBounds({
76
+ node: node,
77
+ scrollableAncestor: this.scrollableAncestor,
78
+ topOffset,
79
+ bottomOffset,
80
+ });
81
+ const currentPosition = getCurrentPosition(bounds);
82
+ const previousPosition = this.previousPosition;
83
+ this.previousPosition = currentPosition;
84
+ if (previousPosition === currentPosition) {
85
+ return;
86
+ }
87
+ if (currentPosition === 'inside') {
88
+ onEnter();
89
+ } else if (previousPosition === 'inside') {
90
+ onLeave();
91
+ }
92
+ const isRapidScrollDown =
93
+ previousPosition === 'below' && currentPosition === 'above';
94
+ const isRapidScrollUp =
95
+ previousPosition === 'above' && currentPosition === 'below';
96
+ if (isRapidScrollDown || isRapidScrollUp) {
97
+ onEnter();
98
+ onLeave();
99
+ }
100
+ };
101
+ render() {
102
+ // @ts-expect-error: fix this implicit API
103
+ return React.cloneElement(this.props.children, {innerRef: this.innerRef});
104
+ }
105
+ }
106
+ /**
107
+ * Traverses up the DOM to find an ancestor container which has an overflow
108
+ * style that allows for scrolling.
109
+ *
110
+ * @return {Object} the closest ancestor element with an overflow style that
111
+ * allows for scrolling. If none is found, the `window` object is returned
112
+ * as a fallback.
113
+ */
114
+ function findScrollableAncestor(inputNode) {
115
+ let node = inputNode;
116
+ while (node.parentNode) {
117
+ // @ts-expect-error: it's fine
118
+ node = node.parentNode;
119
+ if (node === document.body) {
120
+ // We've reached all the way to the root node.
121
+ return window;
122
+ }
123
+ const style = window.getComputedStyle(node);
124
+ const overflow =
125
+ style.getPropertyValue('overflow-y') ||
126
+ style.getPropertyValue('overflow');
127
+ if (
128
+ overflow === 'auto' ||
129
+ overflow === 'scroll' ||
130
+ overflow === 'overlay'
131
+ ) {
132
+ return node;
133
+ }
134
+ }
135
+ // A scrollable ancestor element was not found, which means that we need to
136
+ // do stuff on window.
137
+ return window;
138
+ }
139
+ function getBounds({node, scrollableAncestor, topOffset, bottomOffset}) {
140
+ const {top, bottom} = node.getBoundingClientRect();
141
+ let contextHeight;
142
+ let contextScrollTop;
143
+ if (scrollableAncestor === window) {
144
+ contextHeight = window.innerHeight;
145
+ contextScrollTop = 0;
146
+ } else {
147
+ const ancestorElement = scrollableAncestor;
148
+ contextHeight = ancestorElement.offsetHeight;
149
+ contextScrollTop = ancestorElement.getBoundingClientRect().top;
150
+ }
151
+ const contextBottom = contextScrollTop + contextHeight;
152
+ return {
153
+ top,
154
+ bottom,
155
+ viewportTop: contextScrollTop + topOffset,
156
+ viewportBottom: contextBottom - bottomOffset,
157
+ };
158
+ }
159
+ function getCurrentPosition(bounds) {
160
+ if (bounds.viewportBottom - bounds.viewportTop === 0) {
161
+ return 'invisible';
162
+ }
163
+ // top is within the viewport
164
+ if (bounds.viewportTop <= bounds.top && bounds.top <= bounds.viewportBottom) {
165
+ return 'inside';
166
+ }
167
+ // bottom is within the viewport
168
+ if (
169
+ bounds.viewportTop <= bounds.bottom &&
170
+ bounds.bottom <= bounds.viewportBottom
171
+ ) {
172
+ return 'inside';
173
+ }
174
+ // top is above the viewport and bottom is below the viewport
175
+ if (
176
+ bounds.top <= bounds.viewportTop &&
177
+ bounds.viewportBottom <= bounds.bottom
178
+ ) {
179
+ return 'inside';
180
+ }
181
+ if (bounds.viewportBottom < bounds.top) {
182
+ return 'below';
183
+ }
184
+ if (bounds.top < bounds.viewportTop) {
185
+ return 'above';
186
+ }
187
+ return 'invisible';
188
+ }
@@ -0,0 +1,33 @@
1
+ export default IdealImageWithDefaults;
2
+ declare function IdealImageWithDefaults({ icons: iconsProp, theme: themeProp, ...props }: {
3
+ [x: string]: any;
4
+ icons?: {
5
+ [x: string]: ((props: any) => React.JSX.Element) | null;
6
+ } | undefined;
7
+ theme?: {
8
+ placeholder: {
9
+ backgroundSize: string;
10
+ backgroundRepeat: string;
11
+ position: string;
12
+ };
13
+ img: {
14
+ width: string;
15
+ height: string;
16
+ maxWidth: string;
17
+ marginBottom: string;
18
+ };
19
+ icon: {
20
+ position: string;
21
+ top: string;
22
+ left: string;
23
+ transform: string;
24
+ textAlign: string;
25
+ };
26
+ noscript: {
27
+ position: string;
28
+ top: number;
29
+ left: number;
30
+ };
31
+ } | undefined;
32
+ }): React.JSX.Element;
33
+ import React from 'react';
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import IdealImage from '../IdealImage';
3
+ import icons from '../icons';
4
+ import theme from '../theme';
5
+
6
+ const IdealImageWithDefaults = ({
7
+ icons: iconsProp = icons,
8
+ theme: themeProp = theme,
9
+ ...props
10
+ }) => <IdealImage {...props} icons={iconsProp} theme={themeProp} />;
11
+
12
+ export default IdealImageWithDefaults;
@@ -0,0 +1,20 @@
1
+ export default class Media extends React.PureComponent<any, any, any> {
2
+ static defaultProps: {
3
+ iconColor: string;
4
+ iconSize: number;
5
+ };
6
+ constructor(props: any);
7
+ state: {
8
+ isMounted: boolean;
9
+ };
10
+ componentDidMount(): void;
11
+ renderIcon(props: any): React.DetailedReactHTMLElement<{
12
+ className: string;
13
+ style: object;
14
+ }, HTMLElement> | null;
15
+ renderImage(props: any): React.JSX.Element;
16
+ dimensionElement: SVGSVGElement | null | undefined;
17
+ renderNoscript(props: any): React.JSX.Element | null;
18
+ render(): React.JSX.Element;
19
+ }
20
+ import React from 'react';
@@ -0,0 +1,169 @@
1
+ import React, {PureComponent} from 'react';
2
+ // import PropTypes from 'prop-types'
3
+ import compose from '../composeStyle';
4
+ import {icons as defaultIcons} from '../constants';
5
+
6
+ const {load, loading, loaded, error, noicon, offline} = defaultIcons;
7
+
8
+ export default class Media extends PureComponent {
9
+ /*static propTypes = {
10
+ /!** URL of the image *!/
11
+ src: PropTypes.string.isRequired,
12
+ /!** Width of the image in px *!/
13
+ width: PropTypes.number.isRequired,
14
+ /!** Height of the image in px *!/
15
+ height: PropTypes.number.isRequired,
16
+ placeholder: PropTypes.oneOfType([
17
+ PropTypes.shape({
18
+ /!** Solid color placeholder *!/
19
+ color: PropTypes.string.isRequired,
20
+ }),
21
+ PropTypes.shape({
22
+ /!**
23
+ * [Low Quality Image Placeholder](https://github.com/zouhir/lqip)
24
+ * [SVG-Based Image Placeholder](https://github.com/technopagan/sqip)
25
+ * base64 encoded image of low quality
26
+ *!/
27
+ lqip: PropTypes.string.isRequired,
28
+ }),
29
+ ]).isRequired,
30
+ /!** display icon *!/
31
+ icon: PropTypes.oneOf([load, loading, loaded, error, noicon, offline])
32
+ .isRequired,
33
+ /!** Map of icons *!/
34
+ icons: PropTypes.object.isRequired,
35
+ /!** theme object - CSS Modules or React styles *!/
36
+ theme: PropTypes.object.isRequired,
37
+ /!** Alternative text *!/
38
+ alt: PropTypes.string,
39
+ /!** Color of the icon *!/
40
+ iconColor: PropTypes.string,
41
+ /!** Size of the icon in px *!/
42
+ iconSize: PropTypes.number,
43
+ /!** React's style attribute for root element of the component *!/
44
+ style: PropTypes.object,
45
+ /!** React's className attribute for root element of the component *!/
46
+ className: PropTypes.string,
47
+ /!** On click handler *!/
48
+ onClick: PropTypes.func,
49
+ /!** callback to get dimensions of the placeholder *!/
50
+ onDimensions: PropTypes.func,
51
+ /!** message to show below the icon *!/
52
+ message: PropTypes.node,
53
+ /!** reference for Waypoint *!/
54
+ innerRef: PropTypes.func,
55
+ /!** noscript image src *!/
56
+ nsSrc: PropTypes.string,
57
+ /!** noscript image srcSet *!/
58
+ nsSrcSet: PropTypes.string,
59
+ }*/
60
+
61
+ static defaultProps = {
62
+ iconColor: '#fff',
63
+ iconSize: 64,
64
+ };
65
+
66
+ constructor(props) {
67
+ super(props);
68
+ this.state = {isMounted: false};
69
+ }
70
+
71
+ componentDidMount() {
72
+ this.setState({isMounted: true});
73
+
74
+ if (this.props.onDimensions && this.dimensionElement)
75
+ /* Firefox returns 0 for both clientWidth and clientHeight.
76
+ To fix this we can check the parentNode's clientWidth and clientHeight as a fallback. */
77
+ this.props.onDimensions({
78
+ width:
79
+ this.dimensionElement.clientWidth ||
80
+ this.dimensionElement.parentNode.clientWidth,
81
+ height:
82
+ this.dimensionElement.clientHeight ||
83
+ this.dimensionElement.parentNode.clientHeight,
84
+ });
85
+ }
86
+
87
+ renderIcon(props) {
88
+ const {icon, icons, iconColor: fill, iconSize: size, theme} = props;
89
+ const iconToRender = icons[icon];
90
+ if (!iconToRender) return null;
91
+ const styleOrClass = compose(
92
+ {width: size + 100, height: size, color: fill},
93
+ theme.icon,
94
+ );
95
+ return React.createElement('div', styleOrClass, [
96
+ React.createElement(iconToRender, {fill, size, key: 'icon'}),
97
+ React.createElement('br', {key: 'br'}),
98
+ this.props.message,
99
+ ]);
100
+ }
101
+
102
+ renderImage(props) {
103
+ return props.icon === loaded ? (
104
+ <img
105
+ {...compose(props.theme.img)}
106
+ src={props.src}
107
+ alt={props.alt}
108
+ width={props.width}
109
+ height={props.height}
110
+ />
111
+ ) : (
112
+ <svg
113
+ {...compose(props.theme.img)}
114
+ width={props.width}
115
+ height={props.height}
116
+ ref={(ref) => (this.dimensionElement = ref)}
117
+ />
118
+ );
119
+ }
120
+
121
+ renderNoscript(props) {
122
+ // render noscript in ssr + hydration to avoid hydration mismatch error
123
+ return this.state.isMounted ? null : (
124
+ <noscript>
125
+ <img
126
+ {...compose(props.theme.img, props.theme.noscript)}
127
+ src={props.nsSrc}
128
+ srcSet={props.nsSrcSet}
129
+ alt={props.alt}
130
+ width={props.width}
131
+ height={props.height}
132
+ />
133
+ </noscript>
134
+ );
135
+ }
136
+
137
+ render() {
138
+ const props = this.props;
139
+ const {placeholder, theme} = props;
140
+ let background;
141
+ if (props.icon === loaded) {
142
+ background = {};
143
+ } else if (placeholder.lqip) {
144
+ background = {
145
+ backgroundImage: `url("${placeholder.lqip}")`,
146
+ };
147
+ } else {
148
+ background = {
149
+ backgroundColor: placeholder.color,
150
+ };
151
+ }
152
+ return (
153
+ <div
154
+ {...compose(
155
+ theme.placeholder,
156
+ background,
157
+ props.style,
158
+ props.className,
159
+ )}
160
+ onClick={this.props.onClick}
161
+ onKeyPress={this.props.onClick}
162
+ ref={this.props.innerRef}>
163
+ {this.renderImage(props)}
164
+ {this.renderNoscript(props)}
165
+ {this.renderIcon(props)}
166
+ </div>
167
+ );
168
+ }
169
+ }
@@ -0,0 +1,89 @@
1
+ All possible states of the component
2
+
3
+ ```js
4
+ const lqip =
5
+ 'data:image/jpeg;base64,/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAIAA4DASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAUG/8QAIRAAAQQDAAEFAAAAAAAAAAAAAQIDBREABAYhEjEyQVH/xAAUAQEAAAAAAAAAAAAAAAAAAAAE/8QAGBEBAAMBAAAAAAAAAAAAAAAAAQACIRH/2gAMAwEAAhEDEQA/AMJ2DG+7Dw0nz8gsx+uyhlxnWdLakOlfzpIF3aRf1WT5t96P5+N1ug9Tu7ZWS8q1gG6B8H2FDz+YxhjUrEOdZ//Z';
6
+
7
+ const sqip =
8
+ "data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4774 3024'%3e%3cfilter id='b'%3e%3cfeGaussianBlur stdDeviation='12' /%3e%3c/filter%3e%3cpath fill='%23515a57' d='M0 0h4774v3021H0z'/%3e%3cg filter='url(%23b)' transform='translate(9.3 9.3) scale(18.64844)' fill-opacity='.5'%3e%3cellipse fill='whitefef' rx='1' ry='1' transform='matrix(74.55002 60.89891 -21.7939 26.67923 151.8 104.4)'/%3e%3cellipse fill='black80c' cx='216' cy='49' rx='59' ry='59'/%3e%3cellipse fill='black60e' cx='22' cy='60' rx='46' ry='89'/%3e%3cellipse fill='%23ffebd5' cx='110' cy='66' rx='42' ry='28'/%3e%3cellipse fill='whiteff9' rx='1' ry='1' transform='rotate(33.3 -113.2 392.6) scale(42.337 17.49703)'/%3e%3cellipse fill='%23031f1e' rx='1' ry='1' transform='matrix(163.4651 -64.93326 6.77862 17.06471 111 16.4)'/%3e%3cpath fill='whitefea' d='M66 74l9 39 16-44z'/%3e%3cellipse fill='%23a28364' rx='1' ry='1' transform='rotate(-32.4 253.2 -179) scale(30.79511 43.65381)'/%3e%3cpath fill='%231a232c' d='M40 139l61-57 33 95z'/%3e%3cpath fill='%230a222b' d='M249.8 153.3l-48.1-48 32.5-32.6 48.1 48z'/%3e%3c/g%3e%3c/svg%3e";
9
+ <table>
10
+ <tbody>
11
+ <tr>
12
+ <th align="left" width="100">
13
+ load
14
+ </th>
15
+ <td>
16
+ <MediaWithDefaults
17
+ width={3500}
18
+ height={2095}
19
+ placeholder={{lqip: lqip}}
20
+ src="andre-spieker-238-unsplash.jpg"
21
+ style={{maxWidth: 200}}
22
+ icon={'load'}
23
+ />
24
+ </td>
25
+ <th align="left" width="100">
26
+ noicon
27
+ </th>
28
+ <td>
29
+ <MediaWithDefaults
30
+ width={3500}
31
+ height={2095}
32
+ placeholder={{lqip: lqip}}
33
+ src="andre-spieker-238-unsplash.jpg"
34
+ style={{maxWidth: 200}}
35
+ icon={'noicon'}
36
+ />
37
+ </td>
38
+ </tr>
39
+ <tr>
40
+ <th align="left">loading</th>
41
+ <td>
42
+ <MediaWithDefaults
43
+ width={3500}
44
+ height={2095}
45
+ placeholder={{lqip: lqip}}
46
+ src="andre-spieker-238-unsplash.jpg"
47
+ style={{maxWidth: 200}}
48
+ icon={'loading'}
49
+ />
50
+ </td>
51
+ <th align="left">offline</th>
52
+ <td>
53
+ <MediaWithDefaults
54
+ width={3500}
55
+ height={2095}
56
+ placeholder={{lqip: lqip}}
57
+ src="andre-spieker-238-unsplash.jpg"
58
+ style={{maxWidth: 200}}
59
+ icon={'offline'}
60
+ />
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <th align="left">loaded</th>
65
+ <td>
66
+ <MediaWithDefaults
67
+ width={3500}
68
+ height={2095}
69
+ placeholder={{lqip: lqip}}
70
+ src="andre-spieker-238-unsplash.jpg"
71
+ style={{maxWidth: 200}}
72
+ icon={'loaded'}
73
+ />
74
+ </td>
75
+ <th align="left">error</th>
76
+ <td>
77
+ <MediaWithDefaults
78
+ width={3500}
79
+ height={2095}
80
+ placeholder={{lqip: lqip}}
81
+ src="andre-spieker-238-unsplash.jpg"
82
+ style={{maxWidth: 200}}
83
+ icon={'error'}
84
+ />
85
+ </td>
86
+ </tr>
87
+ </tbody>
88
+ </table>;
89
+ ```
@@ -0,0 +1,33 @@
1
+ export default MediaWithDefaults;
2
+ declare function MediaWithDefaults({ icons: iconsProp, theme: themeProp, ...props }: {
3
+ [x: string]: any;
4
+ icons?: {
5
+ [x: string]: ((props: any) => React.JSX.Element) | null;
6
+ } | undefined;
7
+ theme?: {
8
+ placeholder: {
9
+ backgroundSize: string;
10
+ backgroundRepeat: string;
11
+ position: string;
12
+ };
13
+ img: {
14
+ width: string;
15
+ height: string;
16
+ maxWidth: string;
17
+ marginBottom: string;
18
+ };
19
+ icon: {
20
+ position: string;
21
+ top: string;
22
+ left: string;
23
+ transform: string;
24
+ textAlign: string;
25
+ };
26
+ noscript: {
27
+ position: string;
28
+ top: number;
29
+ left: number;
30
+ };
31
+ } | undefined;
32
+ }): React.JSX.Element;
33
+ import React from 'react';
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import Media from '../Media';
3
+ import icons from '../icons';
4
+ import theme from '../theme';
5
+
6
+ const MediaWithDefaults = ({
7
+ icons: iconsProp = icons,
8
+ theme: themeProp = theme,
9
+ ...props
10
+ }) => <Media {...props} icons={iconsProp} theme={themeProp} />;
11
+
12
+ export default MediaWithDefaults;
@@ -0,0 +1,5 @@
1
+ declare function _default(...stylesOrClasses: any[]): {
2
+ className: string;
3
+ style: object;
4
+ };
5
+ export default _default;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Composes styles and/or classes
3
+ *
4
+ * For classes it will concat them in in one string
5
+ * and return as `className` property.
6
+ * Alternative is https://github.com/JedWatson/classnames
7
+ *
8
+ * For objects it will merge them in one object
9
+ * and return as `style` property.
10
+ *
11
+ * Usage:
12
+ * Asume you have `theme` object, which can be css-module
13
+ * or object or other css-in-js compatible with css-module
14
+ *
15
+ * <a {...compose(theme.link, theme.active, {color: "#000"})}>link</a>
16
+ *
17
+ * @returns {{className: string, style: object}} - params for React component
18
+ */
19
+ export default (...stylesOrClasses) => {
20
+ const classes = [];
21
+ let style;
22
+ for (const obj of stylesOrClasses) {
23
+ if (obj instanceof Object) {
24
+ Object.assign(style || (style = {}), obj);
25
+ } else if (obj === undefined || obj === false) {
26
+ // ignore
27
+ } else if (typeof obj === 'string') {
28
+ classes.push(obj);
29
+ } else {
30
+ throw new Error(`Unexpected value ${obj}`);
31
+ }
32
+ }
33
+ return {
34
+ className: classes.length > 1 ? classes.join(' ') : classes[0],
35
+ style,
36
+ };
37
+ };
@@ -0,0 +1,22 @@
1
+ export namespace icons {
2
+ export { load };
3
+ export { loading };
4
+ export { loaded };
5
+ export { error };
6
+ export { noicon };
7
+ export { offline };
8
+ }
9
+ export namespace loadStates {
10
+ export { initial };
11
+ export { loading };
12
+ export { loaded };
13
+ export { error };
14
+ }
15
+ declare const load: "load";
16
+ declare const loading: "loading";
17
+ declare const loaded: "loaded";
18
+ declare const error: "error";
19
+ declare const noicon: "noicon";
20
+ declare const offline: "offline";
21
+ declare const initial: "initial";
22
+ export {};
@@ -0,0 +1,24 @@
1
+ const load = 'load';
2
+ const loading = 'loading';
3
+ const loaded = 'loaded';
4
+ const error = 'error';
5
+ const noicon = 'noicon';
6
+ const offline = 'offline';
7
+
8
+ export const icons = {
9
+ load,
10
+ loading,
11
+ loaded,
12
+ error,
13
+ noicon,
14
+ offline,
15
+ };
16
+
17
+ const initial = 'initial';
18
+
19
+ export const loadStates = {
20
+ initial,
21
+ loading,
22
+ loaded,
23
+ error,
24
+ };
@@ -0,0 +1,22 @@
1
+ export const ssr: boolean;
2
+ export const nativeConnection: boolean;
3
+ export function guessMaxImageWidth(dimensions: any, w: any): number;
4
+ export function bytesToSize(bytes: any): string;
5
+ export const supportsWebp: boolean;
6
+ export function selectSrc({ srcSet, maxImageWidth, supportsWebp }: {
7
+ srcSet: any;
8
+ maxImageWidth: any;
9
+ supportsWebp: any;
10
+ }): any;
11
+ export function fallbackParams({ srcSet, getUrl }: {
12
+ srcSet: any;
13
+ getUrl: any;
14
+ }): {
15
+ nsSrcSet?: undefined;
16
+ nsSrc?: undefined;
17
+ ssr?: undefined;
18
+ } | {
19
+ nsSrcSet: any;
20
+ nsSrc: any;
21
+ ssr: true;
22
+ };