Преглед изворни кода

still teaking endpoints | created resizable hero | created hero global state

tags/0.9.0
J пре 6 година
родитељ
комит
70d27e60dd

+ 1
- 0
plugins/cia-endpoints/includes/class.make-endpoint.php Прегледај датотеку

@@ -62,6 +62,7 @@ class Make_Endpoint_For extends WP_REST_Controller {
62 62
         $filtered[blocks] = get_rearrange_blocks($item->blocks);
63 63
         
64 64
         return $filtered;
65
+        // return $item;
65 66
     }
66 67
 }
67 68
 

+ 3
- 1
vue-theme/src/app.vue Прегледај датотеку

@@ -1,6 +1,7 @@
1 1
 <template lang="pug">
2 2
 div#theme.f-col
3 3
     cia-nav
4
+    cia-hero
4 5
     main
5 6
         router-view
6 7
     cia-footer
@@ -8,6 +9,7 @@ div#theme.f-col
8 9
 
9 10
 <script>
10 11
 import navigation from '@/widgets/navigation/navigation'
12
+import hero from '@/components/hero'
11 13
 import footer from '@/components/footer'
12 14
 
13 15
 import '@/sss'
@@ -15,6 +17,7 @@ import '@/sss'
15 17
 export default {
16 18
     components: {
17 19
         'cia-nav': navigation,
20
+        'cia-hero': hero,
18 21
         'cia-footer': footer,
19 22
     }
20 23
 }
@@ -35,7 +38,6 @@ html > body
35 38
     nav, footer
36 39
         &.main
37 40
             background-color: #ccc
38
-            margin: 0 0 $ms
39 41
             padding: $ms
40 42
             width: 100%
41 43
             ul > li

+ 41
- 5
vue-theme/src/components/hero.vue Прегледај датотеку

@@ -1,11 +1,47 @@
1 1
 <template lang="pug">
2
-.hero
3
-    h3 hero
2
+.hero.f-col(v-if="showHero")
3
+    h3(v-if="heroText") {{ heroText }}
4
+    button(v-if="showPlaybutton") play
4 5
 </template>
5 6
 
7
+<script>
8
+import { mapState } from 'vuex'
9
+
10
+export default {
11
+    data() {
12
+        return {
13
+            heroHeight: 0
14
+        }
15
+    },
16
+    computed: mapState({
17
+        showHero: state => state.hero.url,
18
+        heroText: state => state.hero.text,
19
+        showPlaybutton: state => state.hero.playbutton,
20
+    }),
21
+    methods: {
22
+        onResize() {
23
+            this.heroHeight = this.$el.offsetWidth / 2.33
24
+        }
25
+    },
26
+    mounted() {
27
+        this.heroHeight = this.$el.offsetWidth / 2.33
28
+        this.$nextTick(() => { window.addEventListener('resize', this.onResize) })
29
+    },
30
+    watch: {
31
+        heroHeight() {
32
+            Object.assign(this.$el.style, {height: this.heroHeight + 'px'})
33
+        }
34
+    },
35
+    beforeDestroy() {
36
+        window.removeEventListener('resize', this.onResize)
37
+    },
38
+    
39
+}
40
+</script>
41
+
6 42
 <style lang="postcss">
7 43
 .hero
8
-    background-color: rebecca-purple
9
-    padding: 1em
10
-    width: 100vw
44
+    background-color: rebeccapurple
45
+    min-height: 30%
46
+    width: 100%
11 47
 </style>

+ 3
- 3
vue-theme/src/pages/index.vue Прегледај датотеку

@@ -3,14 +3,14 @@ article.page--index
3 3
     h1 {{ site }}: index
4 4
     section(v-if="allPagesLoaded")
5 5
         h4 pages
6
-        p {{ allPages.length }}
6
+        p {{ Object.values(allPages).length }}
7 7
     section(v-if="allPostsLoaded")
8 8
         h4 posts
9
-        p {{ allPosts.length }}
9
+        p {{ Object.values(allPosts).length }}
10 10
         hr
11 11
         div(v-for="post in allPosts")
12 12
             h4 {{ post.slug }}
13
-            p(v-for="block in post.blocks" v-html="block")
13
+            div(v-for="block in post.blocks" v-html="block")
14 14
 </template>
15 15
 
16 16
 <script>

+ 12
- 0
vue-theme/src/store/index.js Прегледај датотеку

@@ -12,9 +12,21 @@ Vue.use(Vuex)
12 12
 
13 13
 const debug = process.env.NODE_ENV !== 'production'
14 14
 
15
+// Current page state
16
+const state = {
17
+  title: 'Test',
18
+  hero: {
19
+    url: 'http://sample-image-url/',
20
+    text: 'sample hero text',
21
+    playbutton: true
22
+  },
23
+  view: 'list'
24
+}
25
+
15 26
 export default new Vuex.Store({
16 27
   actions,
17 28
   getters,
29
+  state,
18 30
   modules: {
19 31
       post,
20 32
       page,

+ 1
- 1
vue-theme/src/store/modules/page.js Прегледај датотеку

@@ -9,7 +9,7 @@ const state = {
9 9
 
10 10
 // getters
11 11
 const getters = {
12
-    allPages: state => Object.values((state.all)),
12
+    allPages: state => state.all,
13 13
     allPagesLoaded: state => state.loaded,
14 14
     page: state => id => {
15 15
         let field = typeof id === 'number' ? 'id' : 'slug'

+ 1
- 10
vue-theme/src/store/modules/post.js Прегледај датотеку

@@ -1,11 +1,5 @@
1 1
 import api from '../../utils/api'
2 2
 
3
-const createPostSlug = post => {
4
-    // let slug = post.link.replace(window.location.protocol + '//' + window.location.host, '')
5
-    // post.slug = slug
6
-    return post
7
-}
8
-
9 3
 const state = {
10 4
     all: {},
11 5
     loaded: false,
@@ -13,7 +7,7 @@ const state = {
13 7
 }
14 8
 
15 9
 const getters = {
16
-    allPosts: state => Object.values(state.all),
10
+    allPosts: state => state.all,
17 11
     allPostsLoaded: state => state.loaded,
18 12
     post: state => id => {
19 13
         let field = typeof id === 'number' ? 'id' : 'slug'
@@ -38,9 +32,6 @@ const getters = {
38 32
 const actions = {
39 33
     getAllPosts({ commit }) {
40 34
         api.getByType('posts', posts => {
41
-            Object.values(posts).map((post, i) => {
42
-                posts[i] = createPostSlug(post)
43
-            })
44 35
             commit('STORE_FETCHED_POSTS', { posts })
45 36
             commit('POSTS_LOADED', true)
46 37
         })

Loading…
Откажи
Сачувај