my-layout.component.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import { Component, OnInit } from '@angular/core';
  2. @Component({
  3. selector: 'app-my-layout',
  4. template: `
  5. <div class="my-layout">
  6. <div class="my-sider shadow-sm" [style.width.px]="isCollapse ? 64 : 236" >
  7. <div class="my-sider-inner" >
  8. sider
  9. <admin-menu [isCollapsed]="isCollapse"></admin-menu>
  10. </div>
  11. </div>
  12. <div class="my-content" >
  13. <div class="my-header" >
  14. <button class="btn" (click)="isCollapse = !isCollapse">Toggle</button>
  15. my header
  16. </div>
  17. <div class="my-main-content">
  18. <router-outlet></router-outlet>
  19. </div>
  20. </div>
  21. </div>
  22. `,
  23. styles: [
  24. `
  25. .my-layout{
  26. display:flex;
  27. flex-direction : row;
  28. align-items: stretch;
  29. }
  30. .my-sider{
  31. position:relative;
  32. width:64px;
  33. transition: width 200ms ease-out, height 200ms ease-out;
  34. }
  35. .my-sider-inner{
  36. position:sticky;
  37. height:100vh;
  38. width:100%;
  39. top:0;
  40. left:0;
  41. background-color:white;
  42. }
  43. .my-content{
  44. flex: 1;
  45. display:flex;
  46. flex-direction:column;
  47. }
  48. .my-header{
  49. display:flex;
  50. flex-direction : row;
  51. align-items: center;
  52. height:64px;
  53. background-color:gray;
  54. position:sticky;
  55. top:0;
  56. left:0;
  57. z-index:1000;
  58. }
  59. .my-main-content{
  60. padding:20px;
  61. }
  62. `
  63. ]
  64. })
  65. export class MyLayoutComponent implements OnInit {
  66. constructor() { }
  67. isCollapse: boolean = true;
  68. toggle() {
  69. }
  70. ngOnInit(): void {
  71. }
  72. }