Skip to content

fix: ShadCN/Ariakit AI menu & translations #1688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/ariakit/src/input/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const TextInput = forwardRef<
onChange,
onSubmit,
autoComplete,
rightSection, // TODO: add rightSection
rightSection,
...rest
} = props;

Expand All @@ -40,7 +40,7 @@ export const TextInput = forwardRef<
className={mergeCSSClasses(
"bn-ak-input",
className || "",
variant === "large" ? "bn-ak-input-large" : ""
variant === "large" ? "bn-ak-input-large" : "",
)}
ref={ref}
name={name}
Expand All @@ -53,6 +53,7 @@ export const TextInput = forwardRef<
onSubmit={onSubmit}
autoComplete={autoComplete}
/>
{rightSection}
</div>
</>
);
Expand Down
87 changes: 80 additions & 7 deletions packages/ariakit/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
gap: 0.5rem;
}

.bn-ak-input-wrapper svg {
width: 24px;
}

.bn-ak-toolbar {
height: fit-content;
overflow: scroll;
Expand All @@ -23,11 +27,15 @@

.bn-toolbar .bn-ak-button[data-selected] {
padding-top: 0.125rem;
box-shadow: inset 0 0 0 1px var(--border), inset 0 2px 0 var(--border);
box-shadow:
inset 0 0 0 1px var(--border),
inset 0 2px 0 var(--border);
}

.bn-toolbar .bn-ak-button[data-selected]:where(.dark, .dark *) {
box-shadow: inset 0 0 0 1px var(--border), inset 0 1px 1px 1px var(--shadow);
box-shadow:
inset 0 0 0 1px var(--border),
inset 0 1px 1px 1px var(--shadow);
}

.bn-toolbar .bn-ak-popover {
Expand Down Expand Up @@ -64,9 +72,11 @@
overflow: visible;
}

.bn-ariakit .bn-suggestion-menu {
.bn-ariakit .bn-suggestion-menu,
.bn-ariakit .ai-suggestion-menu {
height: fit-content;
max-height: inherit;
overflow: auto;
}

.bn-ariakit .bn-color-picker-dropdown {
Expand Down Expand Up @@ -106,13 +116,34 @@
--border: rgb(0 0 0/13%);
--highlight: rgb(255 255 255/20%);
--shadow: rgb(0 0 0/10%);
box-shadow: inset 0 0 0 1px var(--border), inset 0 2px 0 var(--highlight),
inset 0 -1px 0 var(--shadow), 0 1px 1px var(--shadow);
box-shadow:
inset 0 0 0 1px var(--border),
inset 0 2px 0 var(--highlight),
inset 0 -1px 0 var(--shadow),
0 1px 1px var(--shadow);
font-size: 0.7rem;
border-radius: 4px;
padding-inline: 4px;
}

@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

.bn-ariakit .bn-suggestion-menu-loader {
align-items: center;
animation: spin 1s linear infinite;
display: flex;
height: 16px;
justify-content: center;
width: 16px;
}

.bn-ariakit .bn-grid-suggestion-menu {
background: var(--bn-colors-menu-background);
border-radius: var(--bn-border-radius-large);
Expand Down Expand Up @@ -263,7 +294,7 @@
.bn-ak-author-info {
align-items: center;
display: flex;
gap: 16px
gap: 16px;
}

.bn-ariakit .bn-comment-editor .bn-editor {
Expand Down Expand Up @@ -319,6 +350,48 @@
padding: 0;
}

.bn-ariakit .bn-combobox .bn-ak-input-wrapper {
display: flex;
border-radius: 0.5rem;
border-width: 1px;
border-style: solid;
border-color: hsl(204 20% 88%);
background-color: hsl(204 20% 100%);
padding: 0.5rem;
color: hsl(204 4% 0%);
box-shadow:
0 10px 15px -3px rgb(0 0 0 / 0.1),
0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.bn-ariakit .bn-combobox .bn-ak-input-wrapper:where(.dark, .dark *) {
border-color: hsl(204 4% 24%);
background-color: hsl(204 4% 16%);
color: hsl(204 20% 100%);
box-shadow:
0 10px 15px -3px rgb(0 0 0 / 0.25),
0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.bn-ariakit .bn-combobox .bn-ak-input {
background: transparent;
border: none;
box-shadow: none;
outline: none;
}

.bn-ariakit .bn-combobox .bn-combobox-icon,
.bn-ariakit .bn-combobox .bn-combobox-right-section {
align-items: start;
display: flex;
justify-content: center;
width: 24px;
}

.bn-ariakit .bn-combobox .bn-combobox-error {
color: var(--bn-colors-highlights-red-background);
}

.bn-ariakit .bn-comment-actions-wrapper {
align-items: start;
display: flex;
Expand Down Expand Up @@ -355,4 +428,4 @@
.bn-ariakit .bn-thread.selected .bn-ak-author-info,
.bn-ariakit .bn-thread.selected .bn-ak-expand-sections-prompt {
color: var(--bn-colors-selected-text);
}
}
13 changes: 11 additions & 2 deletions packages/ariakit/src/suggestionMenu/SuggestionMenuLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ export const SuggestionMenuLoader = forwardRef<
HTMLDivElement,
ComponentProps["SuggestionMenu"]["Loader"]
>((props, ref) => {
const { className, children, ...rest } = props;
const { className, ...rest } = props;

assertEmpty(rest);

return (
<div className={className} ref={ref}>
{children}
{/* Taken from Google Material Icons */}
{/* https://fonts.google.com/icons?selected=Material+Symbols+Rounded:progress_activity:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=load&icon.size=24&icon.color=%23e8eaed&icon.set=Material+Symbols&icon.style=Rounded&icon.platform=web */}
<svg
xmlns="http://www.w3.org/2000/svg"
height="1em"
viewBox="0 -960 960 960"
width="1em"
fill="#e8eaed">
<path d="M480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 31.5-155.5t86-127Q252-817 325-848.5T480-880q17 0 28.5 11.5T520-840q0 17-11.5 28.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160q133 0 226.5-93.5T800-480q0-17 11.5-28.5T840-520q17 0 28.5 11.5T880-480q0 82-31.5 155t-86 127.5q-54.5 54.5-127 86T480-80Z" />
</svg>
</div>
);
});
52 changes: 40 additions & 12 deletions packages/mantine/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@
max-height: 100%;
position: relative;
box-shadow: var(--mantine-shadow-md);
border: calc(0.0625rem * var(--mantine-scale)) solid var(--mantine-color-gray-2);
border: calc(0.0625rem * var(--mantine-scale)) solid
var(--mantine-color-gray-2);
border-radius: var(--mantine-radius-default);
padding: 4px;
}
Expand Down Expand Up @@ -350,12 +351,15 @@
padding: 8px;
}

.bn-suggestion-menu-item-small .bn-mt-suggestion-menu-item-section[data-position="left"] {
.bn-suggestion-menu-item-small
.bn-mt-suggestion-menu-item-section[data-position="left"] {
background-color: transparent;
padding: 0;
}

.bn-suggestion-menu-item-small .bn-mt-suggestion-menu-item-section[data-position="left"] svg {
.bn-suggestion-menu-item-small
.bn-mt-suggestion-menu-item-section[data-position="left"]
svg {
height: 14px;
width: 14px;
}
Expand Down Expand Up @@ -607,8 +611,8 @@
}

.bn-mt-sub-menu-item
> .mantine-Menu-itemLabel
> div:not(.mantine-Menu-dropdown) {
> .mantine-Menu-itemLabel
> div:not(.mantine-Menu-dropdown) {
align-items: center;
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -745,23 +749,47 @@
}

.bn-mantine
.bn-badge
.mantine-Chip-label
> span:not(.mantine-Chip-iconWrapper) {
.bn-badge
.mantine-Chip-label
> span:not(.mantine-Chip-iconWrapper) {
display: inline-flex;
gap: 4px;
}

.bn-mantine
.bn-badge
.mantine-Chip-label
> span:not(.mantine-Chip-iconWrapper)
> span {
.bn-badge
.mantine-Chip-label
> span:not(.mantine-Chip-iconWrapper)
> span {
align-items: center;
display: inline-flex;
justify-content: center;
}

/* Combobox styling */
.bn-mantine .bn-combobox-input,
.bn-mantine .bn-combobox-items:not(:empty) {
background-color: var(--bn-colors-menu-background);
border: var(--bn-border);
border-radius: var(--bn-border-radius-medium);
box-shadow: var(--bn-shadow-medium);
color: var(--bn-colors-menu-text);
gap: 4px;
min-width: 145px;
padding: 2px;
}

.bn-mantine .bn-combobox-input .bn-combobox-icon,
.bn-mantine .bn-combobox-input .bn-combobox-right-section {
align-items: center;
display: flex;
justify-content: center;
}

.bn-mantine .bn-combobox-input .bn-combobox-error {
color: var(--bn-colors-highlights-red-background);
}

/* We need to get rid of the checked icon - you can set the icon prop to an
empty element (<></>), but even so Mantine leaves extra space for the icon, so
we just don't display it in CSS instead. */
Expand Down
10 changes: 4 additions & 6 deletions packages/mantine/src/suggestionMenu/SuggestionMenuLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ export const SuggestionMenuLoader = forwardRef<
HTMLDivElement,
ComponentProps["SuggestionMenu"]["Loader"]
>((props, ref) => {
const {
className,
children, // unused, using "dots" instead
...rest
} = props;
const { className, ...rest } = props;

assertEmpty(rest);

return <MantineLoader className={className} type="dots" ref={ref} />;
return (
<MantineLoader className={className} type="dots" size={16} ref={ref} />
);
});
3 changes: 1 addition & 2 deletions packages/react/src/editor/ComponentsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export type ComponentProps = {
};
Loader: {
className?: string;
children?: ReactNode;
};
};
GridSuggestionMenu: {
Expand Down Expand Up @@ -360,7 +359,7 @@ export type Components = {
};

export const ComponentsContext = createContext<Components | undefined>(
undefined
undefined,
);

export function useComponentsContext(): Components | undefined {
Expand Down
Loading
Loading