center a div
This commit is contained in:
parent
acab2f9003
commit
3a85beeaa5
4 changed files with 14 additions and 14 deletions
|
@ -32,7 +32,7 @@ impl Render for GoToLine {
|
||||||
type Element = Div<Self>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
modal(cx).child(div().bg(red()).w(px(100.0)).h(px(100.0)))
|
modal(cx).child(div().m_4().bg(red()).w(px(100.0)).h(px(100.0)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use gpui::{div, hsla, point, px, BoxShadow, Div};
|
use gpui::Div;
|
||||||
|
|
||||||
use crate::{prelude::*, v_stack};
|
use crate::{prelude::*, v_stack};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use std::{any::TypeId, sync::Arc};
|
use std::{any::TypeId, sync::Arc};
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, AnyView, AppContext, Component, DispatchPhase, Div, ParentElement, Render,
|
div, hsla, px, red, AnyView, AppContext, Component, DispatchPhase, Div, ParentElement, Render,
|
||||||
StatelessInteractive, Styled, View, ViewContext,
|
StatelessInteractive, Styled, View, ViewContext,
|
||||||
};
|
};
|
||||||
|
use ui::v_stack;
|
||||||
|
|
||||||
use crate::Workspace;
|
use crate::Workspace;
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ impl ModalLayer {
|
||||||
// whatever
|
// whatever
|
||||||
|
|
||||||
pub fn render(&self, workspace: &Workspace, cx: &ViewContext<Workspace>) -> Div<Workspace> {
|
pub fn render(&self, workspace: &Workspace, cx: &ViewContext<Workspace>) -> Div<Workspace> {
|
||||||
let mut parent = div().relative();
|
let mut parent = div().relative().bg(red()).size_full();
|
||||||
|
|
||||||
for (_, action) in cx.global::<ModalRegistry>().registered_modals.iter() {
|
for (_, action) in cx.global::<ModalRegistry>().registered_modals.iter() {
|
||||||
parent = (action)(parent);
|
parent = (action)(parent);
|
||||||
|
@ -92,21 +93,20 @@ impl ModalLayer {
|
||||||
parent.when_some(self.open_modal.as_ref(), |parent, open_modal| {
|
parent.when_some(self.open_modal.as_ref(), |parent, open_modal| {
|
||||||
let container1 = div()
|
let container1 = div()
|
||||||
.absolute()
|
.absolute()
|
||||||
|
.flex()
|
||||||
|
.flex_col()
|
||||||
|
.items_center()
|
||||||
.size_full()
|
.size_full()
|
||||||
.top_0()
|
.top_0()
|
||||||
.left_0()
|
.left_0()
|
||||||
.right_0()
|
.z_index(400);
|
||||||
.bottom_0();
|
|
||||||
|
|
||||||
// transparent layer
|
// transparent layer
|
||||||
let container2 = div()
|
let container2 = v_stack()
|
||||||
.flex()
|
.bg(hsla(0.5, 0.5, 0.5, 0.5))
|
||||||
.h_96()
|
.h(px(0.0))
|
||||||
.justify_center()
|
|
||||||
.size_full()
|
|
||||||
.relative()
|
.relative()
|
||||||
.top_20()
|
.top_20();
|
||||||
.z_index(400);
|
|
||||||
|
|
||||||
parent.child(container1.child(container2.child(open_modal.clone())))
|
parent.child(container1.child(container2.child(open_modal.clone())))
|
||||||
})
|
})
|
||||||
|
|
|
@ -3710,10 +3710,10 @@ impl Render for Workspace {
|
||||||
self.modal_layer
|
self.modal_layer
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.render(self, cx)
|
.render(self, cx)
|
||||||
|
.relative()
|
||||||
.flex_1()
|
.flex_1()
|
||||||
.w_full()
|
.w_full()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_row()
|
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.border_t()
|
.border_t()
|
||||||
.border_b()
|
.border_b()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue