Simplify the lock usage (#35957)
Follow-up of https://github.com/zed-industries/zed/pull/35955 Release Notes: - N/A Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
This commit is contained in:
parent
f3d6deb5a3
commit
6bd2f8758e
1 changed files with 11 additions and 14 deletions
|
@ -2,7 +2,7 @@
|
||||||
use gpui::{Hsla, Length};
|
use gpui::{Hsla, Length};
|
||||||
use std::{
|
use std::{
|
||||||
cell::LazyCell,
|
cell::LazyCell,
|
||||||
sync::{Arc, OnceLock},
|
sync::{Arc, LazyLock, OnceLock},
|
||||||
};
|
};
|
||||||
use theme::{Theme, ThemeColors, ThemeRegistry};
|
use theme::{Theme, ThemeColors, ThemeRegistry};
|
||||||
use ui::{
|
use ui::{
|
||||||
|
@ -25,17 +25,14 @@ pub struct ThemePreviewTile {
|
||||||
style: ThemePreviewStyle,
|
style: ThemePreviewStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn child_radius() -> Pixels {
|
static CHILD_RADIUS: LazyLock<Pixels> = LazyLock::new(|| {
|
||||||
static CHILD_RADIUS: OnceLock<Pixels> = OnceLock::new();
|
inner_corner_radius(
|
||||||
*CHILD_RADIUS.get_or_init(|| {
|
ThemePreviewTile::ROOT_RADIUS,
|
||||||
inner_corner_radius(
|
ThemePreviewTile::ROOT_BORDER,
|
||||||
ThemePreviewTile::ROOT_RADIUS,
|
ThemePreviewTile::ROOT_PADDING,
|
||||||
ThemePreviewTile::ROOT_BORDER,
|
ThemePreviewTile::CHILD_BORDER,
|
||||||
ThemePreviewTile::ROOT_PADDING,
|
)
|
||||||
ThemePreviewTile::CHILD_BORDER,
|
});
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ThemePreviewTile {
|
impl ThemePreviewTile {
|
||||||
pub const SKELETON_HEIGHT_DEFAULT: Pixels = px(2.);
|
pub const SKELETON_HEIGHT_DEFAULT: Pixels = px(2.);
|
||||||
|
@ -229,7 +226,7 @@ impl ThemePreviewTile {
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.size_full()
|
.size_full()
|
||||||
.rounded(child_radius())
|
.rounded(*CHILD_RADIUS)
|
||||||
.border(Self::CHILD_BORDER)
|
.border(Self::CHILD_BORDER)
|
||||||
.border_color(theme.colors().border)
|
.border_color(theme.colors().border)
|
||||||
.child(Self::render_editor(
|
.child(Self::render_editor(
|
||||||
|
@ -257,7 +254,7 @@ impl ThemePreviewTile {
|
||||||
h_flex()
|
h_flex()
|
||||||
.size_full()
|
.size_full()
|
||||||
.relative()
|
.relative()
|
||||||
.rounded(child_radius())
|
.rounded(*CHILD_RADIUS)
|
||||||
.border(Self::CHILD_BORDER)
|
.border(Self::CHILD_BORDER)
|
||||||
.border_color(border_color)
|
.border_color(border_color)
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue