Kaynağa Gözat

:sparkles: creating rudimentary card component

tags/0.0.1
J 5 yıl önce
ebeveyn
işleme
334cc4e205

+ 1
- 2621
package-lock.json
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 29
- 2
src/App.vue Dosyayı Görüntüle

@@ -1,10 +1,37 @@
1 1
 <template lang="pug">
2
-img(alt="Vue logo" src="./assets/logo.png")
2
+.cards.f-row
3
+    card(v-for="card in cards" :card="card" @remove="remove")
3 4
 hello-world(msg="Hello Vue 3 + Vite")
4 5
 </template>
5 6
 
6
-<script setup>
7
+<script>
8
+import { ref } from 'vue'
9
+
7 10
 import helloWorld from '@/components/HelloWorld.vue'
11
+import card from '@/components/card.vue'
12
+
13
+export default {
14
+    components: { card, helloWorld },
15
+    setup() {
16
+    
17
+        const cards = ref([
18
+            { name: 'jwick' },
19
+            { name: 'hwick' },
20
+            { name: 'kwick' },
21
+        ])
22
+
23
+        const remove = card => {
24
+            const i = cards.value.indexOf(card)
25
+            cards.value.splice(i, 1)
26
+            console.log(cards.value)
27
+        }
28
+
29
+        return { 
30
+            cards,
31
+            remove
32
+        }
33
+    }
34
+}
8 35
 </script>
9 36
 
10 37
 <style lang="postcss">

+ 1
- 1
src/components/HelloWorld.vue Dosyayı Görüntüle

@@ -40,7 +40,7 @@ api.removeAll()
40 40
 api.put(state.profile).then(p => {
41 41
     state.loaded = true
42 42
     console.log(p)
43
-    api.sync()
43
+    // api.sync()
44 44
 })
45 45
 </script>
46 46
 

+ 60
- 0
src/components/card.vue Dosyayı Görüntüle

@@ -0,0 +1,60 @@
1
+<template lang="pug">
2
+.card
3
+    header
4
+        p {{ card.name }}
5
+
6
+    main
7
+        section
8
+            img(alt="Vue logo" style="width: 100%;" src="@/assets/logo.png")
9
+
10
+    footer
11
+        button(@click="state.count++") {{ state.count }}
12
+        button(@click="close") close
13
+
14
+</template>
15
+
16
+<script setup>
17
+import { defineProps, reactive, getCurrentInstance } from 'vue'
18
+
19
+const instance = getCurrentInstance()
20
+
21
+const props = defineProps({
22
+    msg: String,
23
+    card: Object
24
+})
25
+
26
+const state = reactive({
27
+    count: 0,
28
+    loaded: false,
29
+    profile: null
30
+})
31
+
32
+const close = e => {
33
+    instance.emit('remove', props.card)
34
+}
35
+
36
+</script>
37
+
38
+<style lang="postcss">
39
+
40
+$pad: 0.5vw
41
+
42
+.card
43
+    background-color: rebeccapurple
44
+    opacity: 0.8
45
+    width: calc($pad * 20)
46
+    height: calc($pad * 40)
47
+    border-radius: $pad
48
+    margin-bottom: -5vh
49
+    display: flex
50
+    border: 1px solid black
51
+    flex-direction: column
52
+    header, main, footer
53
+        text-align: left
54
+        padding: 0 $pad
55
+    header
56
+        padding-top: $pad
57
+    footer
58
+        padding-bottom: $pad
59
+
60
+</style>

+ 5
- 5
src/sss/index.js Dosyayı Görüntüle

@@ -1,9 +1,9 @@
1
-import './partials/_reset.sss'
2
-import './partials/_helpers.sss'
3
-import './partials/_typography.sss'
1
+import '@/sss/partials/_helpers.sss'
2
+import '@/sss/partials/_typography.sss'
3
+import '@/sss/partials/_reset.sss'
4 4
 
5
-import layoutVars from './variables.sss'
6
-import themeVars from './theme.sss'
5
+import layoutVars from '@/sss/variables.sss'
6
+import themeVars from '@/sss/theme.sss'
7 7
 
8 8
 const splitVars = varsFromSSS => {
9 9
     return varsFromSSS.split('\n').map(line => line.split(':')).reduce((vars, pair) => {

+ 2
- 5
src/sss/partials/_reset.sss Dosyayı Görüntüle

@@ -1,5 +1,3 @@
1
-@import '../variables.sss'
2
-@import '../theme.sss'
3 1
 
4 2
 *
5 3
     margin: 0
@@ -18,13 +16,12 @@
18 16
 html
19 17
     cursor: default
20 18
     font-family: system-ui
21
-    line-height: $ms-0
19
+    line-height: 1vh
22 20
     tab-size: 4
23 21
 
24 22
 body
25 23
     margin: 0
26
-    font-size: $ms-1
27
-    font-family: $sans
24
+    font-size: 1em
28 25
 
29 26
 nav
30 27
     ol, ul

+ 2
- 2
src/sss/partials/_typography.sss Dosyayı Görüntüle

@@ -1,5 +1,5 @@
1
-@import '../variables.sss'
2
-@import '../theme.sss'
1
+import '../variables.sss'
2
+import '../theme.sss'
3 3
 
4 4
 h1
5 5
     font-size: $ms-5

Loading…
İptal
Kaydet