Skip to content

Conversation

@zhiyanzhaijie
Copy link
Contributor

@zhiyanzhaijie zhiyanzhaijie commented Dec 24, 2025

related: #160

A new sidebar component is added with followed changes:

  • r#as and merged_attribute in multiple components
  1. in primitive/lib.rs, add meged_attribute for component withr#as, handle class/props of component(TODO: event handler)
  2. r#as support - collapsible,tooltip, dropdown_menu
  • Style optimization
  1. better theme display of separator
  2. add gap in dropdown menu item
  • Add sidebar component
  1. SidebarProvider and others
  2. use_sidebar hook
  3. use_is_mobile hook (considering the right position in a shared module)
  4. doc and variant preview (playwright test)
  • Block component type and its display
  1. A new component type that need to be show in a isolate html, sidebar as example
  2. Change preview/src/main.rs, preview/src/mod.rs to allow block component display, by:
    - 2.1 extend example! macro
    - 2.2 add Route and component for block component, implement isolate envrionment by iframe (Only work in web platform now, not Desktop supported)
    - 2.3 refactoring theme sync, add theme.rs by set theme cookies and sychronize theme change across mutilple iframe by BroadcastChannel
    - 2.4 extractor html (--dark/--light) logic from main.css to dx-component-theme.css

lacks:

  1. using extra class in demo of sidebar to correctly show dropdown cotent (need floating ui)
  2. tooltip is now not working in sidebar collapsible (overflow: hidden) (need a unifying portal solution, those thing will be nice when mounted in the root of )
  3. mege_attribute is now experiment, consult needed

Big changes with r#as in others component, sry about that

@github-actions
Copy link

Copy link
Member

@ealmloff ealmloff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, the sidebar itself mostly looks right, but some of these changes will make the components harder to maintain in the long run.

Adding as everywhere is useful, but makes the attributes significantly harder to maintain. I would rather add support for some of this in core. An attributes macro that accepts the same syntax as the element body but expands to Vec<Attribut> would make this a lot easier to maintain:

attributes!{
    width: 100,
    onclick,
}

This will also need some playright tests for the sidebar behavior before it can be merged

/// - Other attributes are overwritten by the last occurrence.
///
/// TODO: event handler attributes are not merged/combined yet.
pub fn merge_attributes(lists: Vec<Vec<Attribute>>) -> Vec<Attribute> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spread attributes are required to be sorted by the attribute name for more efficient diffing (here). We need to maintain that property while merging and can use that property to more efficiently merge attribute lists

},
let open = ctx.open;
let disabled = ctx.disabled;
let data_state = use_memo(move || if open() { "open" } else { "closed" });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very cheap and nothing expensive depends on it, it doesn't need a memo

rsx! {
collapsible::CollapsibleTrigger { attributes: merged,
{props.children}
svg {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two CollapsibleTrigger's could be merged with an inline if statement in the block to only render the svg if as is_none()

pub side: Signal<SidebarSide>,
pub open: Signal<bool>,
pub set_open: Callback<bool>,
pub open_mobile: Signal<bool>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need two open signals/callbacks?

};
}

if is_mobile() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rendering a sheet instead of a sidebar on mobile doesn't seem like the right behavior. It looks like shadcn exposes options to adjust the width of the sidebar on mobile or hide the sidebar on mobile instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants