introduce typography system and motion module

This commit is contained in:
2026-10-09 19:54:08 +07:00
parent 41e991dd30
commit df411bd044
53 changed files with 1116 additions and 457 deletions
+6 -6
View File
@@ -3,7 +3,7 @@ use gpui::{
relative,
};
use nip29::{Group, GroupMetadata};
use theme::{ActiveTheme, control_radius};
use theme::{ActiveTheme, TextStyle, Typeset as _, control_radius};
use ui::avatar::Avatar;
use ui::{Sizable, StyledExt, WindowExtension, h_flex, v_flex};
@@ -22,7 +22,7 @@ fn body(group: &WeakEntity<Group>, cx: &App) -> AnyElement {
};
let group = entity.read(cx);
let mut body = v_flex().gap_3().text_sm().child(header(group, cx));
let mut body = v_flex().gap_3().text_style(TextStyle::Callout).child(header(group, cx));
if let Some(metadata) = group.metadata() {
if let Some(about) = metadata.about.as_ref() {
@@ -137,14 +137,14 @@ fn header(group: &Group, cx: &App) -> AnyElement {
.min_w_0()
.child(
div()
.text_base()
.text_style(TextStyle::Body)
.font_semibold()
.truncate()
.child(group.display_name()),
)
.child(
div()
.text_xs()
.text_style(TextStyle::Caption)
.text_color(cx.theme().text_faint)
.truncate()
.child(SharedString::from(format!(
@@ -162,7 +162,7 @@ fn section(label: &'static str, content: AnyElement, cx: &App) -> AnyElement {
.gap_1()
.child(
div()
.text_xs()
.text_style(TextStyle::Caption)
.font_medium()
.text_color(cx.theme().text_muted)
.child(label),
@@ -186,7 +186,7 @@ fn chip(label: impl Into<SharedString>, cx: &App) -> AnyElement {
.rounded(px(control_radius()))
.bg(cx.theme().surface_raised)
.text_color(cx.theme().text)
.text_xs()
.text_style(TextStyle::Caption)
.line_height(relative(1.))
.child(label.into())
.into_any_element()
+2 -2
View File
@@ -5,7 +5,7 @@ use gpui::{
};
use nip29::Group;
use nostr_sdk::prelude::SecretKey;
use theme::ActiveTheme;
use theme::{ActiveTheme, TextStyle, Typeset as _};
use ui::dialog::DialogButtonProps;
use ui::input::InputState;
use ui::notification::Notification;
@@ -40,7 +40,7 @@ pub(crate) fn open(group: WeakEntity<Group>, window: &mut Window, cx: &mut App)
.child(
v_flex().gap_3().child(
div()
.text_sm()
.text_style(TextStyle::Callout)
.text_color(cx.theme().text_muted)
.child("Share the code with whoever should be able to join. The relay must accept it."),
)
+11 -11
View File
@@ -16,7 +16,7 @@ use serde::Deserialize;
use settings::AppSettings;
use smallvec::{SmallVec, smallvec};
use state::{NostrRegistry, upload};
use theme::{ActiveTheme, control_radius};
use theme::{ActiveTheme, TextStyle, Typeset as _, control_radius};
use ui::avatar::Avatar;
use ui::button::{Button, ButtonVariant, ButtonVariants};
use ui::dialog::DialogButtonProps;
@@ -168,7 +168,7 @@ pub fn confirm_leave(group: WeakEntity<Group>, window: &mut Window, cx: &mut App
)
.child(
div()
.text_sm()
.text_style(TextStyle::Callout)
.child("You will stop receiving messages from this group."),
)
.on_ok(move |_event, _window, cx| {
@@ -567,10 +567,10 @@ impl GroupPanel {
h_flex()
.flex_shrink_0()
.w_full()
.gap_2()
.gap(px(theme::SPACE))
.px_3()
.py_2()
.text_sm()
.text_style(TextStyle::Callout)
.border_b_1()
.border_color(cx.theme().border)
.child(
@@ -617,7 +617,7 @@ impl GroupPanel {
.py_0p5()
.rounded(px(control_radius()))
.bg(cx.theme().solid)
.text_xs()
.text_style(TextStyle::Caption)
.text_color(cx.theme().text_muted)
.child(pin_label(group, pin))
}))
@@ -695,10 +695,10 @@ impl GroupPanel {
.w_full()
.justify_center()
.items_center()
.gap_2()
.gap(px(theme::SPACE))
.px_3()
.py_2()
.text_sm()
.text_style(TextStyle::Callout)
.text_color(cx.theme().text_muted);
match notice {
@@ -880,7 +880,7 @@ impl GroupPanel {
.border_1()
.border_color(cx.theme().border_faint)
.rounded(px(control_radius()))
.text_xs()
.text_style(TextStyle::Caption)
.text_color(cx.theme().text_muted)
.child(Icon::new(IconName::Link).xsmall())
.child(
@@ -922,12 +922,12 @@ impl Panel for GroupPanel {
h_flex()
.gap_1()
.text_xs()
.text_style(TextStyle::Caption)
.child(Avatar::from_source(picture).seed(seed).xsmall())
.child(display_name(group))
.into_any_element()
})
.unwrap_or_else(|| div().text_xs().child("Unknown").into_any_element())
.unwrap_or_else(|| div().text_style(TextStyle::Caption).child("Unknown").into_any_element())
}
fn toolbar_buttons(&self, _window: &Window, _cx: &App) -> Vec<Button> {
@@ -987,7 +987,7 @@ impl Render for GroupPanel {
None => h_flex()
.size_full()
.justify_center()
.text_sm()
.text_style(TextStyle::Callout)
.text_color(cx.theme().text_faint)
.child("No messages yet")
.into_any_element(),
+6 -6
View File
@@ -9,7 +9,7 @@ use nip29::{Activity, Group};
use nostr_sdk::prelude::{EventId, Kind};
use person::PersonRegistry;
use settings::AppSettings;
use theme::{ActiveTheme, bubble_radius};
use theme::{ActiveTheme, TextStyle, Typeset as _, bubble_radius};
use ui::avatar::Avatar;
use ui::menu::{ContextMenu, PopupMenu, PopupMenuItem};
use ui::message::MessageRow;
@@ -138,7 +138,7 @@ pub(crate) fn render_activity(ix: usize, activity: &Activity, cx: &App) -> AnyEl
h_flex()
.id(ix)
.w_full()
.gap_2()
.gap(px(theme::SPACE))
.py_1()
.px_3()
.hover(|this| this.bg(cx.theme().element_hover))
@@ -155,7 +155,7 @@ pub(crate) fn render_activity(ix: usize, activity: &Activity, cx: &App) -> AnyEl
div()
.min_w_0()
.truncate()
.text_sm()
.text_style(TextStyle::Callout)
.font_semibold()
.child(subject.name()),
)
@@ -163,7 +163,7 @@ pub(crate) fn render_activity(ix: usize, activity: &Activity, cx: &App) -> AnyEl
div()
.min_w_0()
.truncate()
.text_sm()
.text_style(TextStyle::Callout)
.text_color(cx.theme().text_faint)
.child(SharedString::from(action(activity))),
)
@@ -171,7 +171,7 @@ pub(crate) fn render_activity(ix: usize, activity: &Activity, cx: &App) -> AnyEl
div()
.flex_shrink_0()
.ml_1()
.text_xs()
.text_style(TextStyle::Caption)
.text_color(cx.theme().text_faint)
.child(activity.created_at.to_ago()),
)
@@ -225,7 +225,7 @@ fn media(media: &[SharedUri], cx: &App) -> AnyElement {
.flex()
.flex_row()
.flex_wrap()
.gap_2()
.gap(px(theme::SPACE))
.children(media.iter().enumerate().map(|(ix, item)| {
div().id(format!("media-{ix}")).child(
img(item.clone())
+2 -2
View File
@@ -1,4 +1,4 @@
use gpui::{App, AppContext, Entity, ParentElement, Styled, WeakEntity, Window};
use gpui::{App, AppContext, Entity, ParentElement, Styled, WeakEntity, Window, px};
use nip29::{Group, GroupMetadata};
use ui::dialog::DialogButtonProps;
use ui::input::InputState;
@@ -73,7 +73,7 @@ pub(crate) fn open(group: WeakEntity<Group>, window: &mut Window, cx: &mut App)
.child(field("Picture", &picture, cx))
.child(
v_flex()
.gap_2()
.gap(px(theme::SPACE))
.child(
Switch::new("private")
.label("Private")
+2 -2
View File
@@ -2,7 +2,7 @@ use anyhow::Result;
use gpui::{App, Div, Entity, ParentElement, SharedString, Styled, Task, Window};
use nip29::{Group, Pin, Row};
use nostr_sdk::prelude::Url;
use theme::ActiveTheme;
use theme::{ActiveTheme, TextStyle, Typeset as _};
use ui::input::{Input, InputState};
use ui::notification::Notification;
use ui::{WindowExtension, v_flex};
@@ -52,7 +52,7 @@ pub(crate) fn opens_run(rows: &[Row], index: usize) -> bool {
pub(crate) fn field(label: &'static str, input: &Entity<InputState>, cx: &App) -> Div {
v_flex()
.gap_1()
.text_sm()
.text_style(TextStyle::Callout)
.text_color(cx.theme().text_muted)
.child(label)
.child(Input::new(input))