Skip to content

Commit

Permalink
Update Listbox, Menu, ComboBox and Dropdown to use --salt-palette-cor…
Browse files Browse the repository at this point in the history
…ner when their corners are rounded and add 1px visual offset on floating panels
  • Loading branch information
joshwooding committed Jul 11, 2024
1 parent 7ea886e commit 0ff85dc
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/great-pens-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@salt-ds/core": minor
---

- Updated `Listbox`, `Menu`, `ComboBox` and `Dropdown` to use `--salt-palette-corner` when their corners are rounded.
- Updated `Menu`, `Dropdown` and `ComboBox` to have a 1px visual offset on floating panels.
2 changes: 2 additions & 0 deletions packages/core/src/combo-box/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
} from "../utils";
import comboBoxCss from "./ComboBox.css";
import { type UseComboBoxProps, useComboBox } from "./useComboBox";
import {offset} from "@floating-ui/dom";

export type ComboBoxProps<Item = string> = {
/**
Expand Down Expand Up @@ -177,6 +178,7 @@ export const ComboBox = forwardRef(function ComboBox<Item>(
placement: "bottom-start",
strategy: "fixed",
middleware: [
offset(1),
size({
apply({ rects, elements, availableHeight }) {
Object.assign(elements.floating.style, {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
useId,
} from "../utils";
import dropdownCss from "./Dropdown.css";
import {offset} from "@floating-ui/dom";

export type DropdownProps<Item = string> = {
/**
Expand Down Expand Up @@ -217,6 +218,7 @@ export const Dropdown = forwardRef(function Dropdown<Item>(
onOpenChange: handleOpenChange,
placement: "bottom-start",
middleware: [
offset(1),
size({
apply({ rects, elements, availableHeight }) {
Object.assign(elements.floating.style, {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/list-box/ListBox.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
isolation: isolate;
position: relative;
max-height: inherit;
border-radius: var(--salt-palette-corner-weak, 0);
border-radius: var(--salt-palette-corner, 0);
}

.saltListBox-bordered {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/menu/MenuBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function MenuBase(props: MenuBaseProps) {
(isNested || getVirtualElement ? "right-start" : "bottom-start"),
middleware: [
// Align the nested menu by shifting it by var(--salt-size-border)
offset(isNested ? { crossAxis: -1 } : {}),
offset(isNested ? { crossAxis: -1, mainAxis: 2 } : 1),
flip({}),
shift({ limiter: limitShift() }),
size({
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/menu/MenuPanel.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
z-index: var(--salt-zIndex-flyover);
box-shadow: var(--salt-overlayable-shadow-popout);
box-sizing: border-box;
border-radius: var(--salt-palette-corner, 0);
}

.saltMenuPanel-container {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/option/OptionList.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.saltOptionList {
background: var(--salt-container-primary-background);
border: var(--salt-size-border) var(--salt-selectable-borderStyle-selected) var(--salt-selectable-borderColor-selected);
border-radius: var(--salt-palette-corner-weak, 0);
border-radius: var(--salt-palette-corner, 0);
overflow: hidden;
overflow-y: auto;
position: relative;
Expand Down

0 comments on commit 0ff85dc

Please sign in to comment.