From acabaf32c8faa9ca5eb8c54c5ac4a7e8cfb8e088 Mon Sep 17 00:00:00 2001 From: ihavecoke Date: Tue, 3 Sep 2024 23:31:34 +0800 Subject: [PATCH] Correcting shacn to shadcn to uniformly use shadcn ui names (#210) * Fixed some color naming with shadcn style * Input story support scroll y --- crates/story/src/input_story.rs | 18 ++++++++++-------- crates/ui/src/colors.rs | 16 ++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/crates/story/src/input_story.rs b/crates/story/src/input_story.rs index e58c9488..c8d81d49 100644 --- a/crates/story/src/input_story.rs +++ b/crates/story/src/input_story.rs @@ -1,20 +1,20 @@ -use gpui::{ - actions, div, px, AppContext, FocusHandle, InteractiveElement, IntoElement, KeyBinding, - ParentElement as _, Render, SharedString, Styled, View, ViewContext, VisualContext, - WindowContext, -}; +use gpui::{actions, div, px, AppContext, FocusHandle, InteractiveElement, IntoElement, KeyBinding, ParentElement as _, Render, SharedString, Styled, View, ViewContext, VisualContext, WindowContext}; +use crate::section; use ui::{ button::Button, checkbox::Checkbox, h_flex, input::{InputEvent, OtpInput, TextInput}, prelude::FluentBuilder as _, - v_flex, FocusableCycle, IconName, Sizable, + scroll::ScrollbarAxis, + v_flex, + FocusableCycle, + IconName, + Sizable, + StyledExt, }; -use crate::section; - actions!(input_story, [Tab, TabPrev]); const CONTEXT: &str = "InputStory"; @@ -207,6 +207,8 @@ impl Render for InputStory { fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { v_flex() .key_context(CONTEXT) + .id("input-story") + .scrollable(cx.entity_id(), ScrollbarAxis::Vertical) .on_action(cx.listener(Self::tab)) .on_action(cx.listener(Self::tab_prev)) .size_full() diff --git a/crates/ui/src/colors.rs b/crates/ui/src/colors.rs index 07b9da99..3d1c0d5c 100644 --- a/crates/ui/src/colors.rs +++ b/crates/ui/src/colors.rs @@ -55,18 +55,18 @@ impl ColorExt for Hsla { } } -pub(crate) static DEFAULT_COLOR: once_cell::sync::Lazy = +pub(crate) static DEFAULT_COLOR: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { serde_json::from_str(include_str!("../default-colors.json")) .expect("failed to parse default-json") }); -type ColorScales = HashMap; +type ColorScales = HashMap; mod color_scales { use std::collections::HashMap; - use super::{ColorScales, ShacnColor}; + use super::{ColorScales, ShadcnColor}; use serde::de::{Deserialize, Deserializer}; @@ -75,7 +75,7 @@ mod color_scales { D: Deserializer<'de>, { let mut map = HashMap::new(); - for color in Vec::::deserialize(deserializer)? { + for color in Vec::::deserialize(deserializer)? { map.insert(color.scale, color); } Ok(map) @@ -83,9 +83,9 @@ mod color_scales { } #[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)] -pub(crate) struct ShacnColors { - pub(crate) black: ShacnColor, - pub(crate) white: ShacnColor, +pub(crate) struct ShadcnColors { + pub(crate) black: ShadcnColor, + pub(crate) white: ShadcnColor, #[serde(with = "color_scales")] pub(crate) slate: ColorScales, #[serde(with = "color_scales")] @@ -133,7 +133,7 @@ pub(crate) struct ShacnColors { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Deserialize)] -pub(crate) struct ShacnColor { +pub(crate) struct ShadcnColor { #[serde(default)] pub(crate) scale: usize, #[serde(deserialize_with = "from_hsa_channel", alias = "hslChannel")]