|
| 1 | +<template> |
| 2 | + <div class="container"> |
| 3 | + <CBox |
| 4 | + v-bind="mainStyles[colorMode]" |
| 5 | + d="flex" |
| 6 | + w="100vw" |
| 7 | + h="100vh" |
| 8 | + flex-dir="column" |
| 9 | + justify-content="center" |
| 10 | + > |
| 11 | + <CHeading text-align="center" mb="4"> |
| 12 | + ⚡️ Hello chakra-ui/vue |
| 13 | + </CHeading> |
| 14 | + <CFlex justify="center" direction="column" align="center"> |
| 15 | + <CBox mb="3"> |
| 16 | + <CIconButton |
| 17 | + mr="3" |
| 18 | + :icon="colorMode === 'light' ? 'moon' : 'sun'" |
| 19 | + :aria-label="`Switch to ${ |
| 20 | + colorMode === 'light' ? 'dark' : 'light' |
| 21 | + } mode`" |
| 22 | + @click="toggleColorMode" |
| 23 | + /> |
| 24 | + <CButton |
| 25 | + left-icon="info" |
| 26 | + variant-color="blue" |
| 27 | + @click="showToast" |
| 28 | + > |
| 29 | + Show Toast |
| 30 | + </CButton> |
| 31 | + </CBox> |
| 32 | + <CAvatarGroup> |
| 33 | + <CAvatar |
| 34 | + name="Evan You" |
| 35 | + alt="Evan You" |
| 36 | + src="https://pbs.twimg.com/profile_images/1206997998900850688/cTXTQiHm_400x400.jpg" |
| 37 | + > |
| 38 | + <CAvatarBadge size="1.0em" bg="green.500" /> |
| 39 | + </CAvatar> |
| 40 | + <CAvatar |
| 41 | + name="Jonathan Bakebwa" |
| 42 | + alt="Jonathan Bakebwa" |
| 43 | + src="https://res.cloudinary.com/xtellar/image/upload/v1572857445/me_zqos4e.jpg" |
| 44 | + > |
| 45 | + <CAvatarBadge size="1.0em" bg="green.500" /> |
| 46 | + </CAvatar> |
| 47 | + <CAvatar |
| 48 | + name="Segun Adebayo" |
| 49 | + alt="Segun Adebayo" |
| 50 | + src="https://pbs.twimg.com/profile_images/1169353373012897802/skPUWd6e_400x400.jpg" |
| 51 | + > |
| 52 | + <CAvatarBadge size="1.0em" bg="green.500" /> |
| 53 | + </CAvatar> |
| 54 | + <CAvatar src="pop"> |
| 55 | + <CAvatarBadge size="1.0em" border-color="papayawhip" bg="tomato" /> |
| 56 | + </CAvatar> |
| 57 | + </CAvatarGroup> |
| 58 | + <CButton |
| 59 | + left-icon="close" |
| 60 | + variant-color="red" |
| 61 | + mt="3" |
| 62 | + @click="showModal = true" |
| 63 | + > |
| 64 | + Delete Account |
| 65 | + </CButton> |
| 66 | + <CModal :is-open="showModal"> |
| 67 | + <CModalOverlay /> |
| 68 | + <CModalContent> |
| 69 | + <CModalHeader>Are you sure?</CModalHeader> |
| 70 | + <CModalBody>Deleting user cannot be undone</CModalBody> |
| 71 | + <CModalFooter> |
| 72 | + <CButton @click="showModal = false"> |
| 73 | + Cancel |
| 74 | + </CButton> |
| 75 | + <CButton |
| 76 | + margin-left="3" |
| 77 | + variant-color="red" |
| 78 | + @click="showModal = false" |
| 79 | + > |
| 80 | + Delete User |
| 81 | + </CButton> |
| 82 | + </CModalFooter> |
| 83 | + <CModalCloseButton @click="showModal = false" /> |
| 84 | + </CModalContent> |
| 85 | + </CModal> |
| 86 | + </CFlex> |
| 87 | + </CBox> |
| 88 | + </div> |
| 89 | +</template> |
| 90 | + |
| 91 | +<script lang="js"> |
| 92 | +import { |
| 93 | + CBox, |
| 94 | + CButton, |
| 95 | + CAvatarGroup, |
| 96 | + CAvatar, |
| 97 | + CAvatarBadge, |
| 98 | + CModal, |
| 99 | + CModalContent, |
| 100 | + CModalOverlay, |
| 101 | + CModalHeader, |
| 102 | + CModalFooter, |
| 103 | + CModalBody, |
| 104 | + CModalCloseButton, |
| 105 | + CIconButton, |
| 106 | + CFlex, |
| 107 | + CHeading |
| 108 | +} from '@chakra-ui/vue' |
| 109 | +
|
| 110 | +export default { |
| 111 | + name: 'App', |
| 112 | + inject: ['$chakraColorMode', '$toggleColorMode'], |
| 113 | + components: { |
| 114 | + CBox, |
| 115 | + CButton, |
| 116 | + CAvatarGroup, |
| 117 | + CAvatar, |
| 118 | + CAvatarBadge, |
| 119 | + CModal, |
| 120 | + CModalContent, |
| 121 | + CModalOverlay, |
| 122 | + CModalHeader, |
| 123 | + CModalFooter, |
| 124 | + CModalBody, |
| 125 | + CModalCloseButton, |
| 126 | + CIconButton, |
| 127 | + CFlex, |
| 128 | + CHeading |
| 129 | + }, |
| 130 | + data () { |
| 131 | + return { |
| 132 | + showModal: false, |
| 133 | + mainStyles: { |
| 134 | + dark: { |
| 135 | + bg: 'gray.700', |
| 136 | + color: 'whiteAlpha.900' |
| 137 | + }, |
| 138 | + light: { |
| 139 | + bg: 'white', |
| 140 | + color: 'gray.900' |
| 141 | + } |
| 142 | + } |
| 143 | + } |
| 144 | + }, |
| 145 | + computed: { |
| 146 | + colorMode () { |
| 147 | + return this.$chakraColorMode() |
| 148 | + }, |
| 149 | + theme () { |
| 150 | + return this.$chakraTheme() |
| 151 | + }, |
| 152 | + toggleColorMode () { |
| 153 | + return this.$toggleColorMode |
| 154 | + } |
| 155 | + }, |
| 156 | + methods: { |
| 157 | + showToast () { |
| 158 | + this.$toast({ |
| 159 | + title: 'Account created.', |
| 160 | + description: "We've created your account for you.", |
| 161 | + status: 'success', |
| 162 | + duration: 10000, |
| 163 | + isClosable: true |
| 164 | + }) |
| 165 | + } |
| 166 | + } |
| 167 | +} |
| 168 | +</script> |
0 commit comments