AppTopBar: automatically switch toolbar variant
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				/ depoly (push) Successful in 1m21s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	/ depoly (push) Successful in 1m21s
				
			This commit is contained in:
		
							parent
							
								
									bece50643f
								
							
						
					
					
						commit
						b2d8c1bb2e
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1,12 +1,15 @@
 | 
			
		|||
import { AppBar, Toolbar } from "@suid/material";
 | 
			
		||||
import { splitProps, type JSX, type ParentComponent } from "solid-js";
 | 
			
		||||
import "./AppTopBar.css";
 | 
			
		||||
import { useWindowSize } from "@solid-primitives/resize-observer";
 | 
			
		||||
 | 
			
		||||
const AppTopBar: ParentComponent<{
 | 
			
		||||
  class?: string;
 | 
			
		||||
  style?: JSX.HTMLAttributes<HTMLElement>["style"];
 | 
			
		||||
}> = (oprops) => {
 | 
			
		||||
  const [props, rest] = splitProps(oprops, ["children", "class"]);
 | 
			
		||||
  const windowSize = useWindowSize();
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <AppBar
 | 
			
		||||
      class={`AppTopBar ${props.class || ""}`}
 | 
			
		||||
| 
						 | 
				
			
			@ -15,7 +18,7 @@ const AppTopBar: ParentComponent<{
 | 
			
		|||
      {...rest}
 | 
			
		||||
    >
 | 
			
		||||
      <Toolbar
 | 
			
		||||
        variant="dense"
 | 
			
		||||
        variant={windowSize.width > windowSize.height ? "dense" : "regular"}
 | 
			
		||||
        class="toolbar"
 | 
			
		||||
        sx={{ paddingTop: "var(--safe-area-inset-top, 0px)" }}
 | 
			
		||||
      >
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue