Pārlūkot izejas kodu

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

tags/0.9.0
J 6 gadus atpakaļ
vecāks
revīzija
70d27e60dd

+ 1
- 0
plugins/cia-endpoints/includes/class.make-endpoint.php Parādīt failu

62
         $filtered[blocks] = get_rearrange_blocks($item->blocks);
62
         $filtered[blocks] = get_rearrange_blocks($item->blocks);
63
         
63
         
64
         return $filtered;
64
         return $filtered;
65
+        // return $item;
65
     }
66
     }
66
 }
67
 }
67
 
68
 

+ 3
- 1
vue-theme/src/app.vue Parādīt failu

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

+ 41
- 5
vue-theme/src/components/hero.vue Parādīt failu

1
 <template lang="pug">
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
 </template>
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
 <style lang="postcss">
42
 <style lang="postcss">
7
 .hero
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
 </style>
47
 </style>

+ 3
- 3
vue-theme/src/pages/index.vue Parādīt failu

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

+ 12
- 0
vue-theme/src/store/index.js Parādīt failu

12
 
12
 
13
 const debug = process.env.NODE_ENV !== 'production'
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
 export default new Vuex.Store({
26
 export default new Vuex.Store({
16
   actions,
27
   actions,
17
   getters,
28
   getters,
29
+  state,
18
   modules: {
30
   modules: {
19
       post,
31
       post,
20
       page,
32
       page,

+ 1
- 1
vue-theme/src/store/modules/page.js Parādīt failu

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

+ 1
- 10
vue-theme/src/store/modules/post.js Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt