Auro Sidenav Mobile Discussion #19
Replies: 5 comments 6 replies
-
Hey Doug, I just read through that. Good writeup. I'm not fully understanding very well the actually code issue you are trying to solve from the description here. However, I suspect that you are running into a problem with what we had outlined yesterday when we met where you would then have two HTML elements in the accordion trigger that both need to render the "trigger" slot content. Is that correct? |
Beta Was this translation helpful? Give feedback.
-
Let's schedule some time for another pair programing session. This is a challenge we have faced before. |
Beta Was this translation helpful? Give feedback.
-
Post-meeting notes. A clear takeaway from this is that neither a 100% CSS or JS solution was really the best answer. Looking at something more of a hybrid is a strong recommendation. The crux of the conversation was how to handle the switch between a mobile feature and desktop. Referencing the new auro-card solution where there is an option to have the card wrapped in a Having an attribute on sidenav that renders the component one way versus another seems appropriate. Whether or not to put the management of this attribute in the hands of the consumer versus having the component being There is a strong argument to be had that if the attribute is simply made available and it's up to the consumer to carry the last mile, that feels appropriate. This allows the consumer control over how this works versus the component owning a visual state. There is also an argument to be had for the 'out of box' experience and the consumer expecting that the component will react appropriately based on window controls. That statement alone has a smell to it. For a component to be aware of the environment outside its immediate concern is troubling and typically what we DO NOT want to do. However, in the case of visual responsivness, that is absolutely what we do. Thus the paradox. Recommendation: Use CSS where warranted. Best tool for the job, as we say. Regarding responsiveness, the requirement is past simple CSS Going down this route would require that we clearly define the API, what it does, and how it can be used. Test the theory: Once this has been engineered into a demonstratable version, the engineers will set up a meeting, specifically with the Content engineers, to discuss the API expectations and get feedback. re: design tokens. While you can technically access breakpoint via the |
Beta Was this translation helpful? Give feedback.
-
Sidenav Update Mar 7 2024This is our update after speaking with @marnel-mangrubang and @blackfalcon on the JS-backed attribute solution over a deeply-integrated CSS media query solution for converting the Sidenav from desktop to mobile, and vice versa. What's the verdict?We've decided to proceed with having the sidenav essentially "not care" what size screen it's on and only listen to a passed attribute on how it should render. We recognize that this is not ideal in the short term, but we have some far better long term solutions that should make using and developing for Auro a far better experience for everyone. Why did you decided not to use the CSS only solution?To summarize: complexity and ownership. We determined that any solution we chose here has the potential to bite us in the butt in one way or another, so we chose the most common approach we could find among popular frameworks (like MUI - see below media query solutions). The only CSS solution we landed on with @jason-capsule42 involves rendering an This seemed fine on the surface (and actually does work in practice) until we considered future maintainability. Cloning slots and managing breakpoint selection based on an attribute works fine for this one use case, but it's strictly limited to exactly those breakpoints defined as design tokens and limited to exactly this use case. Ultimately, we decided that including breakpoint specific styling is too close to an "application component" pattern than a library component pattern because it makes the above assumptions. While we don't want to hinder content producers or anyone else who wants to use a Sidenav, there are better and more reliable ways to get an easy boolean operation done than including it as part of a strict enumerated attribute in every component that needs responsive wrappers. What do you propose then for CSS media query rendering in Auro?Many of the popular libraries out today use media query "hooks" or equivalent reactive functions from their respective parent frameworks. We'd love to see an We both believe that using these media query exposure solutions can be a far larger lift for responsive design than having to implement media query solutions for every component that needs it. FeedbackPlease let us know if you have any opinions on this as we are extremely interested in feedback. We want to introduce standard solutions that people enjoy using to avoid ending up like this: |
Beta Was this translation helpful? Give feedback.
-
Post Meeting Notesauro-sidenav/pull/20 Summary/Context:We propose a generalized solution for managing state, content, and/or structural changes based on variable screen resolutions. We suggest that library components not endeavor to media match nor show or hide DOM nodes via CSS for the following reasons:
Instead, we've proposed that components with variable structure should contain a Boolean attribute to dictate the rendering path. Topics discussed:
|
Beta Was this translation helpful? Give feedback.
-
Mobile Sidenav refactor
This is related to -> #18
What are we discussing?
How much JS is too much JS for the mobile sidenav? Can we use a combination of
window.innerWidth
+ css breakpoints to render out different "branches" to avoid rapidly increasing complexity?We'd like to propose using window resize events in addition to some heavier CSS lifts where possible to avoid problems in the future.
Context
@rsstdd and I (@DukeFerdinand ) have been working toward as close to a CSS-only solution as possible for the auro sidenav accordion wrapper on mobile. We had a great discussion yesterday after standup with @jason-capsule42 regarding some concerns about using JavaScript to detect window resizing. The main concern is using too much JS and trying to find CSS-only or mostly-CSS solutions to let the browser handle as much as we can since it's far faster to use media queries than
window.innerWidth
at scale.Another concern we're trying to address is using too many
if/else
branching logic points, resulting in a harder-to-maintain component down the line. Wrapping everything in an accordion 100% of the time is a direct result of this concern and attempts to mitigate that by always having an accordion and just disabling certain features like click handlers when we aren't on a mobile screen size.Assumptions (as of yesterday)
manual
prop or similar to the Accordion component will allow us to avoid any heavy JavaScript operations by leveraging the above "css hide/show" techniques.Realities (as of today)
display: none
does nothing functionally and the first slot will always be selected regardless of visibility.slot
elements in onediv
) but cannot be kept in-sync except by way of some JavaScript element cloning. This ultimately means you'd need to clone a slot with JS on first render and subsequent renders if you need reactivity.if/else
branch in the render tree.manual
prop to Auro Accordion would not reduce the amount of JS needed in a significant way and might actually just act as a further complication if wrapping/unwrapping template string manipulation is on the table :)Proposed solution
Ultimately, even though we had concerns with it at the beginning, dynamically wrapping the sidenav in an accordion based on a debounced
window.resize
event listener does seem to be the best solution here. It feels really jank at times, but the only other solutions presently available are actually worse in a number of ways :(We actually just got done with a largely similar problem HERE for Auro Card where we needed to wrap or unwrap a card in an
auro-hyperlink
based on an href attribute using JS. The difference here of course is when the wrap/unwrap happen but debouncing is a common solution for reducing event side effects.I think there's merit to leveraging much of our CSS solutions here, but leaning on the window resize event seems like a way smaller lift.
Recommended reading (unverified statistics)
Beta Was this translation helpful? Give feedback.
All reactions