-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(drawer): implement simple drawer
- Loading branch information
Showing
20 changed files
with
533 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,85 @@ | ||
--- | ||
title: Drawer component | ||
title: Acv Drawer component | ||
lang: en-US | ||
editLink: true | ||
--- | ||
|
||
# Drawer | ||
# Acv Drawer | ||
|
||
Short description for Drawer component... | ||
|
||
:::info Figma component anatomy | ||
https://www.figma.com/file/ | ||
::: | ||
Drawer is a panel that slides in from the edge of the screen. | ||
It can be used to show additional content without taking up space on the main screen. | ||
|
||
## Basic usage | ||
|
||
`AcvDrawer` component uses `AcvCard` as its base. | ||
Bind `AcvDrawer` with `v-model` to hide and show drawer/card. | ||
|
||
All props & slots available in `AcvCard` is available in `AcvDrawer`. | ||
|
||
<DrawerBasic /> | ||
|
||
::: details Source code | ||
::: details DrawerBasic | ||
<<< @/demos/drawer/DrawerBasic.vue | ||
::: | ||
|
||
## Best practices | ||
## Anchor | ||
|
||
You can change the position of the drawer by providing the values `left`,`right`,`top` or `bottom` to the `anchor` prop. | ||
|
||
<DrawerAnchor /> | ||
|
||
::: details DrawerAnchor | ||
<<< @/demos/drawer/DrawerAnchor.vue{37,45} | ||
::: | ||
|
||
## Width | ||
|
||
Use width utility classes to provide custom width to drawer. | ||
|
||
<DrawerWidth /> | ||
|
||
::: details DrawerWidth | ||
<<< @/demos/drawer/DrawerWidth.vue{13} | ||
::: | ||
|
||
## Persistent | ||
|
||
You can disable closing drawer on outside click via `persistent` prop. | ||
|
||
<DrawerPersistent /> | ||
|
||
::: details DrawerPersistent | ||
<<< @/demos/drawer/DrawerPersistent.vue{14} | ||
::: | ||
|
||
## Accessibility | ||
|
||
A Drawer should ... | ||
Drawer is accessible by default. | ||
It can be opened and closed using `esc` key. | ||
|
||
## Related components | ||
|
||
- [Button](/components/button/button.doc) | ||
- [Card](/components/card/card.doc) | ||
|
||
## Props | ||
|
||
| Prop name | Description | Type | Values | Default | | ||
| ----------- | ------------------------- | ------ | ------ | ------- | | ||
| title | Title of the Drawer | string | - | | | ||
| description | Description of the Drawer | string | - | | | ||
| Prop name | Description | Type | Values | Default | | ||
| --------------- | --------------------------------------------------------------- | --------------- | ------ | ------- | | ||
| textColor | Text color of the card | string | - | | | ||
| borderColor | Border color of the card | string | - | | | ||
| backgroundColor | Background color of the card | union | - | | | ||
| modelValue | Drawer visiblity state | boolean | - | false | | ||
| persistent | Persistence of drawer when clicked outside of reference element | boolean | - | false | | ||
| anchor | Drawer anchor/position | AcvDrawerAnchor | - | 'left' | | ||
|
||
## Events | ||
|
||
| Event name | Properties | Description | | ||
| ---------- | --------------------------------------------------------------------------------------------------------------- | -------------------------------------- | | ||
| close | **eventName** `string` - The name of the event<br/>**visible** `string` - The visibility state of the component | Triggered when the component is closed | | ||
| Event name | Properties | Description | | ||
| ----------------- | --------------------------------------------------------------------------------------------------------------- | -------------------------------------- | | ||
| update:modelValue | **eventName** `string` - The name of the event<br/>**visible** `string` - The visibility state of the component | Triggered when the component is closed | | ||
|
||
## Slots | ||
|
||
| Name | Description | Bindings | | ||
| ----------- | ---------------------------- | -------- | | ||
| default | The default slot content | | | ||
| description | The description slot content | | | ||
| Name | Description | Bindings | | ||
| ---- | ----------- | -------- | | ||
| name | | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export default { | ||
title: 'Card title', | ||
subtitle: 'Card subtitle', | ||
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla quam velit, vulputate eu pharetra nec, mattis ac neque.', | ||
image: '/images/hotel.png', | ||
actions: [ | ||
{ | ||
label: 'Action 1', | ||
onClick: () => console.log('Action 1 clicked') | ||
} | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<script setup> | ||
import { ref } from 'vue'; | ||
import AcvDrawer from '@/components/drawer/drawer.vue'; | ||
import AcvButton from '@/components/button/button.vue'; | ||
const isDrawerLeftShown = ref(false); | ||
const isDrawerRightShown = ref(false); | ||
const isDrawerTopShown = ref(false); | ||
const isDrawerBottomShown = ref(false); | ||
</script> | ||
|
||
<template> | ||
<AcvButton | ||
class="mr-4" | ||
@click="isDrawerLeftShown = true" | ||
> | ||
Left | ||
</AcvButton> | ||
<AcvButton | ||
class="mr-4" | ||
@click="isDrawerRightShown = true" | ||
> | ||
Right | ||
</AcvButton> | ||
<AcvButton | ||
class="mr-4" | ||
@click="isDrawerTopShown = true" | ||
> | ||
Top | ||
</AcvButton> | ||
<AcvButton @click="isDrawerBottomShown = true"> | ||
Bottom | ||
</AcvButton> | ||
|
||
<AcvDrawer | ||
v-model="isDrawerLeftShown" | ||
anchor="left" | ||
title="CARPE DIEM, SESTIUS" | ||
subtitle="Solvitur acris hiems grata vice veris et Favoni | ||
trahuntque siccas machinae carinas" | ||
/> | ||
|
||
<AcvDrawer | ||
v-model="isDrawerRightShown" | ||
anchor="right" | ||
title="CARPE DIEM, SESTIUS" | ||
subtitle="Solvitur acris hiems grata vice veris et Favoni | ||
trahuntque siccas machinae carinas" | ||
/> | ||
|
||
<AcvDrawer | ||
v-model="isDrawerTopShown" | ||
anchor="top" | ||
title="CARPE DIEM, SESTIUS" | ||
subtitle="Solvitur acris hiems grata vice veris et Favoni | ||
trahuntque siccas machinae carinas" | ||
/> | ||
|
||
<AcvDrawer | ||
v-model="isDrawerBottomShown" | ||
anchor="bottom" | ||
title="CARPE DIEM, SESTIUS" | ||
subtitle="Solvitur acris hiems grata vice veris et Favoni | ||
trahuntque siccas machinae carinas" | ||
/> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
<script setup> | ||
import Drawer from '@/components/drawer/drawer.vue'; | ||
import { ref } from 'vue'; | ||
import AcvDrawer from '@/components/drawer/drawer.vue'; | ||
import AcvButton from '@/components/button/button.vue'; | ||
const isDrawerShown = ref(false); | ||
</script> | ||
|
||
<template> | ||
<Drawer /> | ||
<AcvDrawer | ||
v-model="isDrawerShown" | ||
title="CARPE DIEM, SESTIUS" | ||
subtitle="Solvitur acris hiems grata vice veris et Favoni | ||
trahuntque siccas machinae carinas" | ||
/> | ||
|
||
<AcvButton @click="isDrawerShown = true"> | ||
Show drawer | ||
</AcvButton> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script setup> | ||
import { ref } from 'vue'; | ||
import cardMock from '../__data__/data.mock.card.js'; | ||
import AcvDrawer from '@/components/drawer/drawer.vue'; | ||
import AcvButton from '@/components/button/button.vue'; | ||
import AcvTypography from '@/components/typography/typography.vue'; | ||
const isDrawerShown = ref(false); | ||
</script> | ||
|
||
<template> | ||
<AcvDrawer | ||
v-model="isDrawerShown" | ||
persistent | ||
> | ||
<div class="a-card-body"> | ||
<AcvTypography | ||
:title="cardMock.title" | ||
:subtitle="cardMock.subtitle" | ||
:text="cardMock.text" | ||
/> | ||
<AcvButton | ||
class="text-sm" | ||
@click="isDrawerShown = false" | ||
> | ||
Close | ||
</AcvButton> | ||
</div> | ||
</AcvDrawer> | ||
|
||
<AcvButton @click="isDrawerShown = true"> | ||
Show drawer | ||
</AcvButton> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script setup> | ||
import { ref } from 'vue'; | ||
const isDrawerShown = ref(false); | ||
</script> | ||
|
||
<template> | ||
<AcvDrawer | ||
v-model="isDrawerShown" | ||
title="CARPE DIEM, SESTIUS" | ||
subtitle="Solvitur acris hiems grata vice veris et Favoni | ||
trahuntque siccas machinae carinas" | ||
class="!w-[400px]" | ||
/> | ||
|
||
<AcvButton @click="isDrawerShown = true"> | ||
Show drawer | ||
</AcvButton> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export interface CardProps { | ||
export interface AcvCardProps { | ||
/** | ||
* Background color of the card | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,54 @@ | ||
Short description for Drawer component... | ||
|
||
:::info Figma component anatomy | ||
https://www.figma.com/file/ | ||
::: | ||
Drawer is a panel that slides in from the edge of the screen. | ||
It can be used to show additional content without taking up space on the main screen. | ||
|
||
## Basic usage | ||
|
||
`AcvDrawer` component uses `AcvCard` as its base. | ||
Bind `AcvDrawer` with `v-model` to hide and show drawer/card. | ||
|
||
All props & slots available in `AcvCard` is available in `AcvDrawer`. | ||
|
||
<DrawerBasic /> | ||
|
||
::: details Source code | ||
::: details DrawerBasic | ||
<<< @/demos/drawer/DrawerBasic.vue | ||
::: | ||
|
||
## Best practices | ||
## Anchor | ||
|
||
You can change the position of the drawer by providing the values `left`,`right`,`top` or `bottom` to the `anchor` prop. | ||
|
||
<DrawerAnchor /> | ||
|
||
::: details DrawerAnchor | ||
<<< @/demos/drawer/DrawerAnchor.vue{37,45} | ||
::: | ||
|
||
## Width | ||
|
||
Use width utility classes to provide custom width to drawer. | ||
|
||
<DrawerWidth /> | ||
|
||
::: details DrawerWidth | ||
<<< @/demos/drawer/DrawerWidth.vue{13} | ||
::: | ||
|
||
## Persistent | ||
|
||
You can disable closing drawer on outside click via `persistent` prop. | ||
|
||
<DrawerPersistent /> | ||
|
||
::: details DrawerPersistent | ||
<<< @/demos/drawer/DrawerPersistent.vue{14} | ||
::: | ||
|
||
## Accessibility | ||
|
||
A Drawer should ... | ||
Drawer is accessible by default. | ||
It can be opened and closed using `esc` key. | ||
|
||
## Related components | ||
|
||
- [Button](/components/button/button.doc) | ||
- [Card](/components/card/card.doc) |
Oops, something went wrong.