Commit graph

1458 commits

Author SHA1 Message Date
Jason Lee
2dbfba3490
popover: Improve Popover API. (#1545)
- Add `open`, `on_open_change` method to control open state.
- Add `default_open` method.

## Break Change

This PR to rewrite the API of Popover API to make it easy to use. 

- The `content` method now can receive an element directly.

```diff
- .content(|window, cx| {
-     cx.new(|cx| {
-         PopoverContent::new(window, cx, |_, _| {
-             div().child("This popover content.")
-         })
-     })
- })
+ .content(|state, window, cx| {
+     div().child("This popover content.")
+ })
```

- And you can also just use `child` and `children` to add child
elements.

```rs
Popover::new("my-popover")
    .trigger(Button::new("trigger").label("Open Popover"))
    .child("This popover content.")
```

- Removed `PopoverContent`, and changed `Popover` default paddings to
`p_3`.
2025-11-11 17:45:30 +08:00
Floyd Wang
13f25bc4a9
progress: Fix incorrect border radius (#1555)
| Before | After |
| - | - |
| <img width="848" height="274" alt="SCR-20251111-nduc"
src="https://github.com/user-attachments/assets/e04590a3-6154-41f6-9763-a7de7db2301e"
/> | <img width="821" height="272" alt="SCR-20251111-ndpb"
src="https://github.com/user-attachments/assets/04ba2e28-0c7f-4205-b8b5-cc79b661ecef"
/> |
2025-11-11 06:53:50 +00:00
ihavecoke
1a5dd46acd
tiles: Add to support panel auto-snap while drag movement (#1552)
Before: 


https://github.com/user-attachments/assets/b9171a47-e21b-4132-8b13-7d9bf06f083a

After:


https://github.com/user-attachments/assets/e06c8353-41f8-4124-b9f4-1c44e462ab72
2025-11-11 11:56:58 +08:00
Floyd Wang
74f23bfca8
tab: Refactor creation to use builder pattern (#1553)
## Breaking change

```diff
- Tab::new("Account")
+ Tab::new().label("Account")
```

We can currently create a tab item without a label, such as only an
icon.
2025-11-11 10:35:00 +08:00
FlyingYu
9228dbfb13
editor: Improve double-click for word selection (#1491)
Close #876 

https://github.com/user-attachments/assets/bb04b3ab-05ca-456c-bb14-b812a846701d

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-10 05:02:02 +00:00
Nico Gründel
2cba6e8be9
slider: Add option to choose between linear and logarithmic scale (#1543)
Adds the ability to choose between a linear and a logarithmic scale for
the slider. A logarithmic scale is the right and intuitive choice for
many different slider applications. Building this right into the
component has two advantages:
- The user doesn't have to convert at every point where they might use
or update the slider value
- On a logarithmic scale, the distance between steps varies over the
sliders range. This implementation respects that

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-10 02:56:09 +00:00
Moulberry
a4d792f121
button_group: Fix overriding button click when no on_click (#1546)
When `on_click` is not specified on the button group, this PR allows for
specifying on_click on each individual button.

e.g.

```rs
let buttons = ButtonGroup::new(("buttons", index)).layout(Axis::Vertical)
    .child(Button::new(("install", index)).label("Install").icon(download_icon).success().on_click(move |_, _, cx| {
          // Install
    })
    .child(Button::new(("open", index)).label("Open Page").icon(IconName::Globe).info().on_click(move |_, _, cx| {
         // Open page
    }));
```
2025-11-10 09:43:25 +08:00
Nico Gründel
b899100d09
slider: Improve Slider interaction to click on bar to drag. (#1544)
This pull request adds a drag event to the slider bar itself, analogous
to the drag handles, in case the slider is not a range slider. This
allows for a more intuitive interaction with the slider, where one can
click and drag on any part of the slider bar container.

https://github.com/user-attachments/assets/4d41ba10-2992-4a42-beb6-0bc376185c5e

This doesn't change the behavior for range sliders, as it's ambiguous
which slider should be dragged in case the event starts between the
sliders. Though if desired, it wouldn't be difficult to implement the
same behavior for clicks below the start or above the end slider.
2025-11-09 11:31:21 +08:00
Jason Lee
a2c55dda46
form: Rename FormField to Field. (#1539) 2025-11-07 18:43:01 +08:00
Jason Lee
945db0be56
dialog: Rename Modal to Dialog. (#1538)
## Break Change

- Renamed `Modal` to `Dialog`.

```diff
- window.open_modal(...)
+ window.open_dialog(...)

- window.close_modal(...);
+ window.close_dialog(...);
```

- Renamed `show_close` method to `close_button` in Dialog.
```diff
- .show_close(false)
+ .close_button(true)
```
2025-11-07 17:25:55 +08:00
Moulberry
c78811c4b9
button_group: Add vertical (#1537)
Adds a vertical option to the button group

Also added an example of the vertical button group to the story

Also fixed button rounding only working when both tl/bl and tr/br are
both set, now they can be set individually

I'm not sure if the justify_center in `.when(self.vertical, |this|
this.flex_col().justify_center())` is needed, but I added it to match
the behaviour of `.items_center()` when the flex direction is row.
2025-11-07 16:48:14 +08:00
Jason Lee
001107438f
story: Add lazy load option to List story. (#1535) 2025-11-06 15:23:45 +00:00
Jason Lee
89041f9ab8
docs: Update version to v0.4.0-preview1 in docs. (#1534) 2025-11-06 22:35:38 +08:00
Jason Lee
34c589d45b Bump v0.4.0-preview1. 2025-11-06 22:27:26 +08:00
obito
80cdf6a44c
theme: Allows to use alpha color for active_border but at least 0.3. (#1531)
Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-06 22:23:55 +08:00
Moulberry
7f8eb28cfa
table: Fix missing border on first frame (#1533)
After all the adjustments, the original issue that
https://github.com/longbridge/gpui-component/pull/1505 was trying to fix
reappeared.

The fix is simple: don't consider the table to be filled if the height
is zero.
2025-11-06 22:01:55 +08:00
Moulberry
faee91eda4
table: fix row border missing on first frame (#1505)
Currently, the bounds are zero on the first frame.
Therefore, the extra_rows_count will always be zero on the first frame.
This causes rendering issues for row border & row stripes.

Unfortunately, I don't know how to get the correct height on the first
frame to fix the row stripes.

However, an easy fix for the row border rendering issue is to disable
the table_is_filled check. The check is problematic anyways since the
border affects the height of the element.

I attached a video showing the issue, the border doesn't render on the
first frame and the height of the element also shifts due to the border:


https://github.com/user-attachments/assets/b154c686-cd9c-4b6b-8ba6-c79640297abc

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-06 21:15:13 +08:00
Jason Lee
97ba18fce9
modal: Adjust close button position. (#1532) 2025-11-06 13:10:49 +00:00
Jason Lee
34aa68ad35
table: Fix Table stripe mode overflow scroll. (#1530)
Ref #1505
2025-11-06 19:11:28 +08:00
Floyd Wang
f33d112819
button: Remove duplicate disabled style (#1529) 2025-11-06 18:47:59 +08:00
Jason Lee
80689264e2
sheet: Rename Drawer to Sheet. (#1527)
## Break Change

- Renamed `Drawer` to `Sheet`, also renamed relative method contains
`drawer` to `sheet`.
- Renamed `ContextModal` to `WindowExt`.

```diff
- use gpui_component::drawer::Drawer
+ use gpui_component::sheet::Sheet

- use gpui_component::ContextModal
+ use gpui_component::WindowExt
```
2025-11-06 07:19:10 +00:00
Jason Lee
4dc10165fb
spinner: Rename Indicator to Spinner. (#1526)
## Break Change

- Renamed `Indicator` to `Spinner`.

```diff
- use gpui_component::indicator::Indicator;
+ use gpui_component::spinner::Spinner;
```
2025-11-06 11:36:39 +08:00
Jason Lee
c06e91101e
collapsible: Add Collapsible. (#1525)
Close #1479 

<img width="1171" height="791" alt="image"
src="https://github.com/user-attachments/assets/eac5cd9f-ef8c-4eb4-b93d-f63c9302c99a"
/>
2025-11-06 10:57:18 +08:00
Jason Lee
4b3fb51fb8
editor: Fix indent guides render position. (#1524) 2025-11-05 13:17:32 +00:00
Jason Lee
998a5fd922
chore: Standardize the overall API and improve docs. (#1516) 2025-11-05 19:10:30 +08:00
Jason Lee
2ba0dfbb96
popover: Renamed no_style to appearance like the Input. (#1523)
## Break Change

- The `no_style` method has been removed, use `appearance` instead.
2025-11-05 08:01:27 +00:00
Jason Lee
469b53178b
form: Renamed column to columns. (#1522)
## Break Change

- Renamed `column` to `columns` and receive `usize` type.
2025-11-05 07:32:15 +00:00
Jason Lee
aea8223637
description_list: Renamed child to item, and add child to add DescriptionItem. (#1521)
## Break Change

- The original `child` method has been renamed to `item`.
- Now the add new `child` to accept a `DescriptionItem` type like the
`children` method.
2025-11-05 07:26:17 +00:00
Jason Lee
2093046942
clipboard: Removed content method from Clipboard. (#1520)
## Break Change

- The `content` method has been removed from `Clipboard`, if you want
display something, you can wrap it in a h_flex.
2025-11-05 07:17:58 +00:00
Jason Lee
d3ec1f29f8
breadcrumb: Rename item to child and add children method. (#1519) 2025-11-05 15:13:29 +08:00
Jason Lee
b08f5be97c
radio: Rename on_change to on_click for RadioGroup. (#1517)
## Break Change

- Renamed `on_change` to `on_click` for RadioGroup.
 
```diff
- RadioGroup::horizontal("radio_group_1").on_change(...)
+ RadioGroup::horizontal("radio_group_1").on_click(...)
```
2025-11-05 02:53:22 +00:00
Jason Lee
0524c51b3e
toggle: Refactor Toggle, ToggleGroup API. (#1515)
## Break Changes

- Refactor `Toggle` new API to require a `id`, and renamed `on_change`
to `on_click.
- Renamed `on_change` method to `on_click` for `ToggleGroup`.

```diff
- Toggle::label("Hello").id("hello").on_change(..)
+ Toggle::new("hello).label("Hello").on_click(..)

- ToggleGroup::new("group1).on_change(..)
+ ToggleGroup::new("group1).on_click(..)
```
2025-11-05 10:47:55 +08:00
Moulberry
a4e93132f1
input, select, date_picker: Refactor cleanable to have argument and default to false. (#1506)
https://github.com/longbridge/gpui-component/pull/1502#issuecomment-3485354324

## Break Change

- The `DatePicker` and `Select` has changed `cleanable` default from
`true` to `false`.
- Updated `Input`, `DatePicker` and `Select` the `cleanable` to have a
argument.

```diff
- pub fn cleanable(mut self)
+ pub fn cleanable(mut self, cleanable: bool)
```

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-05 09:33:31 +08:00
Jason Lee
522f3ced43
docs: Fix footer and add note to home page. (#1511)
Ref https://github.com/longbridge/gpui-component/discussions/1509
2025-11-04 23:07:33 +08:00
Jason Lee
4b8775f7d3
chore: Remove unused image example. (#1510)
Close #1494
2025-11-04 14:55:02 +00:00
Jason Lee
5f39b99fe4
list: Avoid select item when selectable(false). (#1508)
Close #1500
2025-11-04 14:12:31 +00:00
Jason Lee
d037f074dc
chore: Move searchable to ListState and SelectState. (#1507) 2025-11-04 21:26:11 +08:00
Jason Lee
087cb70d00
select, list: Update searchable default to false. (#1504)
Continue #1503 to update the `searchable` default to `false`.
2025-11-04 20:59:38 +08:00
Jason Lee
2870bc6e36
list: Add searchable, search_placeholder option to List and Select. (#1503)
## Break Change

- Removed `set_query_input`, `query_input` and `no_query` method from
List. Now use `List::new(&state).searchable(false)` to intead of
`no_query`.
- Removed `searchable` method from `SelectDelegate`, use
`Select::searchable` instead.
2025-11-04 19:06:50 +08:00
Floyd Wang
27f1f960a0
select: Restore the selection when canceling (#1501)
Fix #1495
2025-11-04 10:22:00 +00:00
Jason Lee
3a9198b5de chore: Hard link crates/ui/LICENSE-APACHE. 2025-11-04 17:54:14 +08:00
ihavecoke
fbaddbe9e3
tiles: Add scrollbar_show option to Tiles (#1496) 2025-11-04 17:42:46 +08:00
Jason Lee
b7815ed6ec
table: Keep scroll to item at bottom when move down. (#1499) 2025-11-04 09:28:37 +00:00
Floyd Wang
2e5bdd0c3a
list: Fix incorrect next selection when select index is none (#1498)
Previously, pressing next would select the second item.
2025-11-04 17:17:17 +08:00
Moulberry
e7aa8983dc
input: Delete selected text with modifier keys (#1497)
In most applications, when text is selected and backspace/delete is
pressed, the selection is simply deleted.

Currently, gpui-component will ignore the selected text and delete the
previous/next word when Ctrl is pressed.

This can be very confusing especially if you do ctrl+a then
ctrl+backspace, expecting the input to be cleared.

This PR makes it so that if there is an active selection, the active
selection is deleted before doing any extra processing.
2025-11-04 16:54:31 +08:00
Jason Lee
893e323692
Fix state internal update to refresh for List, Tree, Table and Select. (#1492)
This to fix #1468, #1449 changes broken the state (e.g.: `SelectState`
to call `cx.notify()`) update not notify parent element (e.g.: `Select`)
to rerender.
2025-11-04 16:25:37 +08:00
Jason Lee
f6bbef0082
docs: Update docs website style. (#1488) 2025-11-03 22:18:18 +08:00
Jason Lee
faee23eef8
table: Change context_menu method in TableDelegate to mutable window and cx. (#1487)
## Break Change

- The `window`, `cx` has changed from `&Window`, `&App` to `&mut
Window`, `&mut App`.

```diff
- fn context_menu(&self, row_ix: usize, menu: PopupMenu, window: &Window, cx: &App)
+ fn context_menu(&self, row_ix: usize, menu: PopupMenu, window: &mut Window, cx: &mut App)
```
2025-11-03 18:06:29 +08:00
FlyingYu
be460dcbed
modal, drawer: Block background interaction when Modal, Drawer is active. (#1483)
Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-03 16:51:38 +08:00
Floyd Wang
3d606a6909
select: Avoid reopen menu when clearing selection (#1484) 2025-11-03 08:24:54 +00:00