Skip to content

Commit

Permalink
feat(components): shortcut
Browse files Browse the repository at this point in the history
Signed-off-by: ZTL-UwU <zhangtianli2006@163.com>
  • Loading branch information
ZTL-UwU committed Oct 14, 2024
1 parent 82fa587 commit 7d9b4ef
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions components/content/Shortcut.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<Kbd :size>
{{ computedValue }}
</Kbd>
</template>

<script setup lang="ts">
const { value, size = 'sm' } = defineProps<{
value: string;
size?: 'xs' | 'sm' | 'md';
}>();
const metaSymbol = ref('Ctrl');
onMounted(() => {
metaSymbol.value = navigator && navigator.userAgent && navigator.userAgent.match(/Macintosh;/) ? '' : 'Ctrl';
});
const computedValue = computed(() => value === 'meta' ? metaSymbol : value);
</script>
17 changes: 17 additions & 0 deletions content/1.getting-started/3.writing/2.components.md
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,23 @@ Stackable components:
- `card`
- `tabs`
### Shortcut
:badge[0.6.3]{variant="outline"}
:badge[Nuxt UI Pro]{variant="outline" to="https://ui.nuxt.com/pro/prose/shortcut" target="_blank"}
::code-group
::div{label="Preview" class="md:p-4"}
:shortcut{value="meta"} :shortcut{value="K"} :br
:shortcut{value="xs" size="xs"} :shortcut{value="sm"} :shortcut{value="md" size="md"}
::
```mdc [Code]
:shortcut{value="meta"} :shortcut{value="K"} :br
:shortcut{value="xs" size="xs"} :shortcut{value="sm"} :shortcut{value="md" size="md"}
```
::

You can put `meta` in the `value` field to automatically display either :shortcut{value=""} or :shortcut{value="Ctrl"} based on the platform.

## Page Components

### Hero
Expand Down

0 comments on commit 7d9b4ef

Please sign in to comment.