Skip to content

Commit

Permalink
lfg
Browse files Browse the repository at this point in the history
  • Loading branch information
irsyadadl committed Oct 18, 2024
1 parent 0f50eb5 commit 0aedae2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion components/docs/generated/previews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is autogenerated by scripts/create-pr-content.ts.
// Do not edit this file directly.

import React from 'react'
import React from 'react';

export const previews: Record<string, any> = {
"date-and-time/date-field/date-field-demo": {
Expand Down
36 changes: 15 additions & 21 deletions components/ui/command-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ const commandStyles = tv({
'xda32kfseccmd overflow-hidden py-2 px-2 text-fg',
'[&_[cmdk-group-heading]]:select-none [&_[cmdk-group-heading]]:ml-[1px] [&_[cmdk-group-heading]]:py-2 [&_[cmdk-group-heading]]:text-[0.8rem] [&_[cmdk-group-heading]]:text-muted-fg'
],
modalOverlay: [
'fixed inset-0 max-h-[--visual-viewport-height] z-50 bg-black/15 dark:bg-black/40 entering:animate-in entering:fade-in-0 exiting:animate-in exiting:fade-out-0'
],
modal: [
'fixed bottom-0 left-[50%] top-auto z-50 grid h-[calc(100vh-35%)] w-full max-w-full translate-x-[-50%] gap-4 overflow-hidden rounded-t-xl bg-overlay text-overlay-fg shadow-lg ring-1 ring-dark/5 dark:ring-border sm:bottom-auto sm:top-[6rem] sm:h-auto sm:w-full sm:max-w-2xl sm:rounded-xl',
'sm:entering:slide-in-from-bottom-auto entering:duration-300 entering:animate-in entering:fade-in-0 entering:slide-in-from-bottom-1/2 entering:slide-in-from-left-1/2 entering:[transition-timing-function:ease-out] sm:entering:duration-300 sm:entering:slide-in-from-top-[2rem]',
Expand Down Expand Up @@ -61,26 +58,12 @@ const commandStyles = tv({
variants: {
isDanger: {
true: 'text-danger data-[selected=true]:bg-danger data-[selected=true]:text-danger-fg [&[data-selected=true]_[data-slot=icon]]:text-danger-fg'
},
isBlurred: {
true: 'backdrop-blur-sm'
}
}
})

const {
command,
empty,
section,
list,
item,
closeButton,
modal,
input,
modalOverlay,
kbdKeyboard,
description
} = commandStyles()
const { command, empty, section, list, item, closeButton, modal, input, kbdKeyboard, description } =
commandStyles()

interface CommandMenuContextProps {
hideSearchIndicator?: boolean
Expand All @@ -102,6 +85,17 @@ interface CommandMenuRootProps {
CommandMenuDescription?: typeof CommandMenuDescription
}

const modalOverlay = tv({
base: [
'fixed inset-0 max-h-[--visual-viewport-height] z-50 bg-black/15 dark:bg-black/40 entering:animate-in entering:fade-in-0 exiting:animate-in exiting:fade-out-0'
],
variants: {
isBlurred: {
true: 'backdrop-blur',
false: 'bg-black/15 dark:bg-black/40'
}
}
})
interface CommandMenuProps
extends ModalOverlayProps,
CommandMenuRootProps,
Expand All @@ -114,7 +108,6 @@ interface CommandMenuProps
overlay?: string
content?: string
}
isBlurred?: boolean
}

const CommandMenu = ({
Expand All @@ -135,7 +128,8 @@ const CommandMenu = ({
<ModalOverlay
isDismissable
className={modalOverlay({
className: twJoin(classNames?.overlay, isBlurred ? 'backdrop-blur' : '')
isBlurred,
className: classNames?.overlay
})}
{...props}
>
Expand Down
9 changes: 5 additions & 4 deletions resources/content/docs/components/controls/command-menu.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ Activate the command menu via keyboard commands, ideal for initiating command pa
Highlight a command item as dangerous by changing its color to red, indicating a warning.
<How toUse="controls/command-menu/command-menu-danger-item-demo" />


## Blur
If you want to blur the background, you can use `isBlurred` prop.
<How toUse="controls/command-menu/command-menu-blur-demo" />

## Controlled
Manage the command palette dynamically using the `value` and `onValueChange` props, making it responsive to changes in a parent component.
<How toUse="controls/command-menu/command-menu-controlled-demo" />
Expand Down Expand Up @@ -145,7 +150,3 @@ export function CommandPalette({ open, setOpen }: Props) {
}, [pathname, setOpen])
return (...)
```
## Blur
If you want to blur the background, you can use `isBlurred` prop.
<How toUse="controls/command-menu/command-menu-blur-demo" />
3 changes: 3 additions & 0 deletions resources/content/docs/prologue/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ If you don't see the release you're looking for, please run `npx justd-cli@lates
## 2024
This all changes are made on the 2024 release.

## 18 October
- Add `isBlurred` props to [Command Menu](/docs/components/controls/command-menu) by [yuxxeun](https://github.com/yuxxeun)

## 17 October
- `isLoading` now renamed to `isPending` on all components that need it
- SearchField now have `isPending` props [SearchField](/docs/components/forms/search-field)
Expand Down

0 comments on commit 0aedae2

Please sign in to comment.