Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 1809857

Browse files
Merge pull request #30 from chakra-ui/docs/landing-page
chore: improve landing page
2 parents cd394c1 + 8ceb0c2 commit 1809857

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+8118
-126
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,5 @@ dist
9696
.pnp.*
9797

9898
# vscode history extension
99-
.history
99+
.history
100+
website/.vite-ssg-temp

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"johnsoncodehk.volar"
4+
]
5+
}

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"typescript.tsdk": "node_modules/typescript/lib"
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"volar.tsPlugin": true
34
}

docs/.vitepress/config.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module.exports = {
2727
sidebar: {
2828
'/setup/': getSetupSidebar(),
2929
'/components/': getSetupSidebar(),
30+
'/composables/': getSetupSidebar(),
3031
'/': getSetupSidebar()
3132
}
3233
}
@@ -52,6 +53,12 @@ function getSetupSidebar() {
5253
{ text: 'CSS reset', link: '/components/css-reset' },
5354
{ text: 'Visually hidden', link: '/components/visually-hidden' },
5455
]
56+
},
57+
{
58+
text: 'Composables',
59+
children: [
60+
{ text: 'usePopper', link: '/composables/use-popper' }
61+
]
5562
}
5663
]
5764
}
@@ -70,13 +77,5 @@ function getComponentsSidebar() {
7077
{ text: 'Visually hidden', link: '/components/visually-hidden' },
7178
]
7279
},
73-
// {
74-
// text: 'Theme',
75-
// children: [
76-
// { text: 'Homepage', link: '/config/homepage' },
77-
// { text: 'Algolia Search', link: '/config/algolia-search' },
78-
// { text: 'Carbon Ads', link: '/config/carbon-ads' }
79-
// ]
80-
// }
8180
]
8281
}

docs/composables/use-popper.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# usePopper
2+
3+
The **`usePopper`** hook is an internal hook for Chakra UI Vue used to encapsulate `@popperjs/core` into an extendable composable hook.
4+
5+
## Import
6+
7+
```bash
8+
import { usePopper } from "@chakra-ui/c-popper"
9+
```
10+
11+
This composable accepts options to modify the positioning fo the popover as well as the modifiers of the popper. It returns an object of properties that can be used to bind the template refs to the popper instance
12+
13+
## Usage
14+
15+
```vue
16+
<template>
17+
<chakra.div>
18+
<c-button :ref="reference" @click="toggleIsOpen">Testing</c-button>
19+
<div v-if="isOpen" :ref="popper" style="padding: 20px; background: red">
20+
<div
21+
data-popper-arrow=""
22+
style="--popper-arrow-size: 10px; background: yellow"
23+
/>
24+
Popper
25+
</div>
26+
</chakra.div>
27+
</template>
28+
29+
<script lang="ts">
30+
import { defineComponent } from 'vue'
31+
import { usePopper } from '@chakra-ui/c-popper'
32+
import { CButton } from '@chakra-ui/c-button'
33+
import { useToggle } from '@vueuse/core'
34+
35+
export default defineComponent({
36+
components: { CButton },
37+
setup() {
38+
const [isOpen, toggleIsOpen] = useToggle(true)
39+
40+
const { reference, popper } = usePopper({
41+
gutter: 16,
42+
placement: 'right-end',
43+
})
44+
45+
return {
46+
isOpen,
47+
toggleIsOpen,
48+
reference,
49+
popper,
50+
}
51+
},
52+
})
53+
</script>
54+
55+
```
56+
57+
## Props
58+
These are the options for the `usePopper` composable. These properties are similar to the options listed in the [@popperjs/core](https://popper.js.org/docs/v2/) documentation.
59+
```ts
60+
export interface UsePopperOptions {
61+
offset?: [x: number, y: number]
62+
gutter?: number
63+
preventOverflow?: boolean
64+
flip?: boolean
65+
matchWidth?: boolean
66+
boundary?: 'clippingParents' | 'scrollParent' | HTMLElement
67+
eventListeners?: boolean | { scroll?: boolean; resize?: boolean }
68+
arrowPadding?: number
69+
strategy?: 'absolute' | 'fixed'
70+
placement?: Placement
71+
modifiers?: Array<Modifier<any, any>>
72+
}
73+
```

jest.config.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = {
22
transform: {
3-
'^.+\\.(ts|tsx)$': 'ts-jest',
3+
'^.+\\.(ts|tsx|js|jsx)$': 'ts-jest/dist',
44
},
5-
transformIgnorePatterns: ['/node_modules/(?!lodash.)'],
5+
transformIgnorePatterns: ['/node_modules/(?!@popperjs/.*|lodash.)'],
66
moduleNameMapper: {
77
'^@/(.*)$': '<rootDir>/$1',
88
'@chakra-ui/vue-test-utils': '<rootDir>/packages/test-utils/src/index.ts',
@@ -11,10 +11,9 @@ module.exports = {
1111
'@chakra-ui/vue-test-utils/dist/cjs/snapshot-serializer.js',
1212
],
1313
testMatch: ['**/**/*.test.(js|jsx|ts|tsx)'],
14-
testEnvironmentOptions: { resources: 'usable' },
1514
globals: {
1615
'ts-jest': {
17-
babelConfig: 'babel.config.js',
16+
tsconfig: 'tsconfig.json',
1817
},
1918
},
2019
}

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"repository": "https://github.com/chakra-ui/chakra-ui-vue-next.git",
77
"author": "Jonathan Bakebwa codebender828@gmail.com",
88
"workspaces": [
9-
"packages/*"
9+
"packages/*",
10+
"website"
1011
],
1112
"scripts": {
1213
"postinstall": "yarn bootstrap",
@@ -20,6 +21,7 @@
2021
"docs:dev": "vitepress dev docs",
2122
"docs:build": "vitepress build docs",
2223
"docs:serve": "vitepress serve docs",
24+
"website": "yarn workspace @chakra-ui/vue-docs",
2325
"core": "yarn workspace @chakra-ui/vue-next",
2426
"nuxt": "yarn workspace @chakra-ui/nuxt-next",
2527
"system": "yarn workspace @chakra-ui/vue-system",
@@ -34,7 +36,8 @@
3436
"c-reset": "yarn workspace @chakra-ui/c-reset",
3537
"c-spinner": "yarn workspace @chakra-ui/c-spinner",
3638
"c-badge": "yarn workspace @chakra-ui/c-badge",
37-
"c-portal": "yarn workspace @chakra-ui/c-portal"
39+
"c-portal": "yarn workspace @chakra-ui/c-portal",
40+
"c-popper": "yarn workspace @chakra-ui/c-popper"
3841
},
3942
"license": "MIT",
4043
"private": true,
@@ -102,18 +105,22 @@
102105
"@chakra-ui/styled-system": "^1.4.1",
103106
"@emotion/css": "^11.1.3",
104107
"@emotion/server": "^11.0.0",
108+
"@popperjs/core": "^2.8.4",
105109
"@types/lodash.camelcase": "^4.3.6",
106110
"@types/lodash.kebabcase": "^4.1.6",
107111
"@types/lodash.mergewith": "^4.6.6",
108112
"@types/tinycolor2": "^1.4.2",
113+
"@vueuse/motion": "^1.4.4",
109114
"change-case": "^4.1.1",
110115
"css-get-unit": "^1.0.1",
111116
"csstype": "^3.0.5",
117+
"dequal": "^2.0.2",
112118
"lodash.camelcase": "^4.3.0",
113119
"lodash.kebabcase": "^4.1.1",
114120
"lodash.mergewith": "^4.6.2",
115121
"object-assign": "^4.1.1",
116122
"react": "^17.0.1",
117-
"tinycolor2": "^1.4.2"
123+
"tinycolor2": "^1.4.2",
124+
"vue": "^3.0.5"
118125
}
119126
}

