Skip to content

Commit

Permalink
docs: add popover docs
Browse files Browse the repository at this point in the history
  • Loading branch information
visualjerk committed Aug 16, 2020
1 parent 9b50246 commit 544ea31
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 53 deletions.
116 changes: 64 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,85 +23,97 @@ yarn add vue-ari

```vue
<template>
<Button v-bind="$props">
<slot />
</Button>
<PopoverDisclosure v-bind="popover">
Open Popover
</PopoverDisclosure>
<Popover v-bind="popover">
Popover Content
</Popover>
</template>
<script>
import { Button, buttonProps } from 'vue-ari'
import { Popover, PopoverDisclosure, usePopoverState } from 'vue-ari'
export default {
name: 'AppButton',
components: {
Button,
Popover,
PopoverDisclosure,
},
setup() {
const popover = usePopoverState()
return {
popover,
}
},
props: buttonProps,
}
</script>
```

## Styling

Ari components are unstyled by default. That means you got some work to do.
Ari components don't include styling by default. This gives you the ability to add styles however you like.

It also means you are not bound to some opinionated styling.

You have complete freedom in creating your own visual appearance from ari base components.
### Example Using Tailwind

```vue
<template>
<Button v-bind="$props" class="app-button">
<slot />
</Button>
<PopoverDisclosure
v-bind="popover"
class="text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
>
Open Popover
</PopoverDisclosure>
<Popover
v-bind="popover"
class="rounded shadow-lg border border-solid border-gray-300 py-3 px-5 bg-white"
>
Popover Content
</Popover>
</template>
<script>
import { Button, buttonProps } from 'vue-ari'
import { Popover, PopoverDisclosure, usePopoverState } from 'vue-ari'
export default {
name: 'AppButton',
name: 'App',
components: {
Button,
Popover,
PopoverDisclosure,
},
setup() {
const popover = usePopoverState()
return {
popover,
}
},
props: buttonProps,
}
</script>
```

<style lang="scss" scoped>
.app-button {
outline: 0;
color: #ffffff;
background: #006dff;
padding: 0.375em 0.75em;
line-height: 1.5;
border: transparent;
border-radius: 0.25rem;
cursor: pointer;
font-size: 16px;
&:focus {
box-shadow: 0 0 0 0.2em rgba(0, 109, 255, 0.4);
}
&[disabled],
&[aria-disabled='true'] {
cursor: auto;
opacity: 0.5;
}
&:not([disabled]),
&:not([aria-disabled='true']) {
&:hover {
color: #ffffff;
background-color: #0062e6;
}
&:active,
&[data-active='true'] {
color: #ffffff;
background-color: #004eb8;
}
}
## Reusable Components

It would get pretty verbose to add the same styling classes wherever you like to use a `Popover`. So the recommended way is wrapping Ari components inside your own base components and use them inside your app.

```vue
<template>
<PopoverDisclosure
v-bind="$props"
class="text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
>
<slot />
</PopoverDisclosure>
</template>
<script>
import { PopoverDisclosure, popoverDisclosureProps } from 'vue-ari'
export default {
name: 'AppPopoverDisclosure',
props: popoverDisclosureProps,
components: {
PopoverDisclosure,
},
}
</style>
</script>
```
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"tailwindcss": "^1.5.2",
"vue": "^3.0.0-rc.1",
"vue-ari": "^0.0.0"
"vue-ari": "^0.0.0-alpha.6"
},
"devDependencies": {
"@vue/compiler-sfc": "^3.0.0-rc.1",
Expand Down
114 changes: 114 additions & 0 deletions src/Popover/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Popover

`Popover` is a non-modal dialog that is positioned near its disclosure. It is commonly used for displaying additional related content.

## Installation

```bash
npm i vue-ari
```

or

```bash
yarn add vue-ari
```

## Usage

```vue
<template>
<PopoverDisclosure v-bind="popover">
Open Popover
</PopoverDisclosure>
<Popover v-bind="popover">
Popover Content
</Popover>
</template>
<script>
import { Popover, PopoverDisclosure, usePopoverState } from 'vue-ari'
export default {
name: 'AppButton',
components: {
Popover,
PopoverDisclosure,
},
setup() {
const popover = usePopoverState()
return {
popover,
}
},
}
</script>
```

## Styling

Ari components don't include styling by default. This gives you the ability to add styles however you like.

### Example Using Tailwind

```vue
<template>
<PopoverDisclosure
v-bind="popover"
class="text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
>
Open Popover
</PopoverDisclosure>
<Popover
v-bind="popover"
class="rounded shadow-lg border border-solid border-gray-300 py-3 px-5 bg-white"
>
Popover Content
</Popover>
</template>
<script>
import { Popover, PopoverDisclosure, usePopoverState } from 'vue-ari'
export default {
name: 'App',
components: {
Popover,
PopoverDisclosure,
},
setup() {
const popover = usePopoverState()
return {
popover,
}
},
}
</script>
```

## Reusable Components

It would get pretty verbose to add the same styling classes wherever you like to use a `Popover`. So the recommended way is wrapping Ari components inside your own base components and use them inside your app.

```vue
<template>
<PopoverDisclosure
v-bind="$props"
class="text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
>
<slot />
</PopoverDisclosure>
</template>
<script>
import { PopoverDisclosure, popoverDisclosureProps } from 'vue-ari'
export default {
name: 'AppPopoverDisclosure',
props: popoverDisclosureProps,
components: {
PopoverDisclosure,
},
}
</script>
```

0 comments on commit 544ea31

Please sign in to comment.