@uncinc/uncinc-react-kitchen-sink 2.2.16 → 2.2.17
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.
|
@@ -41,6 +41,10 @@ const Picture = ({
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
const isValidImage = url => {
|
|
44
|
+
if (!url) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
44
48
|
const extension = getImageExtension(url);
|
|
45
49
|
return Object.keys(mimeTypes).includes(extension);
|
|
46
50
|
};
|
|
@@ -48,10 +52,21 @@ const Picture = ({
|
|
|
48
52
|
if (Immutable.Iterable.isIterable(Immutable.fromJS(src))) {
|
|
49
53
|
// Sources have to be defined in a descending order.
|
|
50
54
|
// We sort them from best to worst quality.
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const sourcesAll = Immutable.fromJS(src).toOrderedMap().sortBy((url, breakpoint) => parseInt(breakpoint)).reverse();
|
|
56
|
+
const sources = sourcesAll.map(url => {
|
|
57
|
+
if (isValidImage(url)) {
|
|
58
|
+
return url;
|
|
59
|
+
}
|
|
60
|
+
}).filter(image => {
|
|
61
|
+
if (image !== false) {
|
|
62
|
+
return image;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
;
|
|
66
|
+
return null;
|
|
67
|
+
}); // Only render if all our image sources are valid
|
|
68
|
+
|
|
69
|
+
const hasValidSources = sources.count() > 0;
|
|
55
70
|
|
|
56
71
|
if (!hasValidSources) {
|
|
57
72
|
return null;
|
|
@@ -22,6 +22,11 @@ export const Default = () => /*#__PURE__*/React.createElement("div", {
|
|
|
22
22
|
}, /*#__PURE__*/React.createElement(Image, {
|
|
23
23
|
src: "https://dummyimage.com/400x400/73cac4/fff.gif",
|
|
24
24
|
alt: "Image 3"
|
|
25
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
className: "ImageWrapper__image"
|
|
27
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
28
|
+
src: "https://dummyimage.com/400x400/ff8833/fff.svg",
|
|
29
|
+
alt: "Image 4"
|
|
25
30
|
})));
|
|
26
31
|
export const Responsive = () => /*#__PURE__*/React.createElement("div", {
|
|
27
32
|
className: "ImageWrapper"
|
|
@@ -48,4 +53,14 @@ export const BackgroundImageResponsive = () => /*#__PURE__*/React.createElement(
|
|
|
48
53
|
1000: "https://dummyimage.com/1000x400/73cac4/fff.jpg"
|
|
49
54
|
},
|
|
50
55
|
alt: "Image 1"
|
|
56
|
+
}));
|
|
57
|
+
export const ImageResponsiveFail = () => /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
className: "ImageWrapper"
|
|
59
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
60
|
+
src: {
|
|
61
|
+
400: null,
|
|
62
|
+
600: "https://dummyimage.com/600x400/f2788f/fff.png",
|
|
63
|
+
1000: "https://dummyimage.com/1000x400/73cac4/fff.jpg"
|
|
64
|
+
},
|
|
65
|
+
alt: "Image 1"
|
|
51
66
|
}));
|
package/package.json
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ApolloServer, gql } from 'apollo-server-micro';
|
|
2
|
-
export const config = {
|
|
3
|
-
api: {
|
|
4
|
-
bodyParser: false
|
|
5
|
-
}
|
|
6
|
-
};
|
|
7
|
-
const typeDefs = [gql`
|
|
8
|
-
type Query {
|
|
9
|
-
root: String
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type Mutation {
|
|
13
|
-
root: String
|
|
14
|
-
}
|
|
15
|
-
`];
|
|
16
|
-
const server = new ApolloServer({
|
|
17
|
-
typeDefs,
|
|
18
|
-
resolvers: {},
|
|
19
|
-
introspection: true,
|
|
20
|
-
playground: true,
|
|
21
|
-
context: {}
|
|
22
|
-
});
|
|
23
|
-
export default server.createHandler({
|
|
24
|
-
path: '/api/graphql'
|
|
25
|
-
});
|