Skip to content

Commit

Permalink
Updade
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyzen committed Sep 28, 2021
1 parent 01bd308 commit 8a08c37
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 313 deletions.
78 changes: 39 additions & 39 deletions components/Cart.vue
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
<template>
<section v-if="!$apollo.loading" class="fixed top-0 right-0 h-screen p-12 bg-white shadow-lg w-96">
<CloseCart />
<pre class="text-xs" v-if="cart">{{ cart }}</pre>
<pre class="text-xs" v-if="viewer">{{ viewer }}</pre>
<button @click="getUser">Get User</button>
</section>
<section v-if="!$apollo.loading" class="fixed top-0 right-0 h-screen p-12 bg-white shadow-lg w-96">
<CloseCart />
<pre class="text-xs" v-if="cart">{{ cart }}</pre>
<pre class="text-xs" v-if="viewer">{{ viewer }}</pre>
<button @click="getUser">Get User</button>
</section>
</template>

<script>
import { gql } from "nuxt-graphql-request";
import getCart from "~/gql/queries/getCart";
import { gql } from 'nuxt-graphql-request'
import getCart from '~/gql/queries/getCart'
const requestHeaders = {
"Content-Type": "application/json",
Accept: "application/json",
};
'Content-Type': 'application/json',
Accept: 'application/json'
}
export default {
data() {
return {
cart: null,
viewer: null,
};
},
async fetch() {
const cart = await this.$graphql.default.request(getCart);
this.cart = cart;
},
methods: {
async getUser() {
const query = gql`
query {
viewer {
email
firstName
}
}
`;
data() {
return {
cart: null,
viewer: null
}
},
async fetch() {
const cart = await this.$graphql.default.request(getCart)
this.cart = cart
},
methods: {
async getUser() {
const query = gql`
query {
viewer {
email
firstName
}
}
`
const data = await this.$graphql.default.rawRequest(query);
const cart = await this.$graphql.default.request(getCart);
this.cart = cart;
this.viewer = data.data.viewer;
console.log(data);
},
},
};
const data = await this.$graphql.default.rawRequest(query)
const cart = await this.$graphql.default.request(getCart)
this.cart = cart
this.viewer = data.data.viewer
console.log(data)
}
}
}
</script>
90 changes: 50 additions & 40 deletions layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,66 +1,76 @@
<template>
<div>
<div class="text-xs text-white bg-gray-600">
<div class="container flex justify-between py-1.5">
<div>NEXT DAY DELIVERY</div>
<nuxt-link to="/login" v-if="!this.$auth.loggedIn"> LOGIN / SIGN UP </nuxt-link>
<div @click="logOut" v-else>LOGOUT</div>
</div>
</div>
<Header />
<transition name="slide">
<Cart v-if="showCart" class="z-50" />
</transition>
<transition name="page" mode="out-in">
<Nuxt />
</transition>
<transition name="page">
<div v-if="showCart" class="fixed inset-0 bg-black opacity-25" @click="closeCart"></div>
</transition>
<Footer />
</div>
<div>
<div class="text-xs text-white bg-gray-600">
<div class="container flex justify-between py-1.5">
<div>NEXT DAY DELIVERY</div>
<nuxt-link to="/login" v-if="!this.$auth.loggedIn"> LOGIN / SIGN UP </nuxt-link>
<div @click="logOut" v-else>LOGOUT</div>
</div>
</div>
<Header />
<transition name="slide">
<Cart v-if="showCart" class="z-50" />
</transition>
<transition name="page" mode="out-in">
<Nuxt />
</transition>
<transition name="page">
<div v-if="showCart" class="fixed inset-0 bg-black opacity-25" @click="closeCart"></div>
</transition>
<Footer />
</div>
</template>

<script>
export default {
computed: {
showCart() {
return this.$store.state.showCart;
},
},
methods: {
closeCart() {
this.$store.commit("toggleCart", false);
},
async logOut() {
const data = await this.$auth.logout();
console.log(data);
},
},
};
computed: {
showCart() {
return this.$store.state.showCart
}
},
methods: {
closeCart() {
this.$store.commit('toggleCart', false)
},
async logOut() {
const data = await this.$auth.logout()
}
}
}
</script>

