Commit Graph

288 Commits

Author SHA1 Message Date
Antonio Scandurra
bdf6e8bcc7 Merge remote-tracking branch 'origin/main' into editor2-paint 2023-11-07 13:09:48 +01:00
Nate Butler
99a57d922f
Add theme importer (#3246)
[[PR Description]]

Thanks @maxdeviant for all the help with this one 🫂 

- Adds the `theme_importer` crate
- Adds the ability to import themes in VSCode Format.
- Adds the `assets/themes/src` folder with source files for imported
themes
- Adds an initial set of themes: `andromeda`, `ayu`, `dracula`,
`gruvbox`, `night-owl`, `noctis`, `palenight`, `rose-pine`, `solarized`,
`synthwave-84`.

From the README:

## Usage

- `cargo run -p theme_importer` - Import the context of
`assets/themes/src`

---

## Troubleshooting

As the importer generates rust files, you may need to manually do some
cleanup in `registry.rs` and `themes/mod.rs` if you remove themes or
delete the `themes` folder in the theme crate.

---

## Required Structure

To import a theme or series of themes 3 things are required:

- `family.json`: A JSON file containing the theme family metadata and
list of theme variants
- `{theme_name}.json`: One theme json for each theme variant
- `LICENSE`: A license file for the theme family

### `family.json`

#### `name`

The name of the theme family. Avoid special characters.

This will be used for the theme family directory name (lowercased) and
the theme family name in the Zed UI.

Good:

- `Rose Pine`
- `Synthwave 84`
- `Monokai Solarized`

Bad:

- `Rosé Pine`
- `Synthwave '84`
- `Monokai (Solarized)`

#### `author`

The author of the theme family. This can be a name or a username.

This will be used for the theme family author in the Zed UI.

#### `themes`

A list of theme variants.

`appearance` can be either `light` or `dark`. This will impact which
default fallback colors are used, and where the theme shows up in the
Zed UI.

### `{theme_name}.json`

Each theme added to the family must have a corresponding JSON file. This
JSON file can be obtained from the VSCode extensions folder (once you
have installed it.) This is usually located at `~/.vscode/extensions`
(on macOS).

You can use `open ~/.vscode/extensions` to open the folder in Finder
directly.

Copy that json file into the theme family directory and tidy up the
filenames as needed.

### `LICENSE`

A LICENSE file is required to import a theme family. Failing to provide
a complete text license will cause it to be skipped when the import is
run.

If the theme only provices a license code (e.g. MIT, Apache 2.0, etc.)
then put that code into the LICENSE file.

If no license is provided, either contact the theme creator or don't add
the theme.

---

### Complete Example:

An example family with multiple variants:

```json
{
  "name": "Ayu",
  // When both name and username are available
  // prefer the `username (name)` format
  "author": "dempfi (Ike Ku)",
  "themes": [
    {
      "name": "Ayu Light",
      "file_name": "ayu-light.json",
      "appearance": "light"
    },
    {
      "name": "Ayu Mirage",
      "file_name": "ayu-mirage.json",
      "appearance": "dark"
    },
    {
      "name": "Ayu Dark",
      "file_name": "ayu-dark.json",
      "appearance": "dark"
    }
  ]
}
```

An example single variant family:

```json
{
  "name": "Andromeda",
  "author": "Eliver Lara (EliverLara)",
  "themes": [
    {
      "name": "Andromeda",
      "file_name": "andromeda.json",
      "appearance": "dark"
    },
    {
      "name": "Andromeda Bordered",
      "file_name": "andromeda-bordered.json",
      "appearance": "dark"
    }
  ]
}
```


Release Notes:

- N/A
2023-11-06 16:08:05 -05:00
Conrad Irwin
496518f3e8 Use gpui instead of gpui2 consistenytly 2023-11-06 11:50:33 -07:00
Conrad Irwin
eb325fb387
editor2 rendering (#3244)
- Make tab bar visible
- Fix tab text colors
- Ensure panes cover the available space
- Make the close button close
- Fix bug when unsubscribe called after remove
- WIP: start on editor element
- Add hover behaviour to tabs
- Add PointingHand on tabs
- gpui2: Add on_hover events
- Tooltip on tabs
- MOAR TOOLTIPS
- Use an `IconButton` for the tab close button
- Remove unneeded type qualification
- Tooltips in mouse event handler & fix executor timer
- Move more tooltip logic into gpui2 & fix tooltip moving on paint
- Update tooltip code a bit
- Allow multiple subscriptions from one entity handle

Release Notes:

- N/A
2023-11-06 11:29:42 -07:00
Marshall Bowers
d224f511fa
Add interactivity to Checkbox component (#3240)
This PR adds interactivity to the `Checkbox` component.

They can now be checked and unchecked by clicking them.

Release Notes:

- N/A
2023-11-06 13:22:25 -05:00
Conrad Irwin
c59817cd72 Merge branch 'main' into editor2-rendering 2023-11-06 11:06:43 -07:00
Conrad Irwin
3afdeeac1e
tooltip2 (#3237)
- Fix executor.timer() in gpui2
- Add support for tooltips 

[[PR Description]]

Release Notes:

- N/A
2023-11-06 10:51:01 -07:00
Marshall Bowers
f8504c349c Merge branch 'main' into import-theme 2023-11-06 12:08:46 -05:00
Marshall Bowers
bf80c1da5b
Rename fields in ThemeColors (#3242)
This PR applies a number of field renames in the `ThemeColors` struct
from the `import-theme` branch.

This will help prevent this branch from diverging too far from `main`.

Release Notes:

- N/A

---------

Co-authored-by: Nate Butler <iamnbutler@gmail.com>
Co-authored-by: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
2023-11-06 11:53:27 -05:00
Nate Butler
1bce5dcc69 Add checkboxes and their stories 2023-11-05 01:06:41 -05:00
Nate Butler
b125cc279f Simplify toggle, do some reorganization 2023-11-04 11:24:31 -04:00
Conrad Irwin
de5458cfe0 Update tooltip code a bit
This fixes a tiny UX bug where the tooltip would appear to move if you
hovered over an element, then moved your mouse out and back within
500ms.

The fix is to retain the task, so we can drop it to cancel it when the
mouse leaves.

Also changes the time we construct the tooltip to the time it first
shows.
2023-11-03 21:40:28 -06:00
Julia
4725cd2cd6 Move more tooltip logic into gpui2 & fix tooltip moving on paint
Co-Authored-By: Conrad Irwin <conrad@zed.dev>
2023-11-03 18:37:15 -04:00
Nate Butler
b0d202ba5e Merge branch 'main' into add-ui-docs 2023-11-03 18:20:17 -04:00
Nate Butler
9ce7199d2d Add some initial docs 2023-11-03 18:19:54 -04:00
Julia
3834e26f71 Tooltips in mouse event handler & fix executor timer
Co-Authored-By: Conrad Irwin <conrad@zed.dev>
2023-11-03 18:02:58 -04:00
Marshall Bowers
76db100d11
ui2: Reorganize components (#3228)
This PR reorganizes the components in the `ui2` crate.

The distinction between "elements" and "components" is now gone, with
all of the reusable components living under `components/`.

The components that we built while prototyping but will eventually live
in other crates currently reside in the `to_extract/` module.

Release Notes:

- N/A
2023-11-03 17:34:11 -04:00
Nate Butler
d500b01aed Add docs burndown list
Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
2023-11-03 16:37:22 -04:00
Marshall Bowers
1361b61708 Use an IconButton for the tab close button 2023-11-03 16:36:02 -04:00
Nate Butler
740e2cc5bf Start on ui root doc
Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
2023-11-03 16:28:54 -04:00
Conrad Irwin
33245d119e Tooltip on tabs
Co-Authored-By: Julia <julia@zed.dev>
2023-11-03 14:02:46 -06:00
Conrad Irwin
c604a2e34e Add hover behaviour to tabs
Co-Authored-By: Marshall <marshall@zed.dev>
Co-Authored-By: Nathan <nathan@zed.dev>
2023-11-03 10:55:07 -06:00
Nate Butler
b4e2368943 Merge branch 'main' into import-theme 2023-11-02 20:16:09 -04:00
Nate Butler
2b0c959137 Add terminal colors to ThemeColors, add _background to some color names. 2023-11-02 19:53:52 -04:00
Nathan Sobo
29d8390743 Fix formatting 2023-11-02 12:28:58 -06:00
Nathan Sobo
1dd20d4c0a Merge remote-tracking branch 'origin/main' into gpui2-image-reborrow 2023-11-02 12:25:06 -06:00
Marshall Bowers
0e1d2fdf21 Checkpoint: Narrow down error 2023-11-02 12:47:06 -04:00
Marshall Bowers
66e4d75e6f Checkpoint: Reproduction with Avatar story 2023-11-02 12:34:40 -04:00
Nate Butler
6f41a77a25 Document format_distance
Adds docs for:
- distance_in_seconds
- distance_string
- naive_format_distance
- naive_format_distance_from_now
2023-11-02 11:53:20 -04:00
Marshall Bowers
ec0cff0e1a
Add map method to Components (#3210)
This PR adds a `map` method to the `Component` trait.

`map` is a fully-generalized form of `when`, as `when` can be expressed
in terms of `map`:

```rs
div().map(|this| if condition { then(this) } else { this })
```

This allows us to take advantage of Rust's pattern matching when
building up conditions:

```rs
// Before
div()
    .when(self.current_side == PanelSide::Left, |this| this.border_r())
    .when(self.current_side == PanelSide::Right, |this| {
        this.border_l()
    })
    .when(self.current_side == PanelSide::Bottom, |this| {
        this.border_b().w_full().h(current_size)
    })

// After
div()
    .map(|this| match self.current_side {
        PanelSide::Left => this.border_r(),
        PanelSide::Right => this.border_l(),
        PanelSide::Bottom => this.border_b().w_full().h(current_size),
    })
```

Release Notes:

- N/A
2023-11-02 11:39:40 -04:00
Nate Butler
d4db7a14b3 Remove unused import 2023-11-02 11:04:04 -04:00
Nate Butler
3b91a76159 Merge branch 'main' into n/t2 2023-11-02 11:02:55 -04:00
Nate Butler
d48ec7d58e Remove unused import 2023-11-02 11:02:46 -04:00
Nate Butler
6d562aaa6f Use naive_format_distance_from_now in Notifications 2023-11-02 11:02:17 -04:00
Nate Butler
b76c117979 Update naive_format_distance and tests 2023-11-02 10:37:33 -04:00
Nate Butler
cde7b244bc Checkpoint - impl format_distance 2023-11-02 10:11:25 -04:00
Nathan Sobo
db9ccd7f34 Merge remote-tracking branch 'origin/main' into gpui2-no-send 2023-11-01 21:10:31 -06:00
Nathan Sobo
53066df522 Get project2 tests green 2023-11-01 20:14:40 -06:00
Nate Butler
d0975aacac Merge branch 'main' into n/t2 2023-11-01 16:52:43 -04:00
Nate Butler
229ba0744e Add additional notifications and style tweaks
Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
2023-11-01 16:50:59 -04:00
Nate Butler
be3cc6458c Implement Notifications
Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
2023-11-01 16:34:42 -04:00
Nate Butler
3f74f75dee WIP 2023-11-01 16:19:49 -04:00
Marshall Bowers
b910bbf002
Add ui_font_size setting (#3199)
This PR adds a new `ui_font_size` setting that can be used to control
the scale of the entire UI.

We use the value in this setting to set the base rem size of the window.

Release Notes:

- N/A
2023-11-01 13:11:12 -04:00
Nate Butler
8dafd5f1f3 Allow ListHeader to take a meta 2023-11-01 12:43:25 -04:00
Marshall Bowers
3189cd779e Remove unused impl 2023-11-01 10:52:25 -04:00
Nate Butler
3bcc2fa17b Update notifications panel 2023-11-01 02:10:23 -04:00
Nate Butler
bfb1f5ecf0 Continue refining theme, update tabs & tab bar 2023-11-01 01:41:33 -04:00
Nate Butler
0efd69c60f Refine default colors 2023-11-01 00:51:57 -04:00
Marshall Bowers
18431051d9
Rework theme2 with new theme structure (#3194)
This PR reworks the theme definition in the `theme2` crate to be based
off of the new theme work that @iamnbutler has been working on.

We're still developing the new theme system, but it is complete enough
that we can now load the default theme and use it to theme the storybook
(albeit with some further refining of the color palette required).

---------

Co-authored-by: Nate Butler <iamnbutler@gmail.com>
Co-authored-by: Marshall Bowers <marshall@zed.dev>
2023-10-31 22:23:00 -04:00
Max Brunsfeld
30dffbb409 Introduce a Render trait, make views implement it
Don't pass a render function separately from the view.

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Antonio <as-cii@zed.dev>
2023-10-30 15:19:40 -07:00