Skip to content

Commit

Permalink
feat: add chakra-ui-vue (#573)
Browse files Browse the repository at this point in the history

Co-authored-by: Clark Du <[email protected]>
  • Loading branch information
Easybuoy and clarkdo committed Jul 27, 2020
1 parent 417e964 commit c9ede63
Show file tree
Hide file tree
Showing 8 changed files with 321 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ yarn create nuxt-app <my-project>
- [Bootstrap](https://github.com/bootstrap-vue/bootstrap-vue)
- [Buefy](https://buefy.org)
- [Bulma](https://github.com/jgthms/bulma)
- [Chakra UI](https://github.com/chakra-ui/chakra-ui-vue)
- [Element](https://github.com/ElemeFE/element)
- [Framevuerk](https://github.com/framevuerk/framevuerk)
- [iView](https://www.iviewui.com/)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<div class="container">
<CThemeProvider>
<CColorModeProvider>
<CBox font-family="body" as="main">
<CReset />
<Nuxt />
</CBox>
</CColorModeProvider>
</CThemeProvider>
</div>
</template>
<script>
import {
CThemeProvider,
CColorModeProvider,
CReset,
CBox
} from '@chakra-ui/vue'
export default {
name: 'App',
components: {
CThemeProvider,
CColorModeProvider,
CReset,
CBox
}
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"@chakra-ui/nuxt": "^0.0.7",
"@nuxtjs/emotion": "^0.0.1"
}
}
168 changes: 168 additions & 0 deletions packages/cna-template/template/frameworks/chakra-ui/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<template>
<div class="container">
<CBox
v-bind="mainStyles[colorMode]"
d="flex"
w="100vw"
h="100vh"
flex-dir="column"
justify-content="center"
>
<CHeading text-align="center" mb="4">
⚡️ Hello chakra-ui/vue
</CHeading>
<CFlex justify="center" direction="column" align="center">
<CBox mb="3">
<CIconButton
mr="3"
:icon="colorMode === 'light' ? 'moon' : 'sun'"
:aria-label="`Switch to ${
colorMode === 'light' ? 'dark' : 'light'
} mode`"
@click="toggleColorMode"
/>
<CButton
left-icon="info"
variant-color="blue"
@click="showToast"
>
Show Toast
</CButton>
</CBox>
<CAvatarGroup>
<CAvatar
name="Evan You"
alt="Evan You"
src="https://pbs.twimg.com/profile_images/1206997998900850688/cTXTQiHm_400x400.jpg"
>
<CAvatarBadge size="1.0em" bg="green.500" />
</CAvatar>
<CAvatar
name="Jonathan Bakebwa"
alt="Jonathan Bakebwa"
src="https://res.cloudinary.com/xtellar/image/upload/v1572857445/me_zqos4e.jpg"
>
<CAvatarBadge size="1.0em" bg="green.500" />
</CAvatar>
<CAvatar
name="Segun Adebayo"
alt="Segun Adebayo"
src="https://pbs.twimg.com/profile_images/1169353373012897802/skPUWd6e_400x400.jpg"
>
<CAvatarBadge size="1.0em" bg="green.500" />
</CAvatar>
<CAvatar src="pop">
<CAvatarBadge size="1.0em" border-color="papayawhip" bg="tomato" />
</CAvatar>
</CAvatarGroup>
<CButton
left-icon="close"
variant-color="red"
mt="3"
@click="showModal = true"
>
Delete Account
</CButton>
<CModal :is-open="showModal">
<CModalOverlay />
<CModalContent>
<CModalHeader>Are you sure?</CModalHeader>
<CModalBody>Deleting user cannot be undone</CModalBody>
<CModalFooter>
<CButton @click="showModal = false">
Cancel
</CButton>
<CButton
margin-left="3"
variant-color="red"
@click="showModal = false"
>
Delete User
</CButton>
</CModalFooter>
<CModalCloseButton @click="showModal = false" />
</CModalContent>
</CModal>
</CFlex>
</CBox>
</div>
</template>

<script lang="js">
import {
CBox,
CButton,
CAvatarGroup,
CAvatar,
CAvatarBadge,
CModal,
CModalContent,
CModalOverlay,
CModalHeader,
CModalFooter,
CModalBody,
CModalCloseButton,
CIconButton,
CFlex,
CHeading
} from '@chakra-ui/vue'
export default {
name: 'App',
inject: ['$chakraColorMode', '$toggleColorMode'],
components: {
CBox,
CButton,
CAvatarGroup,
CAvatar,
CAvatarBadge,
CModal,
CModalContent,
CModalOverlay,
CModalHeader,
CModalFooter,
CModalBody,
CModalCloseButton,
CIconButton,
CFlex,
CHeading
},
data () {
return {
showModal: false,
mainStyles: {
dark: {
bg: 'gray.700',
color: 'whiteAlpha.900'
},
light: {
bg: 'white',
color: 'gray.900'
}
}
}
},
computed: {
colorMode () {
return this.$chakraColorMode()
},
theme () {
return this.$chakraTheme()
},
toggleColorMode () {
return this.$toggleColorMode
}
},
methods: {
showToast () {
this.$toast({
title: 'Account created.',
description: "We've created your account for you.",
status: 'success',
duration: 10000,
isClosable: true
})
}
}
}
</script>
5 changes: 5 additions & 0 deletions packages/cna-template/template/nuxt/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ export default {
<%_ } else if (ui === 'buefy') { _%>
// Doc: https://buefy.github.io/#/documentation
'nuxt-buefy',
<%_ } else if (ui === 'chakra-ui') { _%>
// Doc: https://github.com/chakra-ui/chakra-ui-vue/tree/develop/packages/nuxt-chakra
// Doc: https://github.com/nuxt-community/emotion-module#readme
'@chakra-ui/nuxt',
'@nuxtjs/emotion',
<%_ } _%>
<%_ if (axios) { _%>
// Doc: https://axios.nuxtjs.org/usage
Expand Down
1 change: 1 addition & 0 deletions packages/create-nuxt-app/lib/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = [
{ name: 'Bootstrap Vue', value: 'bootstrap' },
{ name: 'Buefy', value: 'buefy' },
{ name: 'Bulma', value: 'bulma' },
{ name: 'Chakra UI', value: 'chakra-ui' },
{ name: 'Element', value: 'element-ui' },
{ name: 'Framevuerk', value: 'framevuerk' },
{ name: 'iView', value: 'iview' },
Expand Down
110 changes: 110 additions & 0 deletions packages/create-nuxt-app/test/snapshots/index.test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -3194,6 +3194,116 @@ Generated by [AVA](https://avajs.dev).
}␊
`

## verify ui: Chakra UI

> Generated files
[
'.editorconfig',
'.gitignore',
'README.md',
'assets/README.md',
'components/Logo.vue',
'components/README.md',
'layouts/README.md',
'layouts/default.vue',
'middleware/README.md',
'nuxt.config.js',
'package.json',
'pages/README.md',
'pages/index.vue',
'plugins/README.md',
'static/README.md',
'static/favicon.ico',
'store/README.md',
]

> package.json
{
dependencies: {
'@chakra-ui/nuxt': '^0.0.7',
'@nuxtjs/emotion': '^0.0.1',
nuxt: '^2.14.0',
},
devDependencies: {},
private: true,
scripts: {
build: 'nuxt build',
dev: 'nuxt',
generate: 'nuxt generate',
start: 'nuxt start',
},
}

> Generated nuxt.config.js
`␊
export default {␊
/*␊
** Nuxt rendering mode␊
** See https://nuxtjs.org/api/configuration-mode␊
*/␊
mode: 'universal',␊
/*␊
** Nuxt target␊
** See https://nuxtjs.org/api/configuration-target␊
*/␊
target: 'server',␊
/*␊
** Headers of the page␊
** See https://nuxtjs.org/api/configuration-head␊
*/␊
head: {␊
title: process.env.npm_package_name || '',␊
meta: [␊
{ charset: 'utf-8' },␊
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },␊
{ hid: 'description', name: 'description', content: process.env.npm_package_description || '' }␊
],␊
link: [␊
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }␊
]␊
},␊
/*␊
** Global CSS␊
*/␊
css: [␊
],␊
/*␊
** Plugins to load before mounting the App␊
** https://nuxtjs.org/guide/plugins␊
*/␊
plugins: [␊
],␊
/*␊
** Auto import components␊
** See https://nuxtjs.org/api/configuration-components␊
*/␊
components: true,␊
/*␊
** Nuxt.js dev-modules␊
*/␊
buildModules: [␊
],␊
/*␊
** Nuxt.js modules␊
*/␊
modules: [␊
// Doc: https://github.com/chakra-ui/chakra-ui-vue/tree/develop/packages/nuxt-chakra␊
// Doc: https://github.com/nuxt-community/emotion-module#readme␊
'@chakra-ui/nuxt',␊
'@nuxtjs/emotion',␊
],␊
/*␊
** Build configuration␊
** See https://nuxtjs.org/api/configuration-build/␊
*/␊
build: {␊
}␊
}␊
`

## verify ui: Element

> Generated files
Expand Down
Binary file modified packages/create-nuxt-app/test/snapshots/index.test.js.snap
Binary file not shown.

0 comments on commit c9ede63

Please sign in to comment.