wip: connect to github step

This commit is contained in:
2026-04-22 22:12:39 +01:00
parent 02932411fb
commit 302d0d3222
7 changed files with 118 additions and 28 deletions

View File

@@ -0,0 +1,39 @@
use gpui::{FontWeight, ParentElement, Styled, div};
use crate::{
api,
component::text::text,
query::{self, use_lazy_query},
};
pub(crate) struct GithubStepView {
create_device_code_query: query::Entity<api::auth::CreateDeviceCode>,
}
pub(crate) fn new(cx: &mut gpui::Context<GithubStepView>) -> GithubStepView {
GithubStepView {
create_device_code_query: use_lazy_query(api::auth::CreateDeviceCode, cx),
}
}
impl gpui::Render for GithubStepView {
fn render(
&mut self,
_window: &mut gpui::Window,
cx: &mut gpui::Context<Self>,
) -> impl gpui::IntoElement {
div().flex().flex_col().size_full().child(header(cx))
}
}
fn header(cx: &gpui::Context<GithubStepView>) -> impl gpui::IntoElement {
div()
.flex()
.flex_col()
.items_center()
.child(text("Connect to GitHub", cx).font_weight(FontWeight(700.)))
.child(text(
"You will be redirected to GitHub to authorize access. Copy the device code below into GitHub.",
cx
).opacity(0.8))
}

View File

@@ -0,0 +1,5 @@
mod github_step;
mod screen;
mod welcome_step;
pub(crate) use screen::new;

View File

@@ -0,0 +1,91 @@
use gpui::{AppContext, FontWeight, IntoElement, ParentElement, Styled, div};
use crate::{
api, app,
component::text::text,
query::{self, use_lazy_query},
screen::setup_wizard::{github_step, welcome_step},
};
pub(crate) struct Screen {
current_step: Step,
}
enum Step {
Welcome,
ConnectToGithub,
}
pub(crate) fn new(cx: &mut gpui::Context<Screen>) -> Screen {
Screen {
current_step: Step::Welcome,
}
}
impl gpui::Render for Screen {
fn render(
&mut self,
_window: &mut gpui::Window,
cx: &mut gpui::Context<Self>,
) -> impl gpui::IntoElement {
let step_view = match self.current_step {
Step::Welcome => welcome_step::new(cx).into_any_element(),
Step::ConnectToGithub => cx.new(|cx| github_step::new(cx)).into_any_element(),
};
let theme = app::current_theme(cx);
div()
.flex()
.flex_row()
.items_center()
.justify_center()
.size_full()
.child(
div()
.flex()
.items_center()
.justify_center()
.w_1_3()
.h_full()
.bg(theme.colors.surface)
.relative()
.child(
text("Novem", cx)
.font_weight(FontWeight(700.))
.absolute()
.top_20()
.left_8(),
)
.child(step_list(cx)),
)
.child(
div()
.flex()
.items_center()
.justify_center()
.w_2_3()
.h_full()
.bg(theme.colors.background)
.child(step_view),
)
}
}
fn step_list(cx: &gpui::Context<impl gpui::Render>) -> impl gpui::IntoElement {
div()
.flex()
.flex_col()
.items_start()
.w_full()
.px_8()
.justify_center()
.gap_3()
.text_sm()
.children(vec![
text("Welcome!", cx),
text("Connect to GitHub", cx),
text("Customize Novem", cx),
text("Complete!", cx),
])
}

View File

@@ -0,0 +1,47 @@
use gpui::{FontWeight, ParentElement, Styled, div};
use crate::{
app,
component::{button::button, text::text},
};
struct WelcomeStep {
on_next: Option<FnOnce>,
}
pub(crate) fn new<E>(cx: &gpui::Context<E>) -> impl gpui::IntoElement {
let theme = app::current_theme(cx);
div()
.flex()
.flex_col()
.size_full()
.items_start()
.justify_center()
.child(
div()
.flex()
.flex_col()
.flex_1()
.justify_center()
.w_full()
.p_8()
.child(
text(
"Welcome to Novem!\nThis wizard will guide you through setting up Novem.\n",
cx,
)
.opacity(0.8),
)
.child(text("Press 'Next' to begin setup.", cx).font_weight(FontWeight(500.))),
)
.child(
div()
.flex()
.flex_row()
.justify_end()
.w_full()
.p_4()
.pt_0()
.child(button("next", cx).label("Next")),
)
}