Skip to content

Commit

Permalink
add first demo
Browse files Browse the repository at this point in the history
  • Loading branch information
k11q committed Jun 30, 2023
1 parent 999e51f commit a57fb7e
Show file tree
Hide file tree
Showing 11 changed files with 626 additions and 541 deletions.
61 changes: 61 additions & 0 deletions docs/components/content/AlertDialogDemo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<script setup lang="ts">
import {
AlertDialogRoot,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogOverlay,
AlertDialogCancel,
AlertDialogAction,
AlertDialogPortal,
AlertDialogTitle,
AlertDialogDescription,
} from "radix-vue";
const alertDialogOpen = ref(false);
function handleAction() {
alert("clicked action button!");
}
</script>

<template>
Hello alert dialog
<!--
<AlertDialogRoot>
<AlertDialogTrigger
class="text-violet11 hover:bg-mauve3 shadow-blackA7 inline-flex h-[35px] items-center justify-center rounded-[4px] bg-white px-[15px] font-medium leading-none shadow-[0_2px_10px] outline-none focus:shadow-[0_0_0_2px] focus:shadow-black"
>
Delete account
</AlertDialogTrigger>
<AlertDialogPortal>
<AlertDialogOverlay
class="bg-blackA9 data-[state=open]:animate-overlayShow fixed inset-0"
/>
<AlertDialogContent
class="data-[state=open]:animate-contentShow fixed top-[50%] left-[50%] max-h-[85vh] w-[90vw] max-w-[500px] translate-x-[-50%] translate-y-[-50%] rounded-[6px] bg-white p-[25px] shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] focus:outline-none"
>
<AlertDialogTitle class="text-mauve12 m-0 text-[17px] font-medium">
Are you absolutely sure?
</AlertDialogTitle>
<AlertDialogDescription class="text-mauve11 mt-4 mb-5 text-[15px] leading-normal">
This action cannot be undone. This will permanently delete your account and
remove your data from our servers.
</AlertDialogDescription>
<div class="flex justify-end gap-[25px]">
<AlertDialogCancel
class="text-mauve11 bg-mauve4 hover:bg-mauve5 focus:shadow-mauve7 inline-flex h-[35px] items-center justify-center rounded-[4px] px-[15px] font-medium leading-none outline-none focus:shadow-[0_0_0_2px]"
>
Cancel
</AlertDialogCancel>
<AlertDialogAction
@click="handleAction"
class="text-red11 bg-red4 hover:bg-red5 focus:shadow-red7 inline-flex h-[35px] items-center justify-center rounded-[4px] px-[15px] font-medium leading-none outline-none focus:shadow-[0_0_0_2px]"
>
Yes, delete account
</AlertDialogAction>
</div>
</AlertDialogContent>
</AlertDialogPortal>
</AlertDialogRoot>
-->
</template>
26 changes: 26 additions & 0 deletions docs/components/content/ComponentExample.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<div class="[&>div>pre]:!rounded-t-none">
<div class="flex border border-gray-200 dark:border-gray-700 relative not-prose rounded-t-md" :class="[{ 'p-4': padding, 'rounded-b-md': !$slots.code, 'border-b-0': !!$slots.code }, backgroundClass, overflowClass]">
<ContentSlot v-if="$slots.default" :use="$slots.default" />
</div>

<ContentSlot v-if="$slots.code" :use="$slots.code" />
</div>
</template>

<script setup lang="ts">
defineProps({
padding: {
type: Boolean,
default: true
},
backgroundClass: {
type: String,
default: 'bg-white dark:bg-gray-900'
},
overflowClass: {
type: String,
default: ''
}
})
</script>
3 changes: 3 additions & 0 deletions docs/components/content/MyButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<button>My button!</button>
</template>
8 changes: 8 additions & 0 deletions docs/components/content/PaginationExampleBasic.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script setup>
const page = ref(1)
const items = ref(Array(55))
</script>

<template>
<button class="bg-gray-800">Hello world</button>
</template>
133 changes: 97 additions & 36 deletions docs/content/3.components/alert-dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,84 @@ aria: https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog

# Alert Dialog

<Description>
A modal dialog that interrupts the user with important content and expects a
response.
</Description>

<HeroContainer>
<AlertDialogDemo />
</HeroContainer>

<HeroCodeBlock folder="AlertDialog" />

<Highlights
features={[
'Focus is automatically trapped.',
'Can be controlled or uncontrolled.',
<span>
Manages screen reader announcements with <Code>Title</Code> and{' '}
<Code>Description</Code> components.
</span>,
'Esc closes the component automatically.',
]}
/>

::code-group
::code-block{label="Preview" preview}
:alert-dialog-demo
::
```vue [Code]
<script setup lang="ts">
import {
AlertDialogRoot,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogOverlay,
AlertDialogCancel,
AlertDialogAction,
AlertDialogPortal,
AlertDialogTitle,
AlertDialogDescription,
} from "radix-vue";
const alertDialogOpen = ref(false);
function handleAction() {
alert("clicked action button!");
}
</script>
<template>
<AlertDialogRoot>
<AlertDialogTrigger
class="text-violet11 hover:bg-mauve3 shadow-blackA7 inline-flex h-[35px] items-center justify-center rounded-[4px] bg-white px-[15px] font-medium leading-none shadow-[0_2px_10px] outline-none focus:shadow-[0_0_0_2px] focus:shadow-black"
>
Delete account
</AlertDialogTrigger>
<AlertDialogPortal>
<AlertDialogOverlay
class="bg-blackA9 data-[state=open]:animate-overlayShow fixed inset-0"
/>
<AlertDialogContent
class="data-[state=open]:animate-contentShow fixed top-[50%] left-[50%] max-h-[85vh] w-[90vw] max-w-[500px] translate-x-[-50%] translate-y-[-50%] rounded-[6px] bg-white p-[25px] shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] focus:outline-none"
>
<AlertDialogTitle class="text-mauve12 m-0 text-[17px] font-medium">
Are you absolutely sure?
</AlertDialogTitle>
<AlertDialogDescription class="text-mauve11 mt-4 mb-5 text-[15px] leading-normal">
This action cannot be undone. This will permanently delete your account and
remove your data from our servers.
</AlertDialogDescription>
<div class="flex justify-end gap-[25px]">
<AlertDialogCancel
class="text-mauve11 bg-mauve4 hover:bg-mauve5 focus:shadow-mauve7 inline-flex h-[35px] items-center justify-center rounded-[4px] px-[15px] font-medium leading-none outline-none focus:shadow-[0_0_0_2px]"
>
Cancel
</AlertDialogCancel>
<AlertDialogAction
@click="handleAction"
class="text-red11 bg-red4 hover:bg-red5 focus:shadow-red7 inline-flex h-[35px] items-center justify-center rounded-[4px] px-[15px] font-medium leading-none outline-none focus:shadow-[0_0_0_2px]"
>
Yes, delete account
</AlertDialogAction>
</div>
</AlertDialogContent>
</AlertDialogPortal>
</AlertDialogRoot>
</template>
```
::

## Features

::list{type="success"}
- Focus is automatically trapped.
- Can be controlled or uncontrolled.
- Manages screen reader announcements with `Title` and
`Description` components.
- Esc closes the component automatically.
::

## Installation

Expand All @@ -42,23 +98,25 @@ npm install @radix-ui/react-alert-dialog

Import all parts and piece them together.

```jsx
```vue
<script setup lang="ts">
import * as AlertDialog from '@radix-ui/react-alert-dialog';

export default () => (
<AlertDialog.Root>
<AlertDialog.Trigger />
<AlertDialog.Portal>
<AlertDialog.Overlay />
<AlertDialog.Content>
<AlertDialog.Title />
<AlertDialog.Description />
<AlertDialog.Cancel />
<AlertDialog.Action />
</AlertDialog.Content>
</AlertDialog.Portal>
</AlertDialog.Root>
);
</script>
<template>
<AlertDialogRoot>
<AlertDialogTrigger />
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogContent>
<AlertDialogTitle />
<AlertDialogDescription />
<AlertDialogCancel />
<AlertDialogAction />
</AlertDialogContent>
</AlertDialogPortal>
</AlertDialogRoot>
<template/>
```

## API Reference
Expand Down Expand Up @@ -99,6 +157,9 @@ Contains all the parts of an alert dialog.

A button that opens the dialog.

| Prop | Type | Default |
| -- | -- | -- |
| `asChild` | false | - |
<PropsTable
data={[
{
Expand Down
File renamed without changes.
Loading

0 comments on commit a57fb7e

Please sign in to comment.