Skip to content

Commit

Permalink
add mobileSize/material-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaserbenyuk committed Sep 12, 2019
1 parent 51962ca commit 92232a0
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 4 deletions.
1 change: 1 addition & 0 deletions .firebase/hosting.YnVpbGQ.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index.html,1568285365825,6029cd2b5875e3367057ce226ddffbfbb10b661b37a656acd1e0b25ee9101eb1
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "geoping-245617"
}
}
65 changes: 65 additions & 0 deletions build/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Welcome to Firebase Hosting</title>

<!-- update the version number as needed -->
<script defer src="/__/firebase/6.6.0/firebase-app.js"></script>
<!-- include only the Firebase features as you need -->
<script defer src="/__/firebase/6.6.0/firebase-auth.js"></script>
<script defer src="/__/firebase/6.6.0/firebase-database.js"></script>
<script defer src="/__/firebase/6.6.0/firebase-messaging.js"></script>
<script defer src="/__/firebase/6.6.0/firebase-storage.js"></script>
<!-- initialize the SDK after all desired features are loaded -->
<script defer src="/__/firebase/init.js"></script>

<style media="screen">
body { background: #ECEFF1; color: rgba(0,0,0,0.87); font-family: Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 0; }
#message { background: white; max-width: 360px; margin: 100px auto 16px; padding: 32px 24px; border-radius: 3px; }
#message h2 { color: #ffa100; font-weight: bold; font-size: 16px; margin: 0 0 8px; }
#message h1 { font-size: 22px; font-weight: 300; color: rgba(0,0,0,0.6); margin: 0 0 16px;}
#message p { line-height: 140%; margin: 16px 0 24px; font-size: 14px; }
#message a { display: block; text-align: center; background: #039be5; text-transform: uppercase; text-decoration: none; color: white; padding: 16px; border-radius: 4px; }
#message, #message a { box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); }
#load { color: rgba(0,0,0,0.4); text-align: center; font-size: 13px; }
@media (max-width: 600px) {
body, #message { margin-top: 0; background: white; box-shadow: none; }
body { border-top: 16px solid #ffa100; }
}
</style>
</head>
<body>
<div id="message">
<h2>Welcome</h2>
<h1>Firebase Hosting Setup Complete</h1>
<p>You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!</p>
<a target="_blank" href="https://firebase.google.com/docs/hosting/">Open Hosting Documentation</a>
</div>
<p id="load">Firebase SDK Loading&hellip;</p>

<script>
document.addEventListener('DOMContentLoaded', function() {
// // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
// // The Firebase SDK is initialized and available here!
//
// firebase.auth().onAuthStateChanged(user => { });
// firebase.database().ref('/path/to/ref').on('value', snapshot => { });
// firebase.messaging().requestPermission().then(() => { });
// firebase.storage().ref('/path/to/ref').getDownloadURL().then(() => { });
//
// // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥

try {
let app = firebase.app();
let features = ['auth', 'database', 'messaging', 'storage'].filter(feature => typeof app[feature] === 'function');
document.getElementById('load').innerHTML = `Firebase SDK loaded with ${features.join(', ')}`;
} catch (e) {
console.error(e);
document.getElementById('load').innerHTML = 'Error loading the Firebase SDK, check the console.';
}
});
</script>
</body>
</html>
4 changes: 4 additions & 0 deletions client/src/components/Auth/Signout.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { GoogleLogout } from "react-google-login";
import { withStyles } from "@material-ui/core/styles";
import ExitToAppIcon from "@material-ui/icons/ExitToApp";
import Typography from "@material-ui/core/Typography";
import { unstable_useMediaQuery as useMediaQuery } from "@material-ui/core/useMediaQuery";


import Context from '../../context'

const Signout = ({ classes }) => {
const mobileSize = useMediaQuery("(max-width: 650px)");
const { dispatch } = useContext(Context)

const onSingout =()=> {
Expand All @@ -22,6 +25,7 @@ const Signout = ({ classes }) => {
render={({onClick})=> (
<span className={classes.root} onClick={onClick}>
<Typography
style={{ display: mobileSize ? "none" : "block" }}
variant="body1"
className={classes.buttonText}
>
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/Blog.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React, { useContext } from "react";
import { withStyles } from "@material-ui/core/styles";
import { Paper } from "@material-ui/core";
import { unstable_useMediaQuery as useMediaQuery } from "@material-ui/core/useMediaQuery";


import Context from '../context'
import NoContent from './Pin/NoContent'
import CreatePin from './Pin/CreatePin'
import PinContent from './Pin/PinContent'

const Blog = ({ classes }) => {
const mobileSize = useMediaQuery("(max-width: 650px)");
const { state } = useContext(Context)
const { draft, currentPin } = state

Expand All @@ -21,7 +24,7 @@ const Blog = ({ classes }) => {
}

return (
<Paper className={classes.root}>
<Paper className={mobileSize ? classes.rootMobile : classes.root}>
<BlogContent/>

</Paper>
Expand Down
16 changes: 14 additions & 2 deletions client/src/components/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import differenceInMinutes from "date-fns/difference_in_minutes";
import Button from "@material-ui/core/Button";
import Typography from "@material-ui/core/Typography";
import DeleteIcon from "@material-ui/icons/DeleteTwoTone";
import { unstable_useMediaQuery as useMediaQuery } from "@material-ui/core/useMediaQuery";

import { Subscription } from "react-apollo";

Expand All @@ -28,6 +29,7 @@ const INITIAL_VIEWPORT = {

const Map = ({ classes }) => {
const client = useClient();
const mobileSize = useMediaQuery("(max-width: 650px)");
const { state, dispatch } = useContext(Context);
useEffect(() => {
getPins();
Expand All @@ -39,6 +41,15 @@ const Map = ({ classes }) => {
}, []);
const [popup, setPopup] = useState(null);

// remove popup if pin itself is deleted by the author of the pin
useEffect(() => {
const pinExists =
popup && state.pins.findIndex(pin => pin._id === popup._id) > -1;
if (!pinExists) {
setPopup(null);
}
}, [state.pins.length]);

//latitude, longitude широта Долгота
const getUserPosition =()=> {
if("geolocation" in navigator) {
Expand Down Expand Up @@ -87,12 +98,13 @@ const Map = ({ classes }) => {
};

return (
<div className={classes.root}>
<ReactMapGL
<div className={mobileSize ? classes.rootMobile : classes.root}>
<ReactMapGL
width="100vw"
height="calc(100vh - 64px)"
mapStyle="mapbox://styles/mapbox/streets-v9"
mapboxApiAccessToken="pk.eyJ1IjoiZGltYXNlcmJlbnl1ayIsImEiOiJjankwbHp2MHUwMXYwM25vMTg4Y2d5aTk4In0.aLzhYd_0w-uMpWzuJN7Jag"
scrollZoom={!mobileSize}
onViewportChange={newViewport => setViewport
(newViewport)}
onClick={handleMapClick}
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/Pin/CreatePin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import AddAPhotoIcon from "@material-ui/icons/AddAPhotoTwoTone";
import LandscapeIcon from "@material-ui/icons/LandscapeOutlined";
import ClearIcon from "@material-ui/icons/Clear";
import SaveIcon from "@material-ui/icons/SaveTwoTone";
import { unstable_useMediaQuery as useMediaQuery } from "@material-ui/core/useMediaQuery";



import Context from "../../context";
import { useClient } from '../../client'
import { CREATE_PIN_MUTATION } from "../../graphql/mutations";

const CreatePin = ({ classes }) => {
const mobileSize = useMediaQuery("(max-width: 650px)");
const client = useClient()
const { state, dispatch } = useContext(Context);
const [title, setTitle] = useState("");
Expand Down Expand Up @@ -100,7 +103,7 @@ const { state, dispatch } = useContext(Context);
name="content"
lable="Content"
multiline
rows="6"
rows={mobileSize ? "3" : "6"}
margin='normal'
fullWidth
variant="outlined"
Expand Down
16 changes: 16 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
3 changes: 3 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ mongoose
const server = new ApolloServer({
typeDefs,
resolvers,
introspection: true,
playground: true,
cors: true,
context: async ({ req }) => {
let authToken = null;
let currentUser = null;
Expand Down

0 comments on commit 92232a0

Please sign in to comment.