Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3d01f16

Browse files
author
gondzo
committed
Merge branch 'imageGallery' into dev
# Conflicts:#src/config/index.js#src/routes/StatusDetail/components/MissionGalleryItem/MissionGalleryItem.jsx#src/routes/StatusDetail/modules/StatusDetail.js#src/services/APIService.js
2 parents0d299fe +15ac8eb commit3d01f16

File tree

20 files changed

+446
-282
lines changed

20 files changed

+446
-282
lines changed

‎.env‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ REACT_APP_API_BASE_PATH=http://localhost:3500
33
REACT_APP_AUTH0_CLIENT_ID=3CGKzjS2nVSqHxHHE64RhvvKY6e0TYpK
44
REACT_APP_AUTH0_CLIENT_DOMAIN=dronetest.auth0.com
55
REACT_APP_SOCKET_URL=http://localhost:3500
6+
CLOUDINARY_ACCOUNT_NAME=dsp

‎.env.example‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ GOOGLE_API_KEY=AIzaSyCrL-O319wNJK8kk8J_JAYsWgu6yo5YsDI
22
REACT_APP_API_BASE_PATH=http://localhost:3500
33
REACT_APP_AUTH0_CLIENT_ID=3CGKzjS2nVSqHxHHE64RhvvKY6e0TYpK
44
REACT_APP_AUTH0_CLIENT_DOMAIN=dronetest.auth0.com
5-
REACT_APP_SOCKET_URL=http://localhost:3500
5+
REACT_APP_SOCKET_URL=http://localhost:3500
6+
CLOUDINARY_ACCOUNT_NAME=dsp