<style lang="postcss">
.page-enter-active,
.page-leave-active {
transition: opacity 300ms ease-in-out;
transition: opacity 300ms ease-in-out;
}
.page-enter,
.page-leave-active {
opacity: 0;
opacity: 0;
}
body {
@apply bg-gray-50;
@apply bg-gray-50;
}
/* Enter and leave animations can use different */
/* durations and timing functions. */
.slide-leave-active,
.slide-enter-active {
transition: transform 400ms ease-in-out;
transition: transform 400ms ease-in-out;
}
.slide-enter,
.slide-leave-to {
transform: translateX(500px);
transform: translateX(500px);
}
.big-button {
@apply rounded inline-flex justify-center items-center text-sm leading-tight uppercase py-3 font-semibold;
box-shadow: 0 2px 0 #025e47, inset 0 0 8px rgb(255 210 0 / 10%), inset 0 1px 0 #37ff91, inset 0 -1px 0 #06c465;
background: linear-gradient(to bottom, #37ff91 0%, #06c465 100%) no-repeat 0, linear-gradient(to bottom, #37ff91 0%, #06c465 100%) no-repeat 100%,
#06994f linear-gradient(to bottom, #25ca85 0%, #057a40 100%) no-repeat;
background-size: 1px 100%, 1px 100%, cover;
color: #f9f5e1;
text-shadow: 0 -1px rgb(0 71 0 / 30%);
min-width: 200px;
}
</style>
13 changes: 6 additions & 7 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
[headers.values]
Access-Control-Allow-Origin = "*"
Access-Control-Allow-Headers = "Content-Type"
# X-Frame-Options = "ALLOW-FROM https://testing.2cubedtest.com"
# X-XSS-Protection = "1; mode=block"
# Referrer-Policy = "no-referrer"
# X-Content-Type-Options = "nosniff"
# Strict-Transport-Security = "max-age=15780000; includeSubDomains; preload"
# Feature-Policy = "geolocation 'none'; midi 'none'; sync-xhr 'none'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; speaker 'none'; fullscreen 'none'; payment 'none'"
# Content-Security-Policy = "default-src * 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline'"
X-XSS-Protection = "1; mode=block"
Referrer-Policy = "no-referrer"
X-Content-Type-Options = "nosniff"
Strict-Transport-Security = "max-age=15780000; includeSubDomains; preload"
Feature-Policy = "geolocation 'none'; midi 'none'; sync-xhr 'none'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; speaker 'none'; fullscreen 'none'; payment 'none'"
Content-Security-Policy = "default-src * 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline'"


[[redirects]]
Expand Down
10 changes: 9 additions & 1 deletion nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
link: [{ rel: "icon", type: "image/x-icon", href: "/icon.svg" }],
},

modules: ["@nuxtjs/pwa", "@nuxtjs/axios", "@nuxtjs/auth-next"],
modules: ["@nuxtjs/pwa", "@nuxtjs/axios", "@nuxtjs/auth-next", '@nuxtjs/apollo'],
buildModules: ["@nuxtjs/tailwindcss", "@nuxt/image", "nuxt-graphql-request"],

graphql: {
Expand All @@ -30,6 +30,14 @@ export default {
},
},

apollo: {
clientConfigs: {
default:{
httpEndpoint: `${process.env.WORDPRESS_URL}/graphql`
}
}
},

auth: {
strategies: {
google: {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev:host": "nuxt --hostname '0' --port 8000",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate --modern",
"generate": "nuxt generate -m",
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint": "npm run lint:js"
},
Expand All @@ -18,7 +18,7 @@
"@nuxtjs/axios": "^5.13.6",
"@nuxtjs/pwa": "^3.3.5",
"@nuxtjs/tailwindcss": "^4.2.1",
"core-js": "^3.18.0",
"core-js": "^3.18.1",
"graphql-tag": "^2.12.5",
"nuxt": "^2.15.8"
},
Expand All @@ -34,7 +34,7 @@
"eslint-plugin-vue": "^7.18.0",
"graphql": "^15.6.0",
"nuxt-graphql-request": "^4.1.0",
"postcss": "^8.3.7",
"postcss": "^8.3.8",
"prettier": "^2.4.1"
}
}
1 change: 1 addition & 0 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<h1 class="mb-4 text-6xl font-bold">Just landed.</h1>
<div class="max-w-sm mb-12 font-light">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Unde nam dignissimos nostrum veritatis nisi autem accusantium modi? Enim, voluptatibus consectetur.</div>
<nuxt-link class="inline-block p-4 px-6 leading-none text-black bg-white rounded shadow-sm" to="/products">Shop New Arrivals</nuxt-link>
<!-- <nuxt-link class="big-button" to="/products">Shop New Arrivals</nuxt-link> -->
</div>
</section>
<section class="container my-32">
Expand Down
Loading

0 comments on commit 8a08c37

Please sign in to comment.