packages/c-flex/src/flex.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
11
import { h, defineComponent, PropType, reactive } from 'vue'
2+
import type CSS from 'csstype'
23
import { chakra, DOMElements, ThemingProps } from '@chakra-ui/vue-system'
3-
import { SystemStyleObject } from '@chakra-ui/styled-system'
4+
5+
type ArrayOrStringProp<T> = T | T[]
46

57
export interface FlexProps {
68
/**
79
* Shorthand for `alignItems` style prop
810
* @type SystemStyleObject["alignItems"]
911
* SystemStyleObject because prop can be String, Array or Object
1012
*/
11-
align?: SystemStyleObject['alignItems']
13+
align?: ArrayOrStringProp<CSS.Properties['alignItems']>
1214

1315
/**
1416
* Shorthand for `justifyContent` style prop
1517
* @type SystemStyleObject["justifyContent"]
1618
*/
17-
justify?: SystemStyleObject['justifyContent']
19+
justify?: ArrayOrStringProp<CSS.Properties['justifyContent']>
1820

1921
/**
2022
* Shorthand for `flexWrap` style prop
2123
* @type SystemStyleObject["flexWrap"]
2224
*/
23-
wrap?: SystemStyleObject['flexWrap']
25+
wrap?: ArrayOrStringProp<CSS.Properties['flexWrap']>
2426

2527
/**
2628
* Shorthand for `flexDirection` style prop
2729
* @type SystemStyleObject["flexDirection"]
2830
*/
29-
direction?: SystemStyleObject['flexDirection']
31+
direction?: ArrayOrStringProp<CSS.Properties['flexDirection']>
3032

3133
/**
3234
* Shorthand for `flexBasis` style prop
3335
* @type SystemStyleObject["flexBasis"]
3436
*/
35-
basis?: SystemStyleObject['flexBasis']
37+
basis?: ArrayOrStringProp<CSS.Properties['flexBasis']>
3638

3739
/**
3840
* Shorthand for `flexGrow` style prop
3941
* @type SystemStyleObject["flexGrow"]
4042
*/
41-
grow?: SystemStyleObject['flexGrow']
43+
grow?: ArrayOrStringProp<CSS.Properties['flexGrow']>
4244

4345
/**
4446
* Shorthand for `flexShrink` style prop
4547
* @type SystemStyleObject["flexShrink"]
4648
*/
47-
shrink?: SystemStyleObject['flexShrink']
49+
shrink?: ArrayOrStringProp<CSS.Properties['flexShrink']>
4850
}
4951

5052
const CFlex = defineComponent({

packages/c-popper/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# @chakra-ui/vue-popper
2+
3+
Position engine for vue bult on popperjs core
4+
5+
## Installation
6+
7+
```sh
8+
yarn add @chakra-ui/vue-popper
9+
# or
10+
npm i @chakra-ui/vue-popper
11+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export const variants = {
2+
initial: {
3+
opacity: 0,
4+
},
5+
enter: {
6+
opacity: 1,
7+
},
8+
leave: {
9+
opacity: 0,
10+
},
11+
}
12+
13+
export const innerVariants = {
14+
initial: {
15+
scale: 0.9,
16+
opacity: 0,
17+
},
18+
enter: {
19+
scale: 1,
20+
opacity: 1,
21+
transition: {
22+
scale: {
23+
type: 'spring',
24+
damping: 5,
25+
stiffness: 550,
26+
},
27+
},
28+
},
29+
leave: {
30+
scale: 0.9,
31+
opacity: 0,
32+
},
33+
}

0 commit comments

Comments
 (0)