‎README.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ See Guild https://github.com/lorenwest/node-config/wiki/Configuration-Files
1919
|`PORT`| The port to listen|
2020
|`GOOGLE_API_KEY`| The google api key see (https://developers.google.com/maps/documentation/javascript/get-api-key#key)|
2121
|`API_BASE_URL`| The base URL for Drone API|
22-
|`REACT_APP_API_BASE_PATH`| The React app api base path`|
23-
|`REACT_APP_SOCKET_URL`| The React app app socket url`|
24-
|`REACT_APP_AUTH0_CLIEND_ID`| The React app auth0 client id`|
25-
|`REACT_APP_AUTH0_DOMAIN`| The React app auth0 domain`|
22+
|`REACT_APP_API_BASE_PATH`| The React app api base path|
23+
|`REACT_APP_SOCKET_URL`| The React app app socket url|
24+
|`REACT_APP_AUTH0_CLIEND_ID`| The React app auth0 client id|
25+
|`REACT_APP_AUTH0_DOMAIN`| The React app auth0 domain|
26+
|`CLOUDINARY_ACCOUNT_NAME`| Your`Cloud name` fromhttps://cloudinary.com/console|
2627

2728
Environment variables will be loaded from the .env file during build. Create the .env file based on the provided env.example
2829
###Auth0 setup

‎package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@
8282
"react-google-maps":"^6.0.1",
8383
"react-highcharts":"^11.0.0",
8484
"react-icheck":"^0.3.6",
85+
"react-image-lightbox":"^3.4.1",
8586
"react-input-range":"^0.9.3",
87+
"react-measure":"^1.4.5",
8688
"react-modal":"^1.5.2",
8789
"react-paginate":"^4.1.0",
8890
"react-portal":"^3.0.0",
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
importReact,{PropTypes}from'react';
2+
3+
/**
4+
* Fires onClick only when cursor doesn't move
5+
* Used in react-slick because slick always fires onClick when dragging the slider
6+
*/
7+
8+
classClickWithoutDragextendsReact.Component{
9+
constructor(props){
10+
super(props);
11+
this.isClick=false;
12+
13+
this.onMouseUp=(e)=>{
14+
if(this.isClick){
15+
this.props.onClick(e);
16+
}
17+
};
18+
this.onMouseMove=()=>{
19+
this.isClick=false;
20+
};
21+
this.onMouseDown=()=>{
22+
this.isClick=true;
23+
};
24+
}
25+
26+
render(){
27+
return(
28+
<ahref="#"diff-ca4d16c65584e22afdb7334c1f98996ab11b186a51a904019fa2ceefd92394c3-empty-29-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">
29+
{this.props.children}
30+
</a>
31+
);
32+
}
33+
}
34+
35+
ClickWithoutDrag.propTypes={
36+
children:PropTypes.any.isRequired,
37+
onClick:PropTypes.func.isRequired,
38+
};
39+
40+
exportdefaultClickWithoutDrag;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
importClickWithoutDragfrom'./ClickWithoutDrag';
2+
3+
exportdefaultClickWithoutDrag;
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
importReact,{PropTypes}from'react';
2+
importCSSModulesfrom'react-css-modules';
3+
importSliderfrom'react-slick';
4+
import_from'lodash';
5+
importMeasurefrom'react-measure';
6+
importLightboxfrom'react-image-lightbox';
7+
importconfigfrom'../../config';
8+
importstylesfrom'./CloudinaryGallery.scss';
9+
importCloudinaryGalleryItemfrom'./CloudinaryGalleryItem';
10+
11+
constCLOUDINARY_PREFIX=`http://res.cloudinary.com/${config.CLOUDINARY_ACCOUNT_NAME}/image/fetch/`;
12+
13+
constsliderProps={
14+
infinite:false,
15+
dots:true,
16+
speed:500,
17+
slidesToShow:1,
18+
slidesToScroll:1,
19+
vertical:false,
20+
variableWidth:false,
21+
};
22+
23+
// css margin
24+
constMARGIN=8;
25+
26+
classCloudinaryGalleryextendsReact.Component{
27+
constructor(props){
28+
super(props);
29+
this.state={
30+
photoIndex:0,
31+
isOpen:false,
32+
};
33+
}
34+
35+
render(){
36+
const{items, width, count, height, noItemsText}=this.props;
37+
const{isOpen, photoIndex}=this.state;
38+
39+
if(!items||!items.length){
40+
return(
41+
<pstyleName="no-items">{noItemsText}</p>
42+
);
43+
}
44+
constitemWidth=Math.floor(width/count)-2*MARGIN;
45+
constresizedItems=items.map((item)=>({
46+
...item,
47+
// c_fill = crop with retaining original proportions
48+
// g_auto = auto detect point of interests
49+
// see http://cloudinary.com/blog/introducing_smart_cropping_intelligent_quality_selection_and_automated_responsive_images#automatic_content_aware_cropping_g_auto
50+
src:`${CLOUDINARY_PREFIX}w_${itemWidth},h_${height},c_fill,g_auto/${item.src}`,
51+
}));
52+
return(
53+
<divstyleName="cloudinary-gallery">
54+
{isOpen&&
55+
<Lightbox
56+
mainSrc={items[photoIndex].src}
57+
nextSrc={items[(photoIndex+1)%items.length].src}
58+
prevSrc={items[(photoIndex+items.length-1)%items.length].src}
59+
onCloseRequest={()=>this.setState({isOpen:false})}
60+
onMovePrevRequest={()=>this.setState({
61+
photoIndex:(photoIndex+items.length-1)%items.length,
62+
})}
63+
onMoveNextRequest={()=>this.setState({
64+
photoIndex:(photoIndex+1)%items.length,
65+
})}
66+
/>
67+
}
68+
<Slider{...sliderProps}>
69+
{_.chunk(resizedItems,count).map((slideItems,slideIndex)=>(
70+
<divkey={slideIndex}styleName="slide">
71+
<divstyleName="slide-inner">
72+
{slideItems.map((item,itemIndex)=>(
73+
<divkey={itemIndex}styleName="item">
74+
<CloudinaryGalleryItem
75+
{...item}
76+
onClick={()=>{
77+
this.setState({
78+
isOpen:true,
79+
photoIndex:slideIndex*count+itemIndex,
80+
});
81+
}}
82+
/>
83+
</div>
84+
))}
85+
</div>
86+
</div>
87+
))}
88+
</Slider>
89+
</div>
90+
);
91+
}
92+
}
93+
94+
CloudinaryGallery.propTypes={
95+
items:PropTypes.array.isRequired,
96+
width:PropTypes.number,
97+
count:PropTypes.number.isRequired,
98+
height:PropTypes.number.isRequired,
99+
noItemsText:PropTypes.string.isRequired,
100+
};
101+
102+
// HOC wrapping
103+
104+
constCloudinaryGalleryWithStyles=CSSModules(CloudinaryGallery,styles);
105+
106+
constCloudinaryGalleryWithMeasure=(props)=>(
107+
<Measure>
108+
{
109+
({width})=><CloudinaryGalleryWithStyles{...props}width={width}/>
110+
}
111+
</Measure>
112+
);
113+
exportdefaultCloudinaryGalleryWithMeasure;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp