bahaha / cc-frontend-kata

0 stars 0 forks source link

feat(layout/header): collapsible header component with navigation elements #1

Open bahaha opened 3 hours ago

bahaha commented 3 hours ago

Header component in the layout used in the public pages

Functional requirement

Non-functional requirement

bahaha commented 2 hours ago

Menu collapse/expand state management approaches

Approach 1: Pure css only by hidden checkbox with connected label

<header>
    <input type="checkbox" id="header-nav" class="hidden" />
    <label for="header-nav">
       <!-- ... menu ... -->
    </label>
</header>
header { /** styles on menu is collapsed */ }
header:has(#header-nav:checked) { /** styles on menu is expanded */ }

Pros

Cons

Approach 2: React state management

const [isExpand, setIsExpand] = useState(false);

Pros

Cons


Decision

Choose Approach 1: Pure css only by hidden checkbox with connected label for

bahaha commented 2 hours ago

Menu backdrop effects and its collapsing animations

Approach 1: Height transition

header {
  height: var(--header-height);
  transition: height .3s;
  will-change: height; /** isolate layer to eliminate affected elements on reflow triggered by menu state changes"
}
header.expanded {
  height: calc(100% - var(--v-spacing));
}

Pros

Cons

Approach 2: Clip-path with pseudo element

header {
  position: fixed;
  clip-path: inset(0 0 calc(100% - var(--collapsed-header-height)) 0 round 12px);
  transition: clip-path .3s;
  will-change: clip-path; 
}
header::before {
  content: '';
  position: absolute;
  inset: 0;
  height: var(--collapsed-header-height);
  transition: height .3s;
}

Pros

Cons


Decision

Choose Approach 2: Clip-path with pseudo